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
精彩评论