Einzelnen Beitrag anzeigen

Nuclear-Ping
(Gast)

n/a Beiträge
 
#13

Re: Wie zuverlässig ist der MemoryLeak-Report von FastMM?

  Alt 12. Mär 2008, 09:39
Ja, während der Sendung läuft zB meist ein Oszilloskop (kommt drauf an, was man für 'ne Hardware dranhängen hat) und die dazu gehörigen Listen werden dargestellt. Die können pro Eintrag zwei Symbole haben, was unterm Strich immer ein Bild ist. Selbst wenn kein Symbol eingetragen wurde, wird halt ein "Kein Symbol"-Bild gezeigt, was aus einer ImageList kommt. Sonst wird das dazugehörige Bild von einer externen Quelle geladen.

[edit]
Hier mal der Code vom Zeichnen der Symbole.
Delphi-Quellcode:
procedure DrawCellSymbol (Sender: TBaseVirtualTree; TargetCanvas: TCanvas;
  Node: PVirtualNode; Column: TColumnIndex; CellRect: TRect;
  ImageList: TImageList; Symbol1Col, Symbol2Col: Integer;
  CategoryId: Integer);
var
  bmp: TBitmap;
  ThumbFileName,
  Text: String;
  SymbolIndex,
  DrawX, DrawY,
  ImageIndex: Integer;
  Data: PDatabaseData;
  DrawRect: TRect;
  JPG: TJPEGImage;
  iSymbolType: TSymbolType;
  iSymbol: TSymbolStream;
  HasThumbnail,
  SaveThumbnail,
  DrawSymbol: Boolean;
begin
  if (Column <> Symbol1Col) and
     (Column <> Symbol2Col) then
    Exit;

  Data := Sender.GetNodeData (Node);

  SymbolIndex := 0;
  if Column = Symbol1Col then
    begin
      SymbolIndex := 1;
      DrawSymbol := TRUE;
      iSymbolType := Data.SymbolType1;
      iSymbol := Data.Symbol1;
    end
  else if Column = Symbol2Col then
         begin
           SymbolIndex := 2;
           DrawSymbol := TRUE;
           iSymbolType := Data.SymbolType2;
           iSymbol := Data.Symbol2;
         end
       else DrawSymbol := FALSE;

  ThumbFileName := GetApplicationPersonalThumbsPath +
                   inttostr (Node.Index) +
                   inttostr (Data.ID) +
                   inttostr (Data.HealingsheetIndexID) +
                   inttostr (SymbolIndex) +
                   inttohex (CategoryId, 8) +
                   '.bmp';

  if DrawSymbol then
    begin
      bmp := TBitmap.Create;
      try
        case iSymbolType of
          stNoSymbol:
            ImageIndex := 0;
          stImage:
            ImageIndex := 1;
          stSound:
            ImageIndex := 2;
          stVibration:
            ImageIndex := 4;
          else
            ImageIndex := 3;
        end;

        // Wenn Symbol ein Bild ist, externe Datei laden
        if (iSymbolType = stImage) then
          begin
            HasThumbnail := FileExists (ThumbFileName);
            if HasThumbnail then
              bmp.LoadFromFile (ThumbFileName);

            iSymbol.Position := 0;
            if not HasThumbnail then
              begin
                if (Is_BLOB_JPG (iSymbol)) then
                  begin
                    JPG := TJPEGImage.Create;
                    JPG.LoadFromStream (iSymbol);
                    bmp.Assign (JPG);
                    FreeAndNil (JPG);
                  end
                else bmp.LoadFromStream (iSymbol);
              end;
          end
        else ImageList.GetBitmap (ImageIndex, bmp); // ... sonst aus ImageList das dazugehörige Symbol
             
        with TargetCanvas do
          begin
            Font.Color := Sender.Font.Color;
            Text := SymbolTitles[ImageIndex];

            DrawRect := ClipRect;
            DrawRect.Right := DrawRect.Right - 8;

            DrawText (TargetCanvas.Handle,
                      PChar (Text),
                      Length (Text),
                      DrawRect,
                      DT_SINGLELINE or DT_VCENTER or DT_RIGHT);

            if (iSymbolType = stImage) then
              begin
                SaveThumbnail := FALSE;
                // Bild neu skalieren?
                SaveThumbnail := ResizeBitmap (bmp, 80, 80);

                DrawX := ClipRect.Left +
                         Round ((ClipRect.Right - ClipRect.Left) / 2) -
                         Round (bmp.Width / 2);

                DrawY := ClipRect.Top +
                         Round ((ClipRect.Bottom - ClipRect.Top) / 2) -
                         Round (bmp.Height / 2);

                Draw (DrawX, DrawY, bmp);

                if SaveThumbnail then
                  if (Data.ID = 0) and
                     (Data.HealingsheetIndexID = 0) then
                    SaveThumbnail := FALSE;

                if SaveThumbnail then
                  bmp.SaveToFile (ThumbFileName);
              end
            else begin
                   DrawRect := ClipRect;
                   DrawRect.Left := DrawRect.Left +
                                    (Sender as TVirtualStringTree).Margin +
                                    4;
                   DrawRect.Top := DrawRect.Top + (Round ((DrawRect.Bottom - DrawRect.Top) / 2) - 16);

                   Draw (DrawRect.Left,
                         DrawRect.Top,
                         bmp);
                 end;
          end;

      finally
        FreeAndNil (bmp);
      end;
    end;
end;
[/edit]
  Mit Zitat antworten Zitat