Message-ID: <3D8BD38D.11AD94F1@borland.newsgroups> Date: Sat, 21 Sep 2002 12:03:57 +1000 From: Charles Hacker X-Mailer: Mozilla 4.78 [en] (Win98; U) X-Accept-Language: en,pdf MIME-Version: 1.0 Newsgroups: borland.public.delphi.graphics Subject: Re: JPEG... changing size !?!? References: <3d8b33d7@newsgroups.borland.com> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 132.234.129.30 X-Trace: newsgroups.borland.com 1032573842 132.234.129.30 (20 Sep 2002 19:04:02 -0700) Lines: 54 Path: newsgroups.borland.com!not-for-mail Xref: newsgroups.borland.com borland.public.delphi.graphics:51413 "Arquétipo" wrote: > > Does anyone knows how to change the size of JPEG images from 800x600 to > 1014x618 using Delphi ? Here is some code I use. However it does NOT give a 'smooth' resize of the image, (thus the resized image is not as good). As stated in the other posting, better to use the Bitmap Resampler code. uses jpeg; var Jpg : TJPEGImage; Bmp : TBitmap; procedure ResizeBMP(b : TBitmap; NewWidth, NewHeight : integer); var tbmp : TBitmap; begin tbmp := TBitmap.Create; tbmp.Width := b.Width; tbmp.Height := b.Height; BitBlt(tbmp.Canvas.Handle,0,0,tbmp.Width,tbmp.Height, b.Canvas.Handle,0,0,SRCCOPY); b.Width := NewWidth; b.Height := NewHeight; StretchBlt(b.Canvas.Handle,0,0,b.Width,b.Height,tbmp.Canvas.Handle, 0,0,tbmp.Width,tbmp.Height,SRCCOPY); tbmp.Free; end; begin Jpg := TJPEGImage.Create; Bmp := TBitmap.Create; Jpg.LoadFromFile('FileName.jpg'); // Copy JPEG to bitmap: Bmp.Width := Jpg.Width; Bmp.Height := Jpg.Height; Bmp.Canvas.Draw(0,0,Jpg); // Resize Bitmap ResizeBMP(Bmp,[newsizeW],[newsizeh]); // Copy BMP back to JPG Jpg.Assign(Bmp); Jpg.Free; Bmp.Free; end; -- Charles Hacker Lecturer in Electronics and Computing School of Engineering Griffith University - Gold Coast Australia