this slowpoke moves

Scale Bitmap

private
    { Private declarations }
  public
    { Public declarations }
     function ScalePercentBmp(bitmp: TBitmap; iPercent: Integer): Boolean;
  end;
  
//  

function TForm1.ScalePercentBmp(bitmp: TBitmap;
  iPercent: Integer): Boolean;
var
  TmpBmp: TBitmap;
  ARect: TRect;
  h, w: Real;
  hi, wi: Integer;
begin
  Result := False;
  try TmpBmp := TBitmap.Create;
    try
      h := bitmp.Height * (iPercent / 100);
      w := bitmp.Width * (iPercent / 100);
      hi := StrToInt(FormatFloat('#', h)) + bitmp.Height;
      wi := StrToInt(FormatFloat('#', w)) + bitmp.Width;
      TmpBmp.Width := wi;
      TmpBmp.Height := hi; ARect := Rect(0, 0, wi, hi);
      TmpBmp.Canvas.StretchDraw(ARect, Bitmp);
      bitmp.Assign(TmpBmp); finally
      TmpBmp.Free; end; Result := True;  except  Result := False;
  end;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
begin
  ScalePercentBmp(Image1.Picture.Bitmap,
                  10);  // HIER DIE PROZENTUALE SKALIERUNG ANGEBEN
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate