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 »

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: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Printing only a part of an image

Post by Nixola »

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: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Printing only a part of an image

Post 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 )
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests