Languages :: Delphi :: JPEG & GIF resize |
|||
| By: TheFalklands |
Date: 08/12/2002 00:00:00 |
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 | Type : Comment |
|
| yes for JP(e)G, no for GIF |
|||
| By: TheFalklands | Date: 08/12/2002 19:01:00 | Type : Comment |
|
| ok, what's the code ? please for JPeG ? |
|||
| By: VGR | Date: 08/12/2002 19:20:00 | 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 |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








