Mega Code Archive

 
Categories / Delphi / Examples
 

Scalebitmaptosize

procedure TDrawObj.ScaleBitMapToSize(var anyBitMap: Graphics.TBitMap; newWidth, newHeight: Integer); //scale the passed bitmap according to the width and height dimensions //passed in... var tempBitMap: TBitMap; newRect: TRect; begin tempBitMap := TBitMap.Create; newRect.Left := 0; newRect.Right := newWidth; newRect.Top := 0; newRect.Bottom := newHeight; tempBitMap.Width := newWidth; tempBitMap.Height := newHeight; tempBitMap.Canvas.StretchDraw(newRect, anyBitMap); anyBitMap.Width := tempBitMap.Width; anyBitMap.Height := tempBitMap.Height; anyBitMap.Assign(tempBitMap); tempBitMap.Free; end;