Einzelnen Beitrag anzeigen

Benutzerbild von ATS3788
ATS3788

Registriert seit: 18. Mär 2004
Ort: Kriftel
646 Beiträge
 
Delphi XE Starter
 
#1

BMP Resize suche guten Algorithmus

  Alt 24. Jan 2011, 19:10
Hallo

Weiß jemand einen Link für einen guten Algorithmus
zum vergrößern verkleinern einer Bitmap.

Delphi-Quellcode:
function ResizeBitmap(_Bitmap : TBitmap; const maxWidth, maxHeight : integer) : boolean;
 var
   thumbnail : TBitmap;
   thumbRect : TRect;
 begin

   try
    thumbnail := TBitmap.Create;
     thumbRect.Left := 0;
     thumbRect.Top := 0;
      thumbnail.Assign(_Bitmap);

     //proportional resize
     if thumbnail.Width > thumbnail.Height then
     begin
       thumbRect.Right := maxWidth;
       thumbRect.Bottom := (maxWidth * thumbnail.Height) div thumbnail.Width;
     end
     else
     begin
       thumbRect.Bottom := maxHeight;
       thumbRect.Right := (maxHeight * thumbnail.Width) div thumbnail.Height;
     end;

     thumbnail.Canvas.StretchDraw(thumbRect, thumbnail) ;

//resize image
     thumbnail.Width := thumbRect.Right;
    thumbnail.Height := thumbRect.Bottom;

     //display in a TImage control
     Form4.Im.Picture.Assign(nil);
       thumbnail.SaveToFile('d:\zz.bmp');
    Form4.Im.Picture.Assign(thumbnail);
   finally
     thumbnail.Free;
   end;
 end;
Habe dies im Netz gefunden mit beschränkten
"Antialiasing" Ergebnis.
Martin MIchael
  Mit Zitat antworten Zitat