Skip navigation
Currently Being Moderated

Displaying an image with RGB data

Apr 11, 2013 6:16 AM

I am by far no pro with Flex 4.6.  Unfortunatly for me my image sourfce file only comes in .bmp format. Since Flex does not accept that format i need a work arround.

I am using loader.load to get its source image from an embedded device so please dont tell me to convert it beforehand or why in the world am i using .bmp as i have seen in so many threads. I can however send up the RGB values of the .bmp image for every pixel to flex if that help in some way. 

OR another way to put it, say i have an array of a 10x10 pixel image in RGB format. Can i display this somehow as an image ?

 

Thank you

 
Replies
  • Currently Being Moderated
    Apr 11, 2013 8:19 AM   in reply to PastaPrimavera

    Create a BitmapData and set that as the bitmapData of a Bitmap.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2013 9:47 AM   in reply to PastaPrimavera

    I’m not quite sure I understand this last question as it loads a .gif and I thought the issue is that you want to load a .bmp file.

     

    If that’s true, you have some choices:  You can load the entire bmp file as a Base64 encoded entity, and decode it in the app, parse the pixels out of the BMP file format, or you can pull the RGB values out of the  BMP file on the server and send a text blob of RGB encoded data.

     

    Let’s say you choose the latter, and the data is for a 2x2 icon and you send it in the order of (0,0), (1, 0), (0, 1), (1,1) and the text looks like: “0xFF0000,0x00FF00,0x0000FF,0xFF00FF”

     

    In the app, you would load that with URLLoader and not Loader and do something like:

     

    Var pixels:Array = urlLoader.data.split(“,”);

    Var pixelba:ByteArray = new ByteArray();

    For each (var p:String in pixels)

    {

        var px:int = int(p);

        pixelba.writeInt(px);

    }

    Pixelba.posiiton = 0;

    Var bm:Bitmap = new Bitmap();

    Var bmd:BitmapData = new BitmapData(2, 2);

    Bmd.setPixels(ba);

    Bm.bitmapdata = bmd;

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2013 11:15 PM   in reply to PastaPrimavera

    Ah yes, forgot an argument.  Should be something like:

     

        bmd.setPixels(new Rectangle(0,0,2,2), ba);

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 14, 2013 10:43 PM   in reply to PastaPrimavera

    Ah, sorry, should have been pixelba

     
    |
    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