01-15-2013 09:49 AM
I'm attempting to display a static image in my blackberry application. I've tried multiple ways,
EncodedImage.createEncodedImage, Bitmap.createBitmapFromPNG, Bitmap.createBitmapFromBytes
All of them fail with IllegalArgumentException. The data is read in from the SD card and i can navigate to the image and it displays fine in the Blackberry image viewer.
FileConnection fc = (FileConnection) Connector.open(filename)
if(fc.exists())
{
InputStream in_stream = fc.openInputStream();
byte[] data = IOUtilities.streamToBytes(in_stream);
in_stream.close();
fc.close()
Bitmap bmpImg = Bitmap.CreateBitmapFrom Bytes(data,0,data.length,1);
}Is effectively my code, tried with all those different methods. All bailing with IllegalArgumentException at the data processing part.
01-15-2013 10:33 AM
If the image is static, you could always include in the assets and then get it using Bitmap.getBitmapResource(....);
Can you confirm the length of the data array that you read and whether or not the bytes contain what you expect given the file on the SD Card (perhaps use some hex editor on the file).
If neither of these are going to work, then I suspect you might need to put the file that is causing your problems somewhere so that we can get it and try it.
01-15-2013 01:02 PM
Verified that the data is correct. Still no dice. I haven't seen any code examples but is it possible to play it through the media player like i could an audio file? e.g.
Player p = Manager.createPlayer(file_path); p.realize(); p.prefetch(); p.start();
I threw together a test and it failed, but the validity of that test could be questionable. Lol.
01-15-2013 03:00 PM
OK, any chance of putting the file anywhere we can look at ourselves?
01-18-2013 03:24 PM
So I solved this all by just opening it up in the browser/media player. I guess its PNG handling is a bit better. This has lead to a new question though. I have it going through a variety of types of files including audio. Is there a way of getting PlayerListener like callbacks from the native media player? Both when I open the files using BrowserSession or using something such as Registry.invoke() the default player is opened, however i can't get callbacks from it.
Thoughts?