Reputation: 307
I am having problem of displaying PNG image where as JPG image is Displaying Perfectly well.
Here is the code of getting Image .
Image tImage=Image.createImage("/tasbeeh.jpg");
and then draw Image but for png
Image tImage=Image.createImage("/tasbeeh.png");
throws exception:
java.lang.NullPointerException:
at start.SplashScreen.paint(+56)
at javax.microedition.lcdui.Canvas.callPaint(+85)
at javax.microedition.lcdui.Display.repaint(+82)
and
java.io.IOException
at javax.microedition.lcdui.ImmutableImage.getImageFromStream(+15)
at javax.microedition.lcdui.ImmutableImage.<init>(+20)
at javax.microedition.lcdui.Image.createImage(+8)
Upvotes: 0
Views: 1111
Reputation: 2617
I am assuming the exception your getting is an IllegalArgumentException,
An IllegalArgumentException is thrown if the first argument is incorrectly formatted or otherwise cannot be decoded.
So your most likely receiving the error due to unsupported format of the image, or truncated data.
Update
getImageFromStream Throws: IOException - if there is an error with the stream
So the stream of data coming in from that png is not formatted as expected, like I say unsupported format of the image, or truncated data.
You should try using a graphics program like paint.net or photoshop and saving as a PNG with different bit formats.
I hope this helps.
Upvotes: 1
Reputation: 52185
According to the Image.createImage JavaDoc, for that method to throw an exception it must be because the source string is null. This does not seem to be the case. It might be an issue with your MIDP
or CLDC
version.
You can try and use other implementations of the Image.createImage
such as this one.
Upvotes: 0