<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18813">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT color=#000000 size=2 face=Arial>I have a neat program that can picks 
a JPG file, converts JPG to BMP and back and resize it at will too.</FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial>The trick is that you can resize 
as&nbsp;a BMP, but save back as a JPG</FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 face=Arial>Can email the rest of the project, 
but here is the main unit to show its not hard to do...</FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 face=Arial>This program&nbsp;zooms a bevel in 
and out&nbsp;to show the size of the image will be when resized, but does not 
actually resize until you click resize now, as the image would lose quality by 
being continuously resized.</FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 face=Arial>Its all done by about 4 lines in the 
ResizeNow procedure</FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV>John</DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 face=Arial>Code</FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 face=Arial>unit TestJpeg1;</FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 face=Arial>//ideas 
from<BR>//http://www.delphi3000.com/articles/article_4399.asp?SK=<BR>//(compression)</FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 
face=Arial>//and<BR>//http://www/efg2.com/Lab/Library/UseNet/200/0803a.txt<BR>//re 
using Stretchdraw and Rect</FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV><FONT 
color=#000000 size=2 face=Arial>
<DIV><BR>//#### BMPIn and JPGIn need to be Free'd 30/10/2008</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>interface</DIV>
<DIV>&nbsp;</DIV>
<DIV>uses<BR>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, 
Controls, Forms,<BR>&nbsp; Dialogs, StdCtrls, FindFile, ExtCtrls, JPEG;</DIV>
<DIV>&nbsp;</DIV>
<DIV>type<BR>&nbsp; TForm1 = class(TForm)<BR>&nbsp;&nbsp;&nbsp; FindFile1: 
TFindFile;<BR>&nbsp;&nbsp;&nbsp; ListBox1: TListBox;<BR>&nbsp;&nbsp;&nbsp; 
edtPath: TEdit;<BR>&nbsp;&nbsp;&nbsp; Label1: TLabel;<BR>&nbsp;&nbsp;&nbsp; 
Label2: TLabel;<BR>&nbsp;&nbsp;&nbsp; lblFilename: TLabel;<BR>&nbsp;&nbsp;&nbsp; 
Label4: TLabel;<BR>&nbsp;&nbsp;&nbsp; edtFileOut: TEdit;<BR>&nbsp;&nbsp;&nbsp; 
ImageIn: TImage;<BR>&nbsp;&nbsp;&nbsp; btnFind: TButton;<BR>&nbsp;&nbsp;&nbsp; 
Label5: TLabel;<BR>&nbsp;&nbsp;&nbsp; lblWidthHeight: 
TLabel;<BR>&nbsp;&nbsp;&nbsp; Label3: TLabel;<BR>&nbsp;&nbsp;&nbsp; Label6: 
TLabel;<BR>&nbsp;&nbsp;&nbsp; edtWidthOut: TEdit;<BR>&nbsp;&nbsp;&nbsp; 
edtHeightOut: TEdit;<BR>&nbsp;&nbsp;&nbsp; ImageOut: 
TImage;<BR>&nbsp;&nbsp;&nbsp; btnMinus20: TButton;<BR>&nbsp;&nbsp;&nbsp; 
btnPlus20: TButton;<BR>&nbsp;&nbsp;&nbsp; btnResize: 
TButton;<BR>&nbsp;&nbsp;&nbsp; btnSave: TButton;<BR>&nbsp;&nbsp;&nbsp; 
lblStatus: TLabel;<BR>&nbsp;&nbsp;&nbsp; Label7: TLabel;<BR>&nbsp;&nbsp;&nbsp; 
Label8: TLabel;<BR>&nbsp;&nbsp;&nbsp; Bevel1: TBevel;<BR>&nbsp;&nbsp;&nbsp; 
procedure btnFindClick(Sender: TObject);<BR>&nbsp;&nbsp;&nbsp; procedure 
ListBox1DblClick(Sender: TObject);<BR>&nbsp;&nbsp;&nbsp; procedure 
btnMinus20Click(Sender: TObject);<BR>&nbsp;&nbsp;&nbsp; procedure 
btnPlus20Click(Sender: TObject);<BR>&nbsp;&nbsp;&nbsp; procedure 
btnResizeClick(Sender: TObject);<BR>&nbsp;&nbsp;&nbsp; procedure 
btnSaveClick(Sender: TObject);<BR>&nbsp; private<BR>&nbsp;&nbsp;&nbsp; procedure 
SetJPGCompression(ACompression: integer; const 
AInFile,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AOutFile: 
string);<BR>&nbsp;&nbsp;&nbsp; procedure ShowSizeOut;<BR>&nbsp;&nbsp;&nbsp; 
procedure ResizeNow;<BR>&nbsp;&nbsp;&nbsp; { Private declarations }<BR>&nbsp; 
public<BR>&nbsp;&nbsp;&nbsp; { Public declarations }<BR>&nbsp; end;</DIV>
<DIV>&nbsp;</DIV>
<DIV>var<BR>&nbsp; Form1: TForm1;<BR>&nbsp; FileList:TStringList;<BR>&nbsp; 
FileIn,FileOut:String;<BR>&nbsp; JPGIn : TJPegImage;<BR>&nbsp; BMPIn : 
TBitMap;<BR>&nbsp; JPGOut : TJPegImage;<BR>&nbsp; BMPOut : TBitMap;<BR>&nbsp; 
WidthOut,HeightOut:Integer;<BR>&nbsp; ZoomUpDown:integer; //counter number times 
zoomed up (+) or down (-)</DIV>
<DIV>&nbsp;</DIV>
<DIV>implementation</DIV>
<DIV>&nbsp;</DIV>
<DIV>{$R *.dfm}</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>procedure TForm1.btnMinus20Click(Sender: TObject);<BR>begin<BR>&nbsp; 
HeightOut:=(HeightOut * 100) div 120;<BR>&nbsp; WidthOut:=(WidthOut * 100) div 
120;<BR>&nbsp; ZoomUpDown:=ZoomUpDown-1;<BR>&nbsp; if(Zoomupdown=0) 
then<BR>&nbsp; begin<BR>&nbsp;&nbsp;&nbsp; WidthOut:=JPGIn.Width;&nbsp; 
//original sizes - avoid rounding errors<BR>&nbsp;&nbsp;&nbsp; 
HeightOut:=JPGIn.Height;&nbsp; //original sizes - avoid rounding 
errors<BR>&nbsp; end;<BR>&nbsp; ShowSizeOut;<BR>//&nbsp; 
ResizeNow;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //this slows 
down clicking of course...<BR>end;</DIV>
<DIV>&nbsp;</DIV>
<DIV>procedure TForm1.ShowSizeOut;<BR>begin<BR>&nbsp; 
edtWidthOut.text:=inttostr(WidthOut);<BR>&nbsp; 
edtHeightOut.text:=inttostr(HeightOut);<BR>&nbsp; 
bevel1.top:=ImageOut.top;<BR>&nbsp; bevel1.Left:=ImageOut.left;<BR>&nbsp; 
bevel1.width:=WidthOut;<BR>&nbsp; bevel1.Height:=HeightOut;<BR>&nbsp; 
Application.ProcessMessages;<BR>end;</DIV>
<DIV>&nbsp;</DIV>
<DIV>procedure TForm1.btnPlus20Click(Sender: TObject);<BR>begin<BR>&nbsp; 
HeightOut:=(HeightOut * 120) div 100;<BR>&nbsp; WidthOut:=(WidthOut * 120) div 
100;<BR>&nbsp; ZoomUpDown:=ZoomUpDown+1;<BR>&nbsp; if(Zoomupdown=0) 
then<BR>&nbsp; begin<BR>&nbsp;&nbsp;&nbsp; WidthOut:=JPGIn.Width;&nbsp; 
//original sizes - avoid rounding errors<BR>&nbsp;&nbsp;&nbsp; 
HeightOut:=JPGIn.Height;&nbsp; //original sizes - avoid rounding 
errors<BR>&nbsp; end;<BR>&nbsp; ShowSizeOut;<BR>//&nbsp; 
ResizeNow;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //this slows 
down clicking of course...<BR>end;</DIV>
<DIV>&nbsp;</DIV>
<DIV>procedure TForm1.btnResizeClick(Sender: TObject);<BR>begin<BR>&nbsp; 
ResizeNow;<BR>end;</DIV>
<DIV>&nbsp;</DIV>
<DIV>procedure TForm1.ResizeNow;<BR>begin<BR>&nbsp; //have to do from 
BMP<BR>&nbsp; //Get fresh from original JPG each time to prevent 
degrading<BR>&nbsp; JPGOut:=JPGIn;<BR>&nbsp; BMPOut.Width:=WidthOut;<BR>&nbsp; 
BMPOut.Height:=HeightOut;<BR>&nbsp; 
BMPOut.Canvas.Stretchdraw(Rect(0,0,WidthOut,HeightOut),JPGOut);<BR>&nbsp; 
//reshow image now<BR>&nbsp; lblStatus.Caption:='intermediate BMP - 
wait...';<BR>&nbsp; ImageOut.Picture.Assign(BMPOut);<BR>&nbsp; 
ShowSizeOut;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; sleep(1000);<BR>&nbsp; JPGOut.Free;<BR>&nbsp; JPGOut := 
TJPEGImage.Create;<BR>&nbsp; JPGOut.Assign(BMPOut);<BR>&nbsp; 
lblStatus.Caption:='Final 
JPG:'+inttostr(JPGOut.Width)+'x'+inttostr(JPGOut.Height);<BR>&nbsp; 
BMPOut.Assign(JPGOut);<BR>&nbsp; ImageOut.Picture.Assign(BMPOut);<BR>&nbsp; 
ShowSizeOut;<BR>end;</DIV>
<DIV>&nbsp;</DIV>
<DIV>procedure TForm1.btnSaveClick(Sender: TObject);<BR>begin<BR>&nbsp; 
JPGOut.SavetoFile(FileOut);<BR>&nbsp; ShowMessage('File Saved - Click Find again 
to see in list');<BR>end;</DIV>
<DIV>&nbsp;</DIV>
<DIV>procedure TForm1.btnFindClick(Sender: TObject);<BR>begin<BR>&nbsp;&nbsp; 
FindFile1.InSubFolders:=true;<BR>&nbsp;&nbsp; 
Findfile1.Path:=edtPath.text;<BR>&nbsp;&nbsp; 
FindFile1.FileMask:='*.JP*';<BR>&nbsp;&nbsp; 
FileList:=FindFile1.SearchForFiles;<BR>&nbsp;&nbsp; 
ListBox1.items:=FileList;<BR>&nbsp;&nbsp; 
Application.ProcessMessages;<BR>end;</DIV>
<DIV>&nbsp;</DIV>
<DIV>procedure TForm1.ListBox1DblClick(Sender: 
TObject);<BR>var<BR>dotpos:integer;<BR>rszpos:Integer;<BR>begin<BR>&nbsp; 
FileIn:=listbox1.Items[Listbox1.ItemIndex];<BR>&nbsp; 
lblFilename.caption:=FileIn;<BR>&nbsp; dotpos:=ansipos('.',FileIn);<BR>&nbsp; 
rszpos:=ansipos('Rsz.',FileIn);<BR>&nbsp; if RszPos&gt;0 then FileOut:=FileIn; 
//keep same name<BR>&nbsp; if (dotpos&gt;0) and (RszPos&lt;=0) then 
FileOut:=<BR>&nbsp;&nbsp;&nbsp; 
copy(FileIn,1,dotpos-1)+'Rsz'+copy(FileIn,DotPos,5);<BR>&nbsp; // Create Jpeg 
and Bmp work classes<BR>&nbsp; JPGIn := TJPegImage.Create;<BR>&nbsp; 
JPGIn.LoadFromFile(FileIn);<BR>&nbsp; BMPIn := TBitMap.Create;<BR>&nbsp; 
BMPIn.Assign(JPGIn);<BR>&nbsp; ImageIn.Picture.Assign(BMPIn);<BR>&nbsp; 
lblWidthHeight.Caption:=inttostr(JPGin.Width)+'x'+inttostr(JPGIn.Height);<BR>&nbsp; 
JPGOut := TJPegImage.Create;<BR>&nbsp; JPGOut:=JPGIn;<BR>&nbsp; BMPOut := 
TBitMap.Create;<BR>&nbsp; BMPOut.Assign(JPGOut);<BR>&nbsp; 
ImageOut.Picture.Assign(BMPOut);<BR>&nbsp; edtFileOut.text:=FileOut;<BR>&nbsp; 
WidthOut:=JPGOut.Width;<BR>&nbsp; HeightOut:=JPGOut.Height;<BR>&nbsp; 
ShowSizeOut;<BR>&nbsp; ZoomUpDown:=0;<BR>&nbsp; 
label7.Caption:='(frame='+inttostr(ImageIn.Width)+'x'+inttostr(ImageIn.Height)+')';<BR>&nbsp; 
label8.Caption:='(frame='+inttostr(ImageOut.Width)+'x'+inttostr(ImageOut.Height)+')';<BR>end;</DIV>
<DIV>&nbsp;</DIV>
<DIV>//http://www.delphi3000.com/articles/article_4399.asp?SK=</DIV>
<DIV>&nbsp;</DIV>
<DIV>// ====================================================<BR>// Set the 
compression quality of a JPEG image<BR>// This will alter the quality vs size 
ratio<BR>// ====================================================</DIV>
<DIV>&nbsp;</DIV>
<DIV>//(Note this code is not used for resize)</DIV>
<DIV><BR>procedure TForm1.SetJPGCompression(ACompression : integer; const 
AInFile : 
string;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
const AOutFile : string);<BR>var iCompression : integer;<BR>&nbsp;&nbsp;&nbsp; 
oJPG : TJPegImage;<BR>&nbsp;&nbsp;&nbsp; oBMP : TBitMap;<BR>begin<BR>&nbsp; // 
Force Compression to range 1..100<BR>&nbsp; iCompression := 
abs(ACompression);<BR>&nbsp; if iCompression = 0 then iCompression := 
1;<BR>&nbsp; if iCompression &gt; 100 then iCompression := 100;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; // Create Jpeg and Bmp work classes<BR>&nbsp; oJPG := 
TJPegImage.Create;<BR>&nbsp; oJPG.LoadFromFile(AInFile);<BR>&nbsp; oBMP := 
TBitMap.Create;<BR>&nbsp; oBMP.Assign(oJPG);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; // Do the Compression and Save New File<BR>&nbsp; 
oJPG.CompressionQuality := iCompression;<BR>&nbsp; oJPG.Compress;<BR>&nbsp; 
oJPG.SaveToFile(AOutFile);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; // Clean Up<BR>&nbsp; oJPG.Free;<BR>&nbsp; oBMP.Free;<BR>end;</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>end.<BR></FONT></DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 size=2 face=Arial></FONT>&nbsp;</DIV>
<DIV><BR>1) open and dipslay Gif, jpg, and png image formats.<BR>2) Resize the 
above file format<BR>3) Save file back in resized format.<BR><BR>Does anyone 
have or recommend any code for doing such?<BR><BR>I have seen GraphixEx but it 
states it does not support saving of 
images.<BR><BR>Cheers<BR>Rob<BR><BR>_______________________________________________<BR>NZ 
Borland Developers Group - Delphi mailing list<BR></DIV></BODY></HTML>