BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 09-10-2010, 01:52 PM   #1
taqi.mir
Thumbs Must Hurt
 
Join Date: Oct 2008
Model: 8800
PIN: N/A
Carrier: AT
Posts: 81
Default EncodedImage doesn't encode

Please Login to Remove!

Hi

The below code doesn't work for adding image to the MainScreen,

InputStream input = fconn.openInputStream();

int available = input.available();
byte[] data = new byte[available];
System.out.println("reading");
input.read(data, 0, available);

EncodedImage image = EncodedImage.createEncodedImage(data,0,data.length ); // This line of code doesn't work

Bitmap b = image.getBitmap();
BitmapField picture = new BitmapField(b);
main.add(picture);
main.add(new LabelField("Data Length:" + data.length));



Could anyone tell me what's wrong i am doing ?
Offline  
Old 09-10-2010, 03:54 PM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

What does "doesn't work" mean? Are you getting an exception?

You should be checking to make sure that the file was found. Also, I'm not sure you can use available() the way you are - you might want to trace that out and see what you are getting. Sometimes this only tells you how many bytes are in the current buffer, not the entire size of the file.

The file could also be in some unsupported format.
Offline  
Old 09-14-2010, 08:04 AM   #3
RockoAndy
New Member
 
RockoAndy's Avatar
 
Join Date: Sep 2010
Model: 8900
PIN: N/A
Carrier: Airtel
Posts: 11
Default

Hi ru using png images or any other format
__________________
the amazing world of
Offline  
Old 09-18-2010, 03:32 PM   #4
YamilBracho
New Member
 
Join Date: May 2010
Model: bold
PIN: N/A
Carrier: movistar
Posts: 1
Default EncodedImage doesn't encode

I think you are getting corruot data so instead using available use filezise method of FileConnection. For example:

Code:
InputStream input = fconn.openInputStream();
byte[] data = new byte[fconn.filesize()];
System.out.println("reading");
input.read(data);
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


USA Windows VPS Server / RDP Server / VPS Hosting 12GB RAM + 400GB HDD picture

USA Windows VPS Server / RDP Server / VPS Hosting 12GB RAM + 400GB HDD

$27.99



USA Windows VPS RDP Server/ Windows VPS Hosting - 4GB RAM + 150GB HDD picture

USA Windows VPS RDP Server/ Windows VPS Hosting - 4GB RAM + 150GB HDD

$11.99



USA Windows VPS RDP Server/ Windows VPS Hosting - 4GB RAM + 150GB HDD -  1 Year picture

USA Windows VPS RDP Server/ Windows VPS Hosting - 4GB RAM + 150GB HDD - 1 Year

$129.88



Vollrath 72050 Cayenne 28 3/4

Vollrath 72050 Cayenne 28 3/4" x 13 3/4" Heat 'n Serve 4/3 Size Countertop Food

$285.00



Hubbell NXBTC NX Bluetooth Radio Module with Time Server -  picture

Hubbell NXBTC NX Bluetooth Radio Module with Time Server -

$129.99



NEW MOXA NPORT 5150 serial server DHL Fast delivery picture

NEW MOXA NPORT 5150 serial server DHL Fast delivery

$196.00







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.