Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: EncodedImage.createEncodedImage() = null

Hi simon thanks for your help!!!,

 

but again i need your suggestion... the data is in a XML file via a webservice. am parsing this xml file

using saxparser.

 

the following is the code am using to get the bytes.

 

 

public void characters(char[] ch, int start, int length) 
{
if(qName.equalsIgnoreCase("BarCodeImage"))
{
  String temp = new String(ch, start, length);				
  BarCodeImage = temp.getBytes();
}
}

 

can you suggest me how to modify this from here...??

 

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: EncodedImage.createEncodedImage() = null

ThankU i converted teh char[] to the stream as follows.. and i changed my code as

String temp = new String(ch, start, length);				// modified by Praveen G
			byte[] barcode;
			try 
			{
				barcode = temp.getBytes("UTF-8");
				InputStream stream = new ByteArrayInputStream(barcode);
				BarCodeImage = IOUtilities.streamToBytes(stream);
				 
			} 
			catch (UnsupportedEncodingException e) 
			{
				Tools.printMessage("XCO: ParseIntroPage: Error while parsing the barcode image, unsupportedEncodingException" + e.toString());
			}
			catch (IOException e) 
			{
				Tools.printMessage("XCO: ParseIntroPage: Error while parsing the barcode image, IOException" + e.toString());
			}

 

i will let you know the result.

 

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: EncodedImage.createEncodedImage() = null

 

Again the same error!!!!

 

the following is the error message.

Img bytes values is...[B@67b801a7
Imgbytes != null, if block26148
Error EncodedImage..... java.lang.IllegalArgumentException

 

i observed that the image bytes is of size 25KB, but while parsing am getting only 9.5KB of bytes. i think this is the reason for the exception.

 

 

but why the whole data is not coming into the bytearray???

 

the following is the errror... and am posting the code.

if(qName.equalsIgnoreCase("BarCodeImage"))
		{
			String temp = new String(ch);				// modified by Praveen G
			byte[] barcode;
			try 
			{
				barcode = temp.getBytes("UTF-8");
				InputStream stream = new ByteArrayInputStream(barcode);
				BarCodeImage = IOUtilities.streamToBytes(stream);   
			} 
			catch (UnsupportedEncodingException e) 
			{
				Tools.printMessage("XCO: ParseIntroPage: Error while parsing the barcode image, unsupportedEncodingException" + e.toString());
			}
			catch (IOException e) 
			{
				Tools.printMessage("XCO: ParseIntroPage: Error while parsing the barcode image, IOException" + e.toString());
			}
		
		}

 

 

Thanks and Regards,
PraveenGoparaju.
Please use plain text.