Printing only a part of an image

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Eldy
Prole
Posts: 7
Joined: Mon Oct 26, 2015 10:06 pm

Printing only a part of an image

Post by Eldy » 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.
Last edited by Eldy on Fri Mar 15, 2019 2:21 pm, edited 2 times in total.

User avatar
Nixola
Inner party member
Posts: 1940
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Printing only a part of an image

Post by Nixola » Mon Oct 26, 2015 11:05 pm

Take a look at [wiki]Quad[/wiki]s ;)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics

User avatar
Ref
Party member
Posts: 687
Joined: Wed May 02, 2012 11:05 pm

Re: Printing only a part of an image

Post by Ref » Tue Oct 27, 2015 12:39 am

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 )

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 27 guests