I have a jpg image in a byte array. (My application will get it from network into a byte array)
I want to display it.
Image.createImage(buf, 0, buf.length)
throws exception which means it doesn't support jpg...
how to display it...
Thanks in advance
I have a jpg image in a byte array. (My application will get it from network into a byte array)
I want to display it.
Image.createImage(buf, 0, buf.length)
throws exception which means it doesn't support jpg...
how to display it...
Thanks in advance
What is the device?
If the device doesn't support jpegs, then the only way is to write your own decoder... no small task.
Its Nokia E61i and I think it supports jpg images...
anyways... do u know any good jpg decoder for J2ME
Try loading a jpeg from the application's JAR:
See if that works. Possibly the data you have in the byte array is not as valid as you think.Code:Image jpeg = Image.createImage("my.jpg");
Although I haven't tried, but I have seen discussions on some forum that this thing works:
but if you createImage with byte array then it doesn't work...Code:Image jpeg = Image.createImage("my.jpg");
Also,
That's not the case...same code is working fine if I send png image from the server...
it would be great if you suggest a good jpg decoder for J2ME...
I have tried this JPEGDecoder:
http://webuser.hs-furtwangen.de/~dersch/
My images are now displayed well with the help of this decoder.
But it is consuming 524 KB of heap memory...
I want a memory decoder which should consume less than 50 KB of heap memory...
Please suggest me a good jpeg decoder...
Thanks in advance
I think you're lucky to find a decoder at all...
How big is the image (file size and pixel size)?
How do you know it's using 524k?
That means nobody will suggest me a decoder
File size: 1 KB to 4 KB
Image size: 18 x 25 pixels to 100 x 100 pixels
Case 1:
Case 2:Code:JPEGDecoder JPEGDecoderObject = new JPEGDecoder(); System.gc(); System.out.println("Free memory is " + String.valueOf(RuntimeObject.freeMemory() / 1024) + "KB");
Memory consumed by JPEGDecoderObject = Case 2 - Case 1Code://JPEGDecoder JPEGDecoderObject = new JPEGDecoder(); System.gc(); System.out.println("Free memory is " + String.valueOf(RuntimeObject.freeMemory() / 1024) + "KB");
Hmmm... you're right!
Good grief. The problem is that the Huffman tables are all fixed sizes. This line:
creates an array of 400k. And this:Code:private int HuffTab[][][] = new int[4][2][MAX_HUFFMAN_SUBTREE * 256];
is another 100k. The other arrays amount to about 30k.Code:int V[][][][] = new int[4][2][16][200];
I don't think this can work in 50k, but if these arrays are dynamically sized, you should be able to cut this down a lot.
Basically I want to transfer images from my server and display it on phone
I want least data transfer to occur
Do you know any good image compression algorithm/format which results into 100 x 100 pixels image to be converted into less than 5KB and which consumes heap memory less than 50KB...
You can use PNG.. how small you will get depends on what is in the image. If you reduce the number of colours, and use PNGOUT you will get the size down.
You should be able to modify that code to use less memory, and decode a JPEG.
My images consists of lots & lots of colors. So, size of 100 x 100 pixels PNG image is in the range 18KB to 22KB which is very very high... I want less than 5KB...
Really?
I didn't read jpeg compression-decompression algorithm...
How can I manage without HuffTab... I don't want heap consumption to go beyond 50KB at any point of time during decoding...
I can think of only one way... don't pre-calculate the HuffTab. Instead, calculate the value as and when it is required... but this will deteriorate the performance I think...
Last edited by arpit2agrawal; 2009-01-04 at 23:50.
Some years ago I had read wavelet compression algorithm which has negligible memory footprint.
Today, using Corel Draw I converted my image to .wi (Wavelet Compressed Bitmap) file which gives me reduction in size up to 4KB and quality at par with jpeg images.
I hope decoding .wi file will also consume negligible heap memory.
So, I think one can use .wi image file format to send images from server and display on phone
I want .wi image decoder for J2ME
If anyone knows then please post here...
Last edited by arpit2agrawal; 2009-01-07 at 01:15.
u must be doing something wrong....
a 100x100 pixels PNG image cant be 18K to 22K...
try to convert the jpeg images to PNG 8 bit on server side and send those to ur mobile...
U are mentioning many colors and so, so some quality degradation will occure when converting them to PNG 8 bit, but nothing to worry about, cause u alsways have to keep in mind its a 100x100 pixel picture which will be shown on a mini-screen (mobile) so nobody will notice the difference... most probably u are creating 32 or 24 bit PNG's now, try to cut that down to 8 bit...
I tried with 8 bit PNG. But the quality is degraded so much that it cannot be tolerated.
Please note that some of the images contain even photos of human being
So, 24 bit PNG will only do. But it has very very less compression ratio in the range 1.15:1 to 1.3:1
I want compression ratio at least 3:1 or even more than that
I tried Wavelet Compressed Bitmap and it gives me compression ratio more than 3:1 and that too without degrading quality much
I just want a decoder of .wi files (Wavelet Compressed Bitmap) for J2ME