visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
304 experts, 1182 utilisateurs inscrits, 1626 questions déjà répondues
European Experts Exchange, le meilleur site pour des solutions de qualité

New Improved Search!

 


Le lien vers le DDRK est de nouveau fonctionnel.
Nous avons subi une coupure d'une semaine, désolé.
(23-30/01/2010)

Langages :: Delphi :: JPEG & GIF resize


Par : TheFalklands E.U.A.  Date : 08/12/2002 00:00:00  Anglais  Points: 50 État : Répondue
Qualité : Excellente
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
Par : VGR Date : 08/12/2002 04:10:00 Anglais  Type : Commentaire
yes for JP(e)G, no for GIF
Par : TheFalklands Date : 08/12/2002 19:01:00 Anglais  Type : Commentaire
ok, what's the code ? please for JPeG ?
Par : VGR Date : 08/12/2002 19:20:00 Anglais  Type : Réponse
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")

Inscrivez-vous pour répondre

 Add This Article To:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page générée en 42.206050 millisecondes

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page