Kylix
Tips

NEW TIPS
Database (90)
Files (138)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Search Tip
Top15
Add new Tip

Forum

...stretch a bitmap?
Author: Frank Ditsche
Homepage: www.fditsche.de
[ Print tip ]    

Tip Rating (21):  
     



// This function stretches a bitmap with specified number of pixels
// in horizontal, vertical dimension
// Example Call : ResizeBmp(Image1.Picture.Bitmap , 200 , 200);

// Diese Funktion zerrt eine Bitmap in die anzugebenden Pixel
// Beispielaufruf : ResizeBmp(Image1.Picture.Bitmap , 200 , 200);

function TForm1.ResizeBmp(bitmp: TBitmap; wid, hei: Integer): Boolean;
var 
  
TmpBmp: TBitmap;
  ARect: TRect;
begin
  
Result := False;
  try
    
TmpBmp := TBitmap.Create;
    try
      
TmpBmp.Width  := wid;
      TmpBmp.Height := hei;
      ARect := Rect(0,0, wid, hei);
      TmpBmp.Canvas.StretchDraw(ARect, Bitmp);
      bitmp.Assign(TmpBmp);
    finally
      
TmpBmp.Free;
    end;
    Result := True;
  except
    
Result := False;
  end;
end;

Rate this tip:

poor
very good


Copyright  Torry's Delphi Pages Torry's Delphi Pages Maintained by Simon Grossenbacher Notes? Comments? Feel free to send... Copyright 1996-2001