位图转换到黑莓的base64字符串 [英] Convert bitmap to base64 string in blackberry

查看:118
本文介绍了位图转换到黑莓的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 。请参阅<一个href=\"http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/io/Base64OutputStream.html\">API对样品code 如何连接code。

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

这篇关于位图转换到黑莓的base64字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