Page 1 of 1

Printing only a part of an image

Posted: Mon Oct 26, 2015 10:07 pm
by Eldy
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.

Re: Printing only a part of an image

Posted: Mon Oct 26, 2015 11:05 pm
by Nixola
Take a look at [wiki]Quad[/wiki]s ;)

Re: Printing only a part of an image

Posted: Tue Oct 27, 2015 12:39 am
by Ref
Can also use:

Code: Select all

ImageData:paste( source, dx, dy, sx, sy, sw, sh )
Simple example:

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 )