Printing only a part of an image
Posted: Mon Oct 26, 2015 10:07 pm
How do I do that? If I only want to print a tile in a tileset for example.
I didn't find this option anywhere.
I didn't find this option anywhere.
Code: Select all
ImageData:paste( source, dx, dy, sx, sy, sw, sh )
Code: Select all
crop = {
x = 300, -- upper-left corner of desired image
y = 150,
w = 150, -- size of final crop image
h = 150,
sourceName = 'CircuitBoard.jpg'
}
crop.sourceImage = love.image.newImageData( crop.sourceName )
crop.imageData = love.image.newImageData( crop.w, crop.h )
crop.imageData:paste( crop.sourceImage, 0, 0, crop.x, crop.y, crop.w, crop.h )
crop.image = gr.newImage( crop.imageData )