[DUG] Image manipulation

Conor Boyd Conor.Boyd at trimble.co.nz
Tue Oct 13 17:04:28 NZDT 2009


Dunno about the pngs.

Feel free to send him my way directly if he has more questions...
 
C.

________________________________

From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Robert martin
Sent: Tuesday, 13 October 2009 4:41 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Image manipulation


Nice !

I had read that since GraphicsEx loads images as bitmaps you lost some
of the advanced features of the image format.  Do you know if png files
retain their transparencies?

This all looks very promising.  I will forward this on to the man doing
the work :)

Rob



 



Conor Boyd wrote: 

	Yeah, those issues are what drove my choice of Graphics32 (image
quality and scaling).
	 
	Here's some code which uses Graphics32 to resample an image.
	 
	OldBitmap, TempBitmap are of type Graphics32.TBitmap32
	NewBitmap is of type Graphics.TBitmap;
	 
	  OldBitmap.Assign(a regular Graphics.TBitmap here which you
could load using GraphicEx);
	 
	  TempBitmap := TBitmap32.Create;
	  try
	    TempBitmap.Width := Trunc(OldBitmap.Width * Scale);
	    TempBitmap.Height := Trunc(OldBitmap.Height * Scale);
	 
	    rs := TKernelResampler.Create(OldBitmap);
	 
	    if FastResamplingWanted then
	      rs.Kernel := THermiteKernel.Create
	    else
	      rs.Kernel := TLanczosKernel.Create;
	 
	    GR32_Resamplers.StretchTransfer(TempBitmap,
	                                    Rect(0, 0, TempBitmap.Width,
TempBitmap.Height),
	                                    Rect(0, 0, TempBitmap.Width,
TempBitmap.Height),
	                                    OldBitmap,
	                                    Rect(0, 0, OldBitmap.Width,
OldBitmap.Height),
	                                    rs, dmBlend, Nil);
	 
	    NewBitmap.Assign(TempBitmap);
	  finally
	    TempBitmap.Free;
	  end;
	
	I've paraphrased this from some code of mine, but hopefully
that's the gist of a high-quality resample for you using Graphics32.
	 
	Cheers,
	 
	Conor


	[snip] 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20091013/7f800083/attachment.html 


More information about the Delphi mailing list