Skip navigation
Currently Being Moderated

HttpService.lastResult returns [B@b041b0

Jan 11, 2012 11:57 AM

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.



 

 
Replies
  • Currently Being Moderated
    Jan 17, 2012 5:55 PM   in reply to Anshul108

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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points