I’ve been having problems with display.save on objects in groups, and I eventually realized the problem pertains to objects whose parent group has been moved with an x or y offset.
Example:
local group = display.newGroup() group.y = 25 local img = display.newImageRect ( group, "Icon.png", 100, 100 ) img.x, img.y = 100, 100 local temp = system.TemporaryDirectory local fn = "temp.png" display.save ( img, { filename = fn, baseDir = temp } ) local img2 = display.newImageRect ( group, fn, temp, 100, 100 ) img2:setFillColor ( 1, 0, 0 ) img2.x, img2.y = 200, 100
Here I place the “img” graphic inside a group which has been moved down by 25px. I’m then trying to bring it back in as “img2” and tint it red, setting it beside the original. But you can see it’s cropped by 25px, and the crop amount varies according to whatever offset the group has. (Tested in builds 3520 and 3540.)
Ordinarily instead of a simple image, I’m trying to render a group within a group to a raster image, and to that end I suspect I should be using snapshots instead, but I was just wondering if this is what display.save is supposed to be doing in this case. I notice display.save does crop objects which are partially off-screen when saved, which I can understand, but cropping an object due to its group’s offset just seems bizarre to me.