How to convert bytearray to image or image to bytearray ?

后端 未结 7 1344
感情败类
感情败类 2020-12-06 18:57

How to assign bytearray value to panel background image. If anybody have idea or experiance plz help me to overcome the problem. BRIEF EXP:

I have panel control an

7条回答
  •  离开以前
    2020-12-06 19:54

    uhm, well i presume, since it is an image, you have it in a BitmapData, let's say "myBmp" ... then use the following to extract all the data from BitmapData:

    var bytes:ByteArray = myBmp.getPixels(myBmp.rect);
    

    and the following to write:

    myBmp.setPixels(myBmp.rect, bytes);
    

    note that only the raw 32 bit pixel data is stored in the ByteArray, without compression, nor the dimensions of the original image.

    for compression, you should refer to the corelib, as ozke said ...

提交回复
热议问题