Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T
Accepted Solution

BB10 camera image returns null bitmap

[ Edited ]

I am using the Invoke method to open the camera and take an image and then close the card given by .

 

When I set the Image, I don't get an error, but the information is null.

The event data is coming back with a location of the image.

What step am I missing?

 

private function CardClosed( event:CardCloseEvent ) : void
{
	trace( 'card closed ' + event.reason + ' ' + event.data );
	InvokeManager.invokeManager.removeEventListener( CardCloseEvent.CARD_CLOSED, CardClosed );
	
	if( event.reason == 'save' && event.data != '' )
	{
		trace("data : " + event.data);
		// example data value : '/accounts/1000/removable/sdcard/camera/IMG_00000131.jpg'
		imgCapture = new Image();						
		imgCapture.setImage( "file://" + event.data );
		
		decodeBitmapData(imgCapture.bitmapData, stage.stageWidth, stage.stageHeight);
	}
}	

 Just wanted to note that I tried to set the image using the following:

  • "file://" + event.data
  • "file:/" + event.data
  • event.data

Same result for all 3 ways.

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: BB10 camera image returns null bitmap

Just found out that if you do this.

 

var dir:File = File.userDirectory.resolvePath( event.data );
 
You get the "file://" portion and end up with
 
file:///accounts/1000/removable/sdcard/camera/IMG_00000131.jpg
 
It still doesn't load the image.
_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: BB10 camera image returns null bitmap

I added a image load listener to see if maybe it was taking a little time to load the image.

imgCapture.addEventListener(Event.COMPLETE, onImageLoad );

private function onImageLoad( event:Event ):void
{
    decodeBitmapData(imgCapture.bitmapData, stage.stageWidth, stage.stageHeight);
}

 But, it still couldn't find the file.  But, at least I could see an error.

 

 

Just event.data with resolve path.url

card closed save /accounts/1000/removable/sdcard/camera/IMG_00000144.jpg
data : /accounts/1000/removable/sdcard/camera/IMG_00000144.jpg
dir url: file:///accounts/1000/removable/sdcard/camera/IMG_00000144.jpg
Error #2044: Unhandled ioError:. text=Error #2035: URL Not Found. URL: app:/accounts/1000/removable/sdcard/camera/IMG_00000144.jpg

 

 

event.data with url

card closed save /accounts/1000/removable/sdcard/camera/IMG_00000141.jpg
data : /accounts/1000/removable/sdcard/camera/IMG_00000141.jpg
dir url: file:///accounts/1000/removable/sdcard/camera/IMG_00000141.jpg
Error #2044: Unhandled ioError:. text=Error #2035: URL Not Found. URL: file:///accounts/1000/removable/sdcard/camera/IMG_00000141.jpg

 

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: BB10 camera image returns null bitmap

I figured it out.  Not that everything is working, but I am capturing the image.

I just needed to add the Loader to get the image and then put that content into the image.

 

private function CardClosed( event:CardCloseEvent ) : void
{
	trace( 'card closed ' + event.reason + ' ' + event.data );
	InvokeManager.invokeManager.removeEventListener( CardCloseEvent.CARD_CLOSED, CardClosed );
	
	if( event.reason == 'save' && event.data != '' )
	{
		trace("request length" + cameraRequest.data.length);
		
		imgCaptureLoader = new flash.display.Loader();
		imgCaptureLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageCapture);
		imgCaptureLoader.load(new URLRequest('file://' + event.data ));
	}
}		

private function onImageCapture( event:Event ):void {
	imgCapture = new Image();						
	imgCapture.visible = false;
	try {
		imgCapture.setImage( imgCaptureLoader.content );
		decodeBitmapData(imgCapture.bitmapData, stage.stageWidth, stage.stageHeight);
	} catch (e:*) {
		trace(" load error: " + e);
	}
}

 

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment