 		public function loadFromBitmapData(bd:BitmapData) : void
 		{						
 			_bd = bd;
+			
+			// in case we were not able to extract the width/height directly from byte array
+			if (!width || !height) {
+				width = bd.width;
+				height = bd.height;
+			}
+			
 			dispatchEvent(new ODataEvent(ODataEvent.DATA));
 		}
 				
 		
 		public function loadFromByteArray(ba:ByteArray) : void
 		{
-			var callback:Function, info:Object;
+			var callback:Function, info:Object, loader:Loader;
 						
 			if (JPEG.test(ba)) {
 				_img = new JPEG(ba);		

			});
			
			bc.addEventListener(BitmapDataUnlimitedEvent.ERROR, function(e:BitmapDataUnlimitedEvent) : void {
				dispatchEvent(new OErrorEvent(OErrorEvent.ERROR, RuntimeError.OUT_OF_MEMORY));
			});
			
			bc.create(width, height, true);

						
			Utils.extend(this, _img.info());
			size = ba.length;
			
			loader = new Loader;
			
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event) : void 
			{					
				loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, arguments.callee);
								
				_prepareBitmapData(loader.width, loader.height, function(bd:BitmapData) : void {
					if (bd) {
						bd.draw(loader.content as IBitmapDrawable, null, null, null, null, true);
						loadFromBitmapData(bd);	
					} else {
						dispatchEvent(new OErrorEvent(OErrorEvent.ERROR, RuntimeError.OUT_OF_MEMORY));
					}
					
					loader.unload();
					ba.clear();
				});
			});
			
			loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function(e:*) : void {
				ba.clear();
				//Moxie.log(e);
			});
			
			try {
				loader.loadBytes(ba);
			} catch (ex:*) {
				//Moxie.log(ex);	
			}
		}
		
		
