Image rendering

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Danny769
Posts: 55
Joined: Wed Feb 01, 2006 12:29 pm

Image rendering

Post by Danny769 »

I need to load several images in sequence to imatate a movie.
All it does is crash

I currently load a picture in place for background, and then bliz it and flip it.

It does about 9 and then crashes.
Any ideas?

I need closer to 200 images to load, and yes i relize that is asking alot of lua, but how would i go about doing it, in a maner that will work
RanDom_ErrOr
Posts: 13
Joined: Sat Apr 15, 2006 11:19 am

Post by RanDom_ErrOr »

wouldnt it be easier to make a .gif or a .avi and then render that as a texture onto a sprite that is the same size as the screen (or whatever size you need)

that way you can do things like dynamic resizing, layering, alpha transperiencies... etc... etc... etc...
Danny769
Posts: 55
Joined: Wed Feb 01, 2006 12:29 pm

Post by Danny769 »

Do you have an example as for the code for avi?

And will it look like a vid?
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

Why do you need to load 200 images and how big are they ? I can't think of a reason why you would need this, the best way is to load each as necessary (ie: if in a game env't then load necessary imgs for each level)
imhotep
Posts: 41
Joined: Tue Dec 13, 2005 9:15 pm

Post by imhotep »

1. code please
2. use timers and load a new image when timer:time()>timelimit
3. don't load all images before the loop, the psp doesn't have that much resources
4. unassign the old picture when the new one is blitted
5. oldpic=""
Danny769
Posts: 55
Joined: Wed Feb 01, 2006 12:29 pm

Post by Danny769 »

How do i unasign a pic.

All i have been doing is loding a new on to replace it
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

No need to unassign anything in Lua. Use the same variable name for a new value of *any* type. Lua has a built-in garbage collector to take care of cleaning up inside.
Geo Massar
Retired Engineer
Altair
Posts: 76
Joined: Sat May 20, 2006 2:33 am
Location: The Netherlands

Post by Altair »

Yeah i was wondering how that works. It doesn't clean it up when you use another variable, right? Because if i do that and i don't empty the old var. myself, it crashes if i do that a couple of times.
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

All global non-nil variables can be left untouched in the namespace. It has been advised to declare all variables as locals if possible since they can be garbage-collected sooner or later automatically.

All parameters in every Lua function are locals.
Geo Massar
Retired Engineer
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

The crash sounds like a memory error, try freeing up images as you display them and dont load them all up at once. That could possibly be your biggest issue.
Altair
Posts: 76
Joined: Sat May 20, 2006 2:33 am
Location: The Netherlands

Post by Altair »

romero126 wrote:The crash sounds like a memory error, try freeing up images as you display them and dont load them all up at once. That could possibly be your biggest issue.
Yeah thats what i figured. I clear the images, but it crashes always (if it crashes) at the moment it loads four 1000x1000 images after eachother. However it doesn't crash alot anymore, since i clear the unused images. I guess i dont clear everything. I'll look for more stuff i can kick out of the memory.
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

1000x1000px?

The limits on the PSP is only 480x272px size
Altair
Posts: 76
Joined: Sat May 20, 2006 2:33 am
Location: The Netherlands

Post by Altair »

romero126 wrote:1000x1000px?

The limits on the PSP is only 480x272px size
nope thats the resolution of the screen. I use 1000x1000 images but ofcourse can only blit part of it to the screen.
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

A single 1000x1000 image loaded would eat up about 4MB of VRAM, would it?

The VRAM is only 32MB in PSP, I believe.

PS Is it VRAM or just RAM?
Geo Massar
Retired Engineer
Altair
Posts: 76
Joined: Sat May 20, 2006 2:33 am
Location: The Netherlands

Post by Altair »

i dont know if its vram or ram, but the image itself is only 58 kB. Well thats the biggest. The others are smaller. I also have a 11 kB one.
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Aren't they all compressed before loading?

When loaded unto the memory, each image is uncompressed, that's, pixel by pixel, correct?
Geo Massar
Retired Engineer
Teggles
Posts: 27
Joined: Mon Jan 16, 2006 9:30 am

Post by Teggles »

LuaPlayer cannot support loading images larger than 512x512. Fact.

For your "animation", you'd do something like this:


image = Image.load("")
screen:clear()
screen:blit(0, 0, image)
screen.flip()
image = Image.load("")
screen.waitVblankStart(25)

...then back to the screen:clear and go from there. The vBlank function is how long it will stay on screen. Note this is only an example.
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

Im so glad teggles came to this website. Its about time.
youresam
Posts: 87
Joined: Sun Nov 06, 2005 1:43 am

Post by youresam »

I have heard that LuaPlayer can load 1000x1000 jpgs, but I havent tried it out.

I was helping someone out with code today, and the same thing happened. For some reason, a 480x272 image takes up exactly 1mb RAM. Now, with Lowser, Lua has only 16mb to use.



As for how to remove images, you should.
theimage = nil
collectgarbage()

that will remove the image from memory then garbage collect to rid of it forever.
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

youresam wrote:... a 480x272 image takes up exactly 1mb RAM.
Are you referring to the double buffer which occupies exactly 1 MB in the memory space, 4 bytes for the front and 4 for the back buffer?

That explains why the funny number of 272 for the height.
Geo Massar
Retired Engineer
Altair
Posts: 76
Joined: Sat May 20, 2006 2:33 am
Location: The Netherlands

Post by Altair »

Ok im getting a little tired of this. How about you guys try something out yourself first. Im using a 1000x1000 JPG image of 58 kB and it works. It wont work with PNG but it does with JPG. And yoursam I was the one who told you this remember?
Post Reply