[RESOLVED] display.captureBounds() Totally BROKEN in Graphics 2.0

Hi,

I have an app developed and published that captures the bounds of a display object in Graphics 1.0. I’m working in the migration to graphics 2.0 (daily build 2170) in order to be able to publish the app on the Apple Appstore, now that Facebook is a plugin. 

Problem is that display.captureBounds is not working anymore with the app. This is the code I’m using to capture bounds (exactly the same that you provide in the examples):

local screenBounds = { xMin = 0, xMax = 100, yMin = 0, yMax = 100, } local miCaptura = display.captureBounds( screenBounds )

The result is always the same (from terminal):

Feb 20 14:46:31 MacBook-Air-de-Braulio.local Corona Simulator[3672] <Error>: CGImageCreate: unsupported image width: 2147483648.

Feb 20 14:46:31 MacBook-Air-de-Braulio.local Corona Simulator[3672] <Error>: Unsupported dimensions - 0 x, 0 y, 2147483648 width, 200 height, 8589934592 bytes-per-row

Feb 20 14:46:31 MacBook-Air-de-Braulio.local Corona Simulator[3672] <Error>: CGBitmapContextCreateWithData: failed to create delegate.

Feb 20 14:46:31 MacBook-Air-de-Braulio.local Corona Simulator[3672] <Error>: CGContextDrawImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

Feb 20 14:46:31 MacBook-Air-de-Braulio.local Corona Simulator[3672] <Error>: CGBitmapContextCreateImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

Feb 20 14:46:31 MacBook-Air-de-Braulio.local Corona Simulator[3672] <Error>: ImageIO: CGImageDestinationAddImage image parameter is nil

Feb 20 14:46:31 MacBook-Air-de-Braulio.local Corona Simulator[3672] <Error>: ImageIO: CGImageDestinationFinalize image destination must have at least one image

This is really frustrating, because even with the daily build 2182 the problem still persists, and my client is waiting to update his app on the Appstore. (Wich is impossible because if I build the app with graphics 1.0 or any previous daily build than 2170, Apple will reject the app). 

Any advice of what is happening here?

Thank you in advance

Strange. I ran your snippet in Corona Simulator and on device without getting any errors.

iMac 27", OSX 10.9.1

Xcode 5.0.2

Corona build: 2014.2182

Device:

iPod Touch 5G, iOS 7.0.4

Do you get the same error you posted if you *only* try the snippet you gave above?

Hi ingemar,

thanks for your answer. I’ve done what you suggest, and effectively, problem wasn’t with captureBounds, but with “display.save()” which is a few lines under the posted code. 

Problem now is solved (I was focussed on display.captureBounds because the error message from terminal suggest me that this was the issue). 

Thanks again, and consider this thread solved :slight_smile:

Bmrpeal,

I am having the same issue as you.  Migrating from graphics 1.0 to 2.0 … prior to this the code i had for capturing a portion of the screen worked just fine.

What did you change in your display.save() to get past this?

Using build 2170

local capture = display.captureBounds( screenBounds ) display.save(capture, {filename = "test.jpg", baseDir = system.DocumentsDirectory }) &nbsp;

I also get:

Corona Simulator(78674,0x7fff726bc310) malloc: \*\*\* mach\_vm\_map(size=18446741324930482176) failed (error code=3) \*\*\* error: can't allocate region \*\*\* set a breakpoint in malloc\_error\_break to debug Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: CGImageCreate: unsupported image width: 2147483648. Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: Unsupported dimensions - 0 x, 0 y, 2147483648 width, 320 height, 8589934592 bytes-per-row Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: CGBitmapContextCreateWithData: failed to create delegate. Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: CGContextDrawImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context &nbsp;and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: CGBitmapContextCreateImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context &nbsp;and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. &nbsp;

Thanks for any insights

Cheers

Yeah, bmrpeal, what did you do to fix that? :slight_smile: I’ve been banging my head on this problem for a while and am no closer to figuring out what’s wrong.

 Jay

