Oleksandr Matrosov
Oleksandr Matrosov

Reputation: 27133

Corona SDK split image

Is there any way how to split image using Corona SDK. For example I have an image 100 x 100 px. I need to create from this image 4 images 50 x 50 px.

Upvotes: 0

Views: 688

Answers (2)

MikeMedved
MikeMedved

Reputation: 31

If you use the original image (let's say 100x100) as a spritesheet of sprites that are 50x50, it will "split" the image into 4 sprites that you can later use to display those portions of the image.

See http://developer.coronalabs.com/reference/index/spritenewspritesheet

Upvotes: 0

speeder
speeder

Reputation: 6296

Yes... there are.

But I guess you are asking HOW to do it.

In that case, you need to use display.captureBounds()

Example copy and pasted from the manual to get the lower right quarter of a full-screen image.

-- Set up a bounds table for capturing the bottom-right quadrant of the screen.
local screenBounds =
{
    xMin = display.contentWidth / 2,
    xMax = display.contentWidth,
    yMin = display.contentHeight / 2,
    yMax = display.contentHeight,
}

-- Capture the bounds of the screen.
local myCaptureImage = display.captureBounds(screenBounds)

Upvotes: 1

Related Questions