[DUG] Image manipulation

Conor Boyd Conor.Boyd at trimble.co.nz
Tue Oct 13 16:30:32 NZDT 2009


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

________________________________

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


I have some code that I wrote form bits of other code off the net that
resizes images so they dont loose any quality. But like how Photoshop
does it etc.....well nearly.
I needed one that did scaling so that the aspect ratio was retained. It
seems to work ok.

Jeremy


On Tue, Oct 13, 2009 at 4:05 PM, Kyley Harris <Kyley at harrissoftware.com>
wrote:


	GraphicsEx is great.. but I do everything with BMP and JPG only
	
	
	On Tue, Oct 13, 2009 at 3:43 PM, Robert martin
<rob at chreos.co.nz> wrote:
	

		Hi
		
		We want to do some basic image manipulation.
Specifically the following
		
		1) open and dipslay Gif, jpg, and png image formats.
		2) Resize the above file format
		3) Save file back in resized format.
		
		Does anyone have or recommend any code for doing such?
		
		I have seen GraphixEx but it states it does not support
saving of images.
		
		Cheers
		Rob
		
		_______________________________________________
		NZ Borland Developers Group - Delphi mailing list
		Post: delphi at delphi.org.nz
		Admin: http://delphi.org.nz/mailman/listinfo/delphi
		Unsubscribe: send an email to
delphi-request at delphi.org.nz with Subject: unsubscribe
		

	
	
	
	-- 
	Kyley Harris
	Harris Software
	+64-21-671-821
	
	_______________________________________________
	NZ Borland Developers Group - Delphi mailing list
	Post: delphi at delphi.org.nz
	Admin: http://delphi.org.nz/mailman/listinfo/delphi
	Unsubscribe: send an email to delphi-request at delphi.org.nz with
Subject: unsubscribe
	


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


More information about the Delphi mailing list