I have a utility that loads jpegs according to a list that is presented to the user.
My problem is, that some of the jpegs are enormous. By using the stretch function of a tImage, I can fit the jpeg onto a form. How can I save a copy of the image at that reduced size?
TImage is like a magnifying glass. When you use it, things look bigger, but the actual size of the thing you're looking at doesn't change. TImage does not modify its image; it re-stretches it every time Windows asks the control to paint itself.
Modifying an image has absolutely nothing to do with how it gets displayed. There are command-line programs that process images, so that should be a clue that you don't require visual controls like TImage to perform your task.
TJPEGImage doesn't have all same methods as other TGraphic descendants. In particular, it doesn't expose a TCanvas, so you can't modify JPEGs directly. Instead, you need to copy the JPEG into a bitmap, modify that image, and then copy it back into a JPEG. Since all you want to do is resize the image, the copying and modifying can be done in the same step. For instance:
Bitmap := TBitmap.Create; try SetRect(Rect, 0, 0, NewWidth, NewHeight); Bitmap.Width := NewWidth; Bitmap.Height := NewHeight; Bitmap.Canvas.StretchDraw(Rect, JPEG); JPEG.Assign(Bitmap); finally Bitmap.Free; end;
-- Rob
_______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

