A sniplet from the article "Taking Pictures with MMAPI"
http://developss.sun.com/techtopics/mobility/midp/Articles/Picture/
Clapton_XP@hotmail.com
Create a thumbnail
The pixels in the picture can be operated in the MIDP 2.0, otherwise in MIDP1.0. This example uses Graphics.SetClip () to achieve each pixel.
Private Image Createthumbnail (Image Image) {
Int SourceWidth = image.getwidth ();
Int sourceheight = image.getHeight ();
INT thumbwidth = 64;
INT thumbheight = -1;
IF (thumbheight == -1)
thumbheight = thumbwidth * SourceHeight / SourceWidth;
Image thumb = image.createImage (thumbwidth, thumbheight);
Graphics g = thumb.getgraphics ();
For (int y = 0; y For (int x = 0; x G.setClip (x, y, 1, 1); INT DX = X * SourceWidth / thumbwidth; INT DY = Y * SourceHeight / thumbheight; g.drawimage (image, x - dx, y - dy, Graphics.top | graphics.top); } } Image Immutablethumb = image.createImage (thumb); Return Immutablethumb; }