View Single Post
Old 07-23-2009, 11:52 PM   #3 (permalink)
capndurk
New Member
 
Join Date: Jun 2009
Model: 7100T
PIN: N/A
Carrier: hi
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the response. The scale thing is actually a typo from copying my code to the forum post, I did use scale 1. And for the length, the documentation said it can be -1 (it will read to the end of the byte array). In any case, I've tried data.length anyway.

As a small update, I have successfully been able to display the same image with the following:
Code:
InputStream is = (this.getClass()).getResourceAsStream("/pic.png");
byte[] data = new byte[5000];
is.read(data, 0, 5000);   // read image
Bitmap b = Bitmap.createBitmapFromBytes(data, 0, data.length, 1);
add(new BitmapField(b));
The code gets an IllegalArgumentException when I use the following code:
Code:
byte[] data = new byte[5000];
is.read(data, 0, 5000);
Bitmap b = Bitmap.createBitmapFromBytes(data, 0, data.length, 1);
add(new BitmapField(b));
I've tried pretty much everything.. I can't figure this out. Oh and by the way, I'm getting the data on the server using a FileInputStream (Java 6 or something).
Offline   Reply With Quote