Thema: Delphi Bildgroesse veraendern

Einzelnen Beitrag anzeigen

peanut
(Gast)

n/a Beiträge
 
#5

Re: Bildgroesse veraendern

  Alt 10. Mai 2007, 13:27
Hallo,

ich habe ein ähnliches Problem gehabt und es dank dieses Threads dann gelöst. Vielleicht helfen die folgenden Prozeduren auch anderen weiter:

Delphi-Quellcode:
procedure ResizeTImage(const Image: TImage; Width, Height: Integer);
begin
  SetStretchBltMode(Image.Picture.Bitmap.Canvas.Handle, STRETCH_HALFTONE);
  SetBrushOrgEx(Image.Picture.Bitmap.Canvas.Handle, 0, 0, nil);
  StretchBlt(Image.Picture.Bitmap.Canvas.Handle, 0, 0, Width, Height, Image.Picture.Bitmap.Canvas.Handle, 0, 0, Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height, SRCCOPY);
  Image.Picture.Bitmap.Width := Width;
  Image.Picture.Bitmap.Height := Height;
end;

procedure ScaledResizeTImage(const Image: TImage; maxWidth, maxHeight: Integer);
var
  r: Double;
begin
  r := Min(maxWidth/Image.Picture.Bitmap.Width, maxHeight/Image.Picture.Bitmap.Height);
  SetStretchBltMode(Image.Picture.Bitmap.Canvas.Handle, STRETCH_HALFTONE);
  SetBrushOrgEx(Image.Picture.Bitmap.Canvas.Handle, 0, 0, nil);
  StretchBlt(Image.Picture.Bitmap.Canvas.Handle, 0, 0, Round(Image.Picture.Bitmap.Width * r), Round(Image.Picture.Bitmap.Height * r), Image.Picture.Bitmap.Canvas.Handle, 0, 0, Image.Picture.Bitmap.Width, Image.Picture.Bitmap.Height, SRCCOPY);
  Image.Picture.Bitmap.Width := Round(Image.Picture.Bitmap.Width * r);
  Image.Picture.Bitmap.Height := Round(Image.Picture.Bitmap.Height * r);
end;
Viel Spaß damit und viele Grüße,

peanut.
  Mit Zitat antworten Zitat