BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-10-2010, 01:52 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Oct 2008
Model: 8800
PIN: N/A
Carrier: AT
Posts: 81
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
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 (permalink)
New Member
 
RockoAndy's Avatar
 
Join Date: Sep 2010
Model: 8900
PIN: N/A
Carrier: Airtel
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi ru using png images or any other format
__________________
the amazing world of
Offline  
Old 09-18-2010, 03:32 PM   #4 (permalink)
New Member
 
Join Date: May 2010
Model: bold
PIN: N/A
Carrier: movistar
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
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


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

22nF 100V PET KEMET HQ Film Capacitor 3500pcs
$122.0
22nF 100V PET KEMET HQ Film Capacitor 3500pcs picture3,3uF 100V MMK Evox Rifa HQ Polyester Capacitor Audio / DAC / 10pcs
$3.72
3,3uF 100V MMK Evox Rifa HQ Polyester Capacitor Audio / DAC /  10pcs picture2,2nF 2200pF 1500V KP Arcotronics HQ Capacitor 10pcs
$3.29
2,2nF 2200pF 1500V KP Arcotronics HQ Capacitor 10pcs picture150nF 63V PET KEMET HQ Film Capacitor 3500pcs
$115.0
150nF 63V PET KEMET HQ Film Capacitor 3500pcs picture33nF 63V MMK BF6 RIFA HQ Polyester Film Capacitor 2500pcs
$99.0
33nF 63V MMK BF6 RIFA HQ Polyester Film Capacitor 2500pcs picture






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