Hello all,
I’ve run into a bit of a snag when trying to crop a captured photo at full resolution. My initial code tried using a bounding rectangle to be the capture bounds of the crop and use display.captureBounds(), but this function will only capture what is visible on the screen. If you are trying to crop a photo that has a higher resolution than the screen with a crop bounding box that is also higher resolution than the screen then the crop won’t work correctly.
local tempGroup = display.newGroup() tempGroup:insert(myPhoto) -- This object will be used as screen capture boundaries object local cropArea = display.newRect(cropX, cropY, cropWidth, cropHeight) cropArea.alpha = 0.0 tempGroup:insert(cropArea) -- Now capture the crop area which the user image will be underneath local myCaptureImage = display.captureBounds(cropArea.contentBounds) display.save(myCaptureImage, { filename=self.filePath .. self.fileName, baseDir=self.baseDir, isFullResolution=true, backgroundColor={0, 0, 0, 0} })
How can I crop an image with a resolution higher than the screen with a crop bounding box that is also larger than the screen?
For example:
Device: iPhone 5
Device resolution: 640x1136
Photo resolution: 2448x3264
Crop bounding box: { x = 200, y = 200, width = 2048, height = 2864 } This is a box that is 200 pixels smaller on all sides from the original
Thanks!