位图转换到黑莓的base64字符串

问题描述:

我有需要被发送到服务器的图像。有没有办法为位图(JPG)为base64字符串转换的黑莓?

I have an image which needs to be sent to the server. Is there a way to convert a bitmap(jpg) to base64 string in blackberry?

你要求什么是有点模糊和奇怪,但是我希望这可以帮助:

What you request is a bit vague and odd, however I hope this can help:

通过下面的一段code有可能得到一个JPEG二进制数据的位图(注意,这是一个COM pressed之一,所以如果比较原始位图)的数据的大小尽可能小:

With the following piece code it's possible to get a JPEG binary data for a Bitmap (note, it is a compressed one, so the size of the data is as small as possible if compare to raw bitmap):

Bitmap bmp = ...; // your bitmap
int quality = 85;
EncodedImage encodedImg = JPEGEncodedImage.encode(bmp, quality);
byte[] data = encodedImg.getData();

然后你可以带code将其与 Base64OutputStream 。请参阅API对样品code 如何连接code。

Then you can encode it with Base64OutputStream. See the API for sample code on how to encode.