Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi [GR32] How to resize TBitmap32? (https://www.delphipraxis.net/149014-%5Bgr32%5D-how-resize-tbitmap32.html)

WojTec 12. Mär 2010 11:50


[GR32] How to resize TBitmap32?
 
Hi, I have problem with TBitmap32 resizing :( Here is my code:

Delphi-Quellcode:
const
  RESAMPLER: array [0..2] of TBitmap32ResamplerClass = (TNearestResampler,
    TLinearResampler, TDraftResampler
  );
var
  B: TBitmap32;
begin
  with TResamplingSettings.Create(Image32.Bitmap.Width, Image32.Bitmap.Height) do
  begin
    if Execute then
    begin
      B := TBitmap32.Create;
      try
        RESAMPLER[2].Create(Image32.Bitmap);

        B.Resampler := Image32.Bitmap.Resampler;
        B.SetSizeFrom(Image32.Bitmap);
        B.Assign(Image32.Bitmap);

        Image32.Bitmap.SetSize(ImageWidth, ImageHeight);
        Image32.Bitmap.Draw(Rect(0, 0, Image32.Bitmap.Width, Image32.Bitmap.Height),
          Image32.Bitmap.BoundsRect, B
        );
      finally
        B.Free;
      end;
    end;
  end;
end;

// TResamplingSettings - window, where can set new size
// Image32 - component where is bitmap
// ImageWidth, ImageHeight - properties from TResamplingSettings
So, this only do well new size, can't correctly repaint old bitmap in new size and causes memory leak (large blocks). I have GR32 1.83. Could you help?

DeddyH 12. Mär 2010 12:22

Re: [GR32] How to resize TBitmap32?
 
I am not familiar with TBitmap32, but when is this object being freed?
Zitat:

Delphi-Quellcode:
RESAMPLER[2].Create(Image32.Bitmap);

I guess this is the reason for the memory leak, you should store it in a variable which you can free when it is no longer needed.


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:54 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz