stretch a jpg

how do I stretch a jpg to low down the size ?
LVL 3
bryan7Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DrDelphiCommented:
Try this out for size ( or resizing) <G>

Procedure ScaleDownJPG(Fname:string;newheight,newWidth:integer) ;

var JPG1,JPG2:TJpegImage;
    BMP:Tbitmap;
Begin
  try
     JPG1:=TJpegimage.create;
     JPG2:=TJpegimage.create;
     BMP:=Tbitmap.create;
     Jpg1.LoadFromFile(Fname);
     With BMP do
     begin
       height:=newheight;
       Width:=newWidth;
       canvas.stretchdraw(canvas.cliprect,jpg1);
     end;
     bmp.savetofile('Z:\test.bmp');
     JPG2.assign(BMP);
     DeleteFile(fname);
     Jpg2.savetofile(fname);
   finally
     Jpg1.free;
     Jpg2.free;
     BMP.free;
   end;
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
edeyCommented:
for *file* sizes try this TJpegImage property:

CompressionQuality indicates the trade-off ratio between the image quality and the file size.

TJPEGQualityRange = 1..100;
property CompressionQuality: TJPEGQualityRange;

GL
Mike
0
bryan7Author Commented:
I already use that property but I also want to reduce the size
0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

bryan7Author Commented:
is it possible to resize directly the jpg without using a bitmap ?
I need to get screen captures to a jpeg to pass them to a memorystream to send over tcp/ip so I need some speed.. it would be faster if there was a way to resize the jpeg itself without passing through a bitmap before..
0
DrDelphiCommented:
The problem is that the Jpeg doesn't have a Canvas property, so you can't StretchDraw to it. To accomplish what you are looking for , you are going to have to use some sort of intermediate device context.... a bitmap, TCanvas, etc.

Good luck!!
0
bryan7Author Commented:
sorry for the delay..

thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Graphics Software

From novice to tech pro — start learning today.