I have changed only the position of the object to save. Better to understand with a real example of my code. 

Old code:

myScreenshot = display.captureBounds( object.contentBounds ) display.save( myScreenshot, "photo" .. photoNum .. ".jpg" )

New code (working with Graphics 2.0):

myScreenshot = display.captureBounds( object.contentBounds ) myScreenshot.x = display.contentWidth \* 0.5 myScreenshot.y = display.contentHeight \* 0.5 display.save( myScreenshot, "photo" .. photoNum .. ".jpg" )

as you can see, the only modification is to place the object to save inside the center of the screen. Just try what coordinates works with your needs, but I think this can be a good start. I hope this helps you  :slight_smile:

That is an odd workaround, but it fixed the problem for me. Just centered the newly created image and then display.save() worked fine after that.

Thanks, bmrpeal!

 Jay

Thanks for the insight … not sure i ever would have thought of that one …

Gotta be a bug … Corona Labs please fix that or at a minimum document it in the Got yas.

Strange. I ran your snippet in Corona Simulator and on device without getting any errors.

iMac 27", OSX 10.9.1

Xcode 5.0.2

Corona build: 2014.2182

Device:

iPod Touch 5G, iOS 7.0.4

Do you get the same error you posted if you *only* try the snippet you gave above?

Hi ingemar,

thanks for your answer. I’ve done what you suggest, and effectively, problem wasn’t with captureBounds, but with “display.save()” which is a few lines under the posted code. 

Problem now is solved (I was focussed on display.captureBounds because the error message from terminal suggest me that this was the issue). 

Thanks again, and consider this thread solved :slight_smile:

Bmrpeal,

I am having the same issue as you.  Migrating from graphics 1.0 to 2.0 … prior to this the code i had for capturing a portion of the screen worked just fine.

What did you change in your display.save() to get past this?

Using build 2170

local capture = display.captureBounds( screenBounds ) display.save(capture, {filename = "test.jpg", baseDir = system.DocumentsDirectory }) &nbsp;

I also get:

Corona Simulator(78674,0x7fff726bc310) malloc: \*\*\* mach\_vm\_map(size=18446741324930482176) failed (error code=3) \*\*\* error: can't allocate region \*\*\* set a breakpoint in malloc\_error\_break to debug Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: CGImageCreate: unsupported image width: 2147483648. Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: Unsupported dimensions - 0 x, 0 y, 2147483648 width, 320 height, 8589934592 bytes-per-row Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: CGBitmapContextCreateWithData: failed to create delegate. Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: CGContextDrawImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context &nbsp;and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. Feb 24 12:57:01 macbook2013.missingmarble.com Corona Simulator[78674] \<Error\>: CGBitmapContextCreateImage: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context &nbsp;and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. &nbsp;

Thanks for any insights

Cheers

Yeah, bmrpeal, what did you do to fix that? :slight_smile: I’ve been banging my head on this problem for a while and am no closer to figuring out what’s wrong.

 Jay

I have changed only the position of the object to save. Better to understand with a real example of my code. 

Old code:

myScreenshot = display.captureBounds( object.contentBounds ) display.save( myScreenshot, "photo" .. photoNum .. ".jpg" )

New code (working with Graphics 2.0):

myScreenshot = display.captureBounds( object.contentBounds ) myScreenshot.x = display.contentWidth \* 0.5 myScreenshot.y = display.contentHeight \* 0.5 display.save( myScreenshot, "photo" .. photoNum .. ".jpg" )

as you can see, the only modification is to place the object to save inside the center of the screen. Just try what coordinates works with your needs, but I think this can be a good start. I hope this helps you  :slight_smile:

That is an odd workaround, but it fixed the problem for me. Just centered the newly created image and then display.save() worked fine after that.

Thanks, bmrpeal!

 Jay

Thanks for the insight … not sure i ever would have thought of that one …

Gotta be a bug … Corona Labs please fix that or at a minimum document it in the Got yas.