views:

107

answers:

1

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
            );
A: 

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

Max Gontar
This is right. thanks for solution.
You're welcome!
Max Gontar