Love.graphics.newImage

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
epishev
Prole
Posts: 1
Joined: Fri Feb 04, 2011 9:20 pm

Love.graphics.newImage

Post by epishev »

Hello.

Got a question ...
The documentation is written
«Love.graphics.newImage
Creates a new Image from a file path. Note that the x and y dimensions of the image must (currently) be a power of two, or some graphics cards will not display it. »
I need to insert a picture, size: 1024:768
How to do it?

Thanks in advance!
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Love.graphics.newImage

Post by Jasoco »

Make the image 1024x1024 and use quads (if the screen is bigger than 1024x768) to crop off the bottom. The benefit to quads being you can use the remaining 1024x256 pixel area for other interface elements.

Just remember, some video cards won't display images bigger than 2048 and others 1024, but there's no way to know what your user is going to have. So be safe and use small images whenever possible to avoid headaches later when your users start filing bug reports about missing images even though it might work fine on your computer.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Love.graphics.newImage

Post by nevon »

Jasoco wrote:Make the image 1024x1024 and use quads (if the screen is bigger than 1024x768) to crop off the bottom. The benefit to quads being you can use the remaining 1024x256 pixel area for other interface elements.
What would be the benefit of doing this instead of just adding transparent padding?
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

Re: Love.graphics.newImage

Post by leiradel »

nevon wrote:What would be the benefit of doing this instead of just adding transparent padding?
You can use the remaining 1024x256 area to put other images and use quads to pickup what you need to draw from the 1024x1024 image. If you just fill it with transparent pixels, it's a waste of texture memory.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love.graphics.newImage

Post by Robin »

leiradel wrote:You can use the remaining 1024x256 area to put other images and use quads to pickup what you need to draw from the 1024x1024 image. If you just fill it with transparent pixels, it's a waste of texture memory.
That sounds a lot like premature optimisation. And using quads is much more complicated than single images.
Help us help you: attach a .love.
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

Re: Love.graphics.newImage

Post by leiradel »

Robin wrote:That sounds a lot like premature optimisation. And using quads is much more complicated than single images.
Although grouping several images into fewer PO2 images is premature during production it's better to use quads from the beginning because otherwise there would be a lot of code to change when the time comes for that optimization, if you want to do it of course. Quads can be encapsulated in a class to make their use easier, but yeah, it's more complicated than using images.

Cheers,

Andre
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 5 guests