Hi,
I am trying to send byte[] array that contains image from java to Flex.
Java Code :
---------------
PrintWriter out= res.getWriter(); out.print(bytes);
I receive this in Flex as [B@b041b0.
Flex Code :
------------------
var obj:Object = HttpService.lastResult;
Alert.show("obj : "+ obj.toString());
resultFormat in HttpService is specified as "array"
How can I display this Object as image in Flex?
Any Help will be appreciated.
immm
in java you have to use
DataoutputStream instead of printwriter, you can send data as binary
then you can
var data:ByteArray = object as ByteArray;
data.uncompress();
var width:int = data.readUnsignedInt(); // first 4 bytes (unsigned integer);
// after data.uncompress()
var height:int = ((data.length - 4) / 4) / width;
// (data.length - 4) ** byte array less the first four bytes gives the representation of the bitmap **
// ((data.length - 4) / 4) ** length of the representation is divided by four because each pixel takes four bytes **
// ((data.length - 4) / 4) / width ** remember, it is a rectangle, so we can get the height this way **
var bmd:BitmapData = new BitmapData(width, height, true, 0); // 32 bit transparent bitmap
bmd.setPixels(bmd.rect, data); // position of data is now at 5th byte
var bm:Bitmap = new Bitmap(bmd);
addChild(bm);
North America
Europe, Middle East and Africa
Asia Pacific