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

Rosemount 3051 Smart Pressure Transmitter and Transducer - FF28
$719.98
Rosemount 3051 Smart Pressure Transmitter and Transducer - FF28 pictureBQLZR G1/4 Pressure Transmitter Transducer Output 4-20mA Range 0-10Bar
$28.53
BQLZR G1/4 Pressure Transmitter Transducer Output 4-20mA Range 0-10Bar pictureMKS Instruments BARATRON PRESSURE TRANSDUCER 750B12TCB2GA RANGE: 100Torr
$150.0
MKS Instruments BARATRON PRESSURE TRANSDUCER 750B12TCB2GA RANGE: 100Torr pictureASHCROFT G17M0242DO300# Pressure Transducer, Range 0 to 300 psi,
$175.05
ASHCROFT G17M0242DO300# Pressure Transducer, Range 0 to 300 psi, picture1PC 50W 40KHz Ultrasonic cleaning transducer Cleaner Brand New
$18.5
1PC 50W 40KHz Ultrasonic cleaning transducer Cleaner  Brand New picture






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