Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Bitmaps skalieren (https://www.delphipraxis.net/68781-bitmaps-skalieren.html)

omsec 5. Mai 2006 12:05


Bitmaps skalieren
 
Hallo
Durch zuweisen von Width/Height ändern sich ja die Abmessung einer Graphik. Leider wird dann aber das Bild nicht angepasst. Wie bekomme ich enen Zoom-Effekt hin ? Die Bilddaten liegen als TBitmap-Instanz vor.

Klaus01 5. Mai 2006 12:08

Re: Bitmaps skalieren
 
im OI stretch auf true setzen, dann passt sich das Bild der Imagekomponente an.

Grüße
Klaus

Muetze1 5. Mai 2006 12:47

Re: Bitmaps skalieren
 
Male das Bitmap mit CopyRect() oder StretchBlt() auf das grössere Bitmap.

omsec 5. Mai 2006 13:11

Re: Bitmaps skalieren
 
Nun ja, auf den Komfort einer TImage-Komponente muss ich verzichten, da ich mich im OnDrawCell-Handler eines DrawGrids befinde, dieser kennt ja nur den Canvas. Daher mein Hinweis auf die TBitmap-Instanz.

Mir ist allerdings nicht ganz klar, wie ich die BtretchBlt-Funktion in diesem Kontext anwenden muss.

Delphi-Quellcode:
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);

var
  bmp: TBitMap;
 
begin
// ShowMEssage('Col: ' + IntToStr(ACol) + ' Row: ' + IntToStr(ARow));
 bmp := TBitmap.Create;
 try
   if (ACol = 0) and (ARow = 0) then
     begin
       bmp.LoadFromFile('c:\temp\charset\1.bmp');
       StretchBlt ??? // Device Context = Handle der Form ?
     end;
   if (ACol = 1) and (ARow = 0) then
     bmp.LoadFromFile('c:\temp\charset\2.bmp');
   if (ACol = 2) and (ARow = 0) then
     bmp.LoadFromFile('c:\temp\charset\3.bmp');
   if (ACol = 3) and (ARow = 0) then
     bmp.LoadFromFile('c:\temp\charset\4.bmp');
   if (ACol = 4) and (ARow = 0) then
     bmp.LoadFromFile('c:\temp\charset\5.bmp');    
 finally
   bmp.Free;
 end;
end;

Muetze1 5. Mai 2006 13:47

Re: Bitmaps skalieren
 
1. Grundlegend solltest du keine Bilder laden im Draw Handler - lade sie dir vorher und male sie dort nur noch!

2.
Delphi-Quellcode:
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  ARect: TRect; State: TGridDrawState);

var
  bmp: TBitMap;
 
begin
  // ShowMEssage('Col: ' + IntToStr(ACol) + ' Row: ' + IntToStr(ARow));
  bmp := TBitmap.Create;
  try
    If ( ARow = 0 ) And ( ACol In [0..4] ) Then
      bmp.LoadFromFile(Format('c:\temp\charset\%d.bmp', [Succ(ACol)]));

    If ( Not Bmp.Empty ) Then
    Begin
        // beachte, dass ich den Parameter "Rect" in "ARect" umbenannt habe!
      TDrawGrid(Sender).Canvas.CopyRect(ARect, Bmp.Canvas, Rect(0, 0, Bmp.Width, Bmp.Height));
    End;
  finally
    bmp.Free;
  end;
end;

Mackhack 5. Mai 2006 15:43

Re: Bitmaps skalieren
 
//OT;
Fuer was steht eigentlich das Blt in StretchBlt?

Muetze1 5. Mai 2006 15:49

Re: Bitmaps skalieren
 
Blit

kommt vom Wort "blitting". Mehr dazu siehe Wikipedia: BitBlit

siehe auch der z.T. in Hardware ausgeführten Blitter - Einheit (Atari STE hatte einen, der Amiga 600 auch...)

Mackhack 5. Mai 2006 15:53

Re: Bitmaps skalieren
 
Dank dir Muetze1... Informativ und wieder ne Frage weniger in meinem Kopf! :lol:

Muetze1 5. Mai 2006 15:56

Re: Bitmaps skalieren
 
Nachtrag:

BLIT = BLock Image Transfers


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:45 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz