Langages :: Delphi :: JPEG & GIF resize |
|||
| Par : TheFalklands |
Date : 08/12/2002 00:00:00 |
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 | Type : Commentaire |
|
| yes for JP(e)G, no for GIF |
|||
| Par : TheFalklands | Date : 08/12/2002 19:01:00 | Type : Commentaire |
|
| ok, what's the code ? please for JPeG ? |
|||
| Par : VGR | Date : 08/12/2002 19:20:00 | 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: | |||
| |
|
|
|
| |
|
|
|








