BlackBerry - Convert EncodedImage to byte []
- by user324884
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[] 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
);