Page 1 of 1

Love.graphics.newImage

Posted: Sat Feb 05, 2011 1:16 am
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!

Re: Love.graphics.newImage

Posted: Sat Feb 05, 2011 2:43 am
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.

Re: Love.graphics.newImage

Posted: Sat Feb 05, 2011 9:38 am
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?

Re: Love.graphics.newImage

Posted: Sat Feb 05, 2011 3:01 pm
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.

Re: Love.graphics.newImage

Posted: Sat Feb 05, 2011 3:39 pm
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.

Re: Love.graphics.newImage

Posted: Sat Feb 05, 2011 4:05 pm
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