Couldn't he get a base64 encoded image or HTTP?
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of dario.drome Sent: Friday, July 06, 2007 12:21 AM To: [email protected] Subject: [flexcomponents] Re: How to create Bitmap/Image from HTTPService output Hi Peter, First, you can not use HTTPService component to retrive binary data because HTTPService only understand text, object, e4x... but not raw binary data. Use URLLoader or URLStream to retrieve your raw images. Second, loader.load() method, as stated in docs, is only able to interpret JPG, GIF, PNG and SWF. In that way, if your raw image data has any of these formats, you will succeed, if not (if your data is in another format or even if it is a secuence of pixels' color values) you will have to compose the bitmapdata at your own (probably using the setPixels method found in BitmapData) After having a good bitmap you can display it with the following piece of code: image.source = new Bitmap( myBitmapData ) Hope this helps. --- In [email protected] <mailto:flexcomponents%40yahoogroups.com> , "pgp.coppens" <[EMAIL PROTECTED]> wrote: > > Hello, > > The reason why is a bit convoluted, but I need to create a Bitmap (and > Image) from the result of an HTTPService invocation. > > I am able to extract the "raw" image data from the event.result > property in the ResultEvent.RESULT listener, but then I am stuck. > > I have two questions with respect to this. > > First is what resultFormat I need to ask from the HTTPService (I now > use HTTPService.RESULT_FORMAT_TEXT) ? > > Second is what after I get hold of the event.result > > I tried a lot of things, like e.g. > > > var loader:Loader=new Loader(); > var byteArray:ByteArray=new ByteArray(); > byteArray.writeUTFBytes(result.event as String); > loader.loadBytes(byteArray); > var bitMap:Bitmap=Bitmap(loader.content); > > But I typically get an error saying the data is not a valid bitmap. > > I guess some cast and/or property is wrong but I have not been able to > sort it out just yet. > > Any help much appreciated > > Peter >
