I have created a web service that pulls images (gif) from the
database and base64 it for sending across the wire. The flex
application then decodes and renders the image. The Image is not
being scaled correctly. If I embed the image into the application
everything works correctly. But if the image is decoded then sizing
goes out the window.
The image overflows the Image box and takes up the full size
of the image. Zoom, rotation, etc. do nothing to the image.
Any help is appreciated...
Example Code:
%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''
http://www.adobe.com/2006/mxml''
layout=''absolute'' creationComplete=''onLoad(event);''%26gt;
%26lt;mx:Script%26gt;
%26lt;![CDATA[
import mx.utils.Base64Decoder;
public function onLoad(event:Event):void {
// Decode image - Base64 gif image (500 x 776)
var base64:String = ''R0lGOD...''; // Get base64 from web
service call
var decoder:Base64Decoder = new Base64Decoder();
decoder.decode(base64);
// Load image into container
var loader:Loader = new Loader();
loader.loadBytes(decoder.flush());
image2.addChild(loader);
}
]]%26gt;
%26lt;/mx:Script%26gt;
%26lt;mx:HBox id=''mainBox''%26gt;
%26lt;!-- Should render a 100 x 100 box but instead the image
is full size --%26gt;
%26lt;mx:Image id=''image2'' width=''100'' height=''100'' /%26gt;
%26lt;/mx:HBox%26gt;
%26lt;/mx:Application%26gt;
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment