| Reply | « Previous Thread | Next Thread » |
|
i know how can i Resize a picture with MIDP2 ,
is it Possible to do this with MIDP1 ? thanks.. |
|
It's possible but not easy. The problem is that MIDP 1.0 doesn't give you any methods to get the pixel data of the picture. So in order to use the method I gave you in the other thread you would have to write your own png decoding/encoding method.
You can find some code to get you started on that here. shmoove |
|
I can get the Hexa Nr of a Picture by some Editor and put it in a byte Array
and static byte dukeData[] = { (byte)0x89,(byte)0x50,(byte)0x4E,(byte)0x47,(byte)0x0D ,...........} img = Image.createImage(dukeData, 0, dukeData.length); if i have the byteArray, can i use the Hexa Nr for Resizing with MIDP2 code ,which you gave me ? |
|
No because that data is not raw pixel data (which is what you need for the resizing algorithm), it's encoded (usually PNG encoded) data.
That's why I said you have to write methods to decode (to get the raw pixel data from the encoded data) and encode (so you can convert the resized pixel data into a byte array that you can use with createImage) images. You can get the specification for PNG and other formats from Wotsit. shmoove |
|
It's not necessary to write your own decoding algorythm. You can let the JVM + Nokia UI do it for you by drawing the PNG on an off-screen graphics context and the use GetPixels to get the pixeldata. Here's the code I use in my program(designed for MIDP1.0 12bit color):
Image temp = Image.createImage("/crosshair.gif"); Image workSpaceImg = Image.createImage(16,16); DirectGraphics workSpace = DirectUtils.getDirectGraphics(workSpaceImg.getGraphics()); workSpace.drawImage(temp, 0, 0, Graphics.LEFT | Graphics.TOP, 0); workSpace.getPixels(image, 0, 16, 0, 0, 16, 16, DirectGraphics.TYPE_USHORT_4444_ARGB); What it does: it creates a blank 16x16 image plus an image from the GIF file, gets the graphics context of the blank image, draws the GIF image on that context, and gets the pixels(image is a short[] array) Encoding is not possible this way i guess, so for that you have to write some code.
Last edited by Cheiz : 2006-09-19 at 00:33.
|
|
Probably a bit too late..
But an obvious solution is to scale a source image vertically first by blitting only the required lines to a temporary image. Then doing the same horizontally. I use this approach to have a generic MIDP1 scaling method in a small slideshow engine. cheers, tfdj |
|
Creating a Thumbnail Image
source: http://developers.sun.com/techtopics...icles/picture/ One seemingly simple thing I wanted to do in this article was talk about how to create a thumbnail image, a smaller version of the image captured from the camera. MIDP 2.0 includes methods for obtaining the raw pixel values of an Image, which would make a true scaling transformation possible. Unfortunately MIDP 1.0 does not provide access to the pixel data. The solution I implemented is neither elegant nor strictly correct (in an image-processing sense), but it approximates the behavior I wanted and doesn't involve parsing the PNG format. I create a new (blank) image for the thumbnail. For each pixel of that image, I set the clipping region to encompass that single pixel, and draw the source image at an appropriately scaled location. 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 < thumbHeight; y++) { for (int x = 0; x < thumbWidth; 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.LEFT | Graphics.TOP); } } Image immutableThumb = Image.createImage(thumb); return immutableThumb; } |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| resize picture | bennet_chen | Mobile Java Media (Graphics & Sounds) | 12 | 2006-11-21 00:13 |
| Sending Nokia Picture Messages with one SMS? | paulmckillop | Smart Messaging | 8 | 2006-11-10 06:52 |
| picture messages | AliNaqvi | Smart Messaging | 2 | 2006-05-10 13:43 |
| Unable to open Picture message on certain Nokia's | ingo.pak | Smart Messaging | 3 | 2004-02-09 10:51 |
| Picture Message to 3310 ERROR | belgiozen | Smart Messaging | 1 | 2002-07-17 11:57 |