visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Delphi :: JPEG & GIF resize


By: TheFalklands U.S.A.  Date: 08/12/2002 00:00:00  English  Points: 50 Status: Answered
Quality : Excellent
Hello everybody,

I would like to know if anyone knows a litle code to resize a Jpeg or a gif pictures.
In fact I would like to do a ActiveX library who can resize image client before upload to my web server.

Best regards
By: VGR Date: 08/12/2002 04:10:00 English  Type : Comment
yes for JP(e)G, no for GIF
By: TheFalklands Date: 08/12/2002 19:01:00 English  Type : Comment
ok, what's the code ? please for JPeG ?
By: VGR Date: 08/12/2002 19:20:00 English  Type : Answer
for GIFs, PNGs, BMPs and such, I open them, and use the canvas's bitmap to produce a reduced (thumbnail )JPEG

For JPEGs it's something like this :

Procedure Vignette; // (Image1: TBitmap; filename:String);
Var PageHeight, // = 200;
PageWidth : Word; // = 320;
var
AspectRatio: Single;
OutputWidth, OutputHeight: Single;
ici : TBitMap;
begin
PageHeight:=350;
PageWidth:=560;
try
OutputWidth := Image1.Width;
OutputHeight := Image1.Height;
AspectRatio := OutputWidth / OutputHeight;
if (OutputWidth < PageWidth) and
(OutputHeight < PageHeight) then
begin
if OutputWidth < OutputHeight then
begin
//VGR23082002 RàF !!! OutputHeight := PageHeight;
//VGR23082002 RàF !!! OutputWidth := OutputHeight * AspectRatio;
end
else
begin
//VGR23082002 RàF !!! OutputWidth := PageWidth;
//VGR23082002 RàF !!! OutputHeight := OutputWidth / AspectRatio;
end
end;
if OutputWidth > PageWidth then
begin
OutputWidth := PageWidth;
OutputHeight := OutputWidth / AspectRatio;
end;
if OutputHeight > PageHeight then

begin
OutputHeight := PageHeight;
OutputWidth := OutputHeight * AspectRatio;
end;
ici:=TBitmap.Create;
ici.Width:=trunc(outputwidth);
ici.Height:=trunc(outputheight);
ici.PixelFormat:=pf24bit;
ici.Canvas.StretchDraw(ici.Canvas.ClipRect,Image1);
ici.SaveToFile(filename);
finally
ici.Free;
end;
end;


basically, it's meaning "use StrecthDraw on the clipped Rect of the Canvas, to image Image1")

Do register to be able to answer

EContact
browser fav
page generated in 94.064000 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page