display.save() and display.capture() question

Hello!

When I use display.capture and display.save the new object I get has a black border around it.

What I have done is I have created a new rectangle (display.newRect()) and I have created a a grid on that rectangle using lines horisontaly and verticaly. The lines are not outside the rectangle as far as the eye can see.

I put all this in a group and use display.capture(group) and I get a new object with a black border.

I dont want that black border because the new object is a base for a chart I’m creating.

Here is the code if you can read it…

local chart1 = display.newGroup()         chart1.hasDot = false         chart1.hasLine = false         chart1.x, chart1.y = 5, 5                  local function init\_chart()             local chart\_bg = display.newRect(0,0, 600, 400)                 chart\_bg:setStrokeColor(180, 180, 180)                 chart1:insert(chart\_bg)                 local linje = {}                 local linje1 = {}                 for i=1, ((chart\_bg.height/50 )+ 1), 1 do                     linje.i = display.newLine( 0, (chart\_bg.height-(i)\*50), chart\_bg.width, (chart\_bg.height-(i)\*50) )                     linje.i:setColor(100,100,100)                     linje.i.width = 1                     chart1:insert(linje.i)                 end                                  for i=1, ((chart\_bg.width/50 )+ 1), 1 do                     linje1.i = display.newLine( chart\_bg.width - i\*50, 0, chart\_bg.width- i\*50, chart\_bg.height )                     linje1.i:setColor(100,100,100)                     linje1.i.width = 1                     chart1:insert(linje1.i)                 end                                  copy = display.capture(chart1, "chartinit.bmp")                                  for i=chart1.numChildren,1,-1 do                     local child = chart1[i]                     child.parent:remove( child )                 end                                                   chart1:insert(copy)         end  

Kinde regards!

Hi @andersson_d1,

Could you use “display.captureBounds()” instead? This allows you to capture just a portion of the screen (your rectangle bounds) instead of the entire screen.

http://docs.coronalabs.com/api/library/display/captureBounds.html

Best regards,

Brent

Thank you, perfect! I missed that one, sry.

Kind regards!

Hi @andersson_d1,

Could you use “display.captureBounds()” instead? This allows you to capture just a portion of the screen (your rectangle bounds) instead of the entire screen.

http://docs.coronalabs.com/api/library/display/captureBounds.html

Best regards,

Brent

Thank you, perfect! I missed that one, sry.

Kind regards!

display.captureBounds() works great, If you want to store an image to the Photo library.

We want the image to be stored to the Documents directory, so we can share it so mail/social networks. How can we get rid of the black border in this situation?

Hi @friskypigstudios,

Can you use display.save() instead?

Thanks,

Brent

Our app offers users 2 options:

  • they can save images to their Photo Album. We do this with display.captureBounds(). We take the original bounds and cut off 1px top, left, right and left. This removes any unwanted borders and images look great.
  • they can also send images via twitter/fb/email. We do this with display.save() to save images internaly in the system.DocumentsDirectory.

Using display.save() sometimes creates borders. The color of the border is as defined by the backgroundColor parameter. Setting isFullResolution to true or false makes no difference. Settings the alpha channel on backgroundColor to 0 or 1 makes no difference.

It would be great, If we could defines bounds and save the image to system.DocumentsDirectory.
 

Hi @friskypigstudios,

When you use display.save(), are you targeting a display group or a single display object? What format are you saving the image in? What happens if you completely omit the “backgroundColor” property?

Thanks,

Brent

display.captureBounds() works great, If you want to store an image to the Photo library.

We want the image to be stored to the Documents directory, so we can share it so mail/social networks. How can we get rid of the black border in this situation?

Hi @friskypigstudios,

Can you use display.save() instead?

Thanks,

Brent

Our app offers users 2 options:

  • they can save images to their Photo Album. We do this with display.captureBounds(). We take the original bounds and cut off 1px top, left, right and left. This removes any unwanted borders and images look great.
  • they can also send images via twitter/fb/email. We do this with display.save() to save images internaly in the system.DocumentsDirectory.

Using display.save() sometimes creates borders. The color of the border is as defined by the backgroundColor parameter. Setting isFullResolution to true or false makes no difference. Settings the alpha channel on backgroundColor to 0 or 1 makes no difference.

It would be great, If we could defines bounds and save the image to system.DocumentsDirectory.
 

Hi @friskypigstudios,

When you use display.save(), are you targeting a display group or a single display object? What format are you saving the image in? What happens if you completely omit the “backgroundColor” property?

Thanks,

Brent