开发者

BlackBerry - Convert EncodedImage to byte []

开发者 https://www.devze.com 2022-12-27 23:31 出处:网络
I am using below code where i don\'t want to use JPEGEncodedImage.encode because it increases the size. So I need to directly convert from EncodedImage to byte array.

I am using below code where i don't want to use JPEGEncodedImage.encode because it increases the size. So I need to directly convert from EncodedImage to byte array.

FileConnection fc= (FileConnection)Connector.open(name);

is=fc.openInputStream();

byte[开发者_如何学Go] ReimgData = IOUtilities.streamToBytes(is);

EncodedImage encode_image = 
    EncodedImage.createEncodedImage(ReimgData, 0, (int)fc.fileSize());

encode_image = sizeImage(encode_image, (int)maxWidth,(int)maxHeight);

JPEGEncodedImage encoder=JPEGEncodedImage.encode(encode_image.getBitmap(),50);

ReimgData=encoder.getData();

is.read(ReimgData);

HttpMultipartRequest(
                content[0],
                content[1],
                content[2],
                params,
                "image",txtfile.getText(), "image/jpeg", ReimgData
            );


Try EncodedImage.getData():

public final byte[] getData()
Returns the encoded data of this image.
Returns: A byte array containing the encoded data for this image.
Since: JDE 3.7.0

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号