anorganix
asked on
Resize JPG Image
Hi all!
I need to resize a serie of large JPG images (4000x2000) and I need a *fast* algo that will do the job...
Currently I am using a procedure based on "StrechDraw", but it's not fast enough:
//////////////////////// code /////////////////////////
procedure ResizeJPG(InFile, OutFile: string; Percent, Quality: integer);
var
oJPG: TJPEGImage;
oBmp: TBitmap;
begin
try
oJPG:=TJPEGImage.Create;
oJPG.LoadFromFile(InFile);
except
MessageBox(0,PChar('Cannot open '+ExtractFileName(InFile)+ '!'),
'Error',MB_OK+MB_ICONERROR );
Exit;
end;
oBmp:=TBitmap.Create;
oBmp.Width:=Round(oJPG.Wid th*Percent /100);
oBmp.Height:=Round(oJPG.He ight*Perce nt/100);
oBmp.Canvas.StretchDraw(Re ct(0,0,oBm p.Width-1, oBmp.Heigh t-1),oJPG) ;
oJPG.Assign(oBmp);
oJPG.CompressionQuality:=Q uality;
oJPG.Compress;
oJPG.SaveToFile(OutFile);
oBmp.Free;
oJPG.Free;
end;
///////////////////////// end code /////////////////////////
I will raise the points if I get a good solution!
Thanks in advance!
:: Cosmin
I need to resize a serie of large JPG images (4000x2000) and I need a *fast* algo that will do the job...
Currently I am using a procedure based on "StrechDraw", but it's not fast enough:
//////////////////////// code /////////////////////////
procedure ResizeJPG(InFile, OutFile: string; Percent, Quality: integer);
var
oJPG: TJPEGImage;
oBmp: TBitmap;
begin
try
oJPG:=TJPEGImage.Create;
oJPG.LoadFromFile(InFile);
except
MessageBox(0,PChar('Cannot
'Error',MB_OK+MB_ICONERROR
Exit;
end;
oBmp:=TBitmap.Create;
oBmp.Width:=Round(oJPG.Wid
oBmp.Height:=Round(oJPG.He
oBmp.Canvas.StretchDraw(Re
oJPG.Assign(oBmp);
oJPG.CompressionQuality:=Q
oJPG.Compress;
oJPG.SaveToFile(OutFile);
oBmp.Free;
oJPG.Free;
end;
///////////////////////// end code /////////////////////////
I will raise the points if I get a good solution!
Thanks in advance!
:: Cosmin
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Any other concise examples?
Thanks,
Cosmin.