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
Contributor
ahmednaserfinal
Posts: 43
Registered: ‎07-22-2012
My Device: curve
My Carrier: syudent

Problem when get bitmap from byte[ ] get from webservice

I get String stream of bitmap from webservice  i use this code to parse it to be byte [ ]

logoImg = Base64.decode(catLogo.getString(i));

 then i use this code to convert to bitmap but in this code i get exception "IllegalArgumentException"

public Bitmap getImage(byte[] image) {
		EncodedImage bit = EncodedImage.createEncodedImage(image, 0,
				image.length);
		return bit.getBitmap();
	}

 please anybody help me where the problem

Please use plain text.
Developer
simon_hain
Posts: 15,841
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problem when get bitmap from byte[ ] get from webservice

i would suggest that you use the debugger to solve this issue.
copy (or log) the string you get and check if it is a valid picture on your PC.
maybe the string is in utf-8 and you did not add the encoding?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
ahmednaserfinal
Posts: 43
Registered: ‎07-22-2012
My Device: curve
My Carrier: syudent

Re: Problem when get bitmap from byte[ ] get from webservice

hi simon_hain,
how make encoding of the string if is in utf-8
Please use plain text.
Developer
simon_hain
Posts: 15,841
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problem when get bitmap from byte[ ] get from webservice

http://www.blackberry.com/developers/docs/7.1.0api/java/lang/String.html#String(byte[],%20java.lang....
"UTF-8" would be the encoding string.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.