forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Check if pixel is transparent

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
Mr Billy



Joined: 26 Oct 2005
Posts: 10

PostPosted: Wed Oct 26, 2005 10:16 am    Post subject: Check if pixel is transparent Reply with quote

Is there a way to check if a pixel in an image is transparent? When I use the img:pixel, the transparent pixels register as white for me. thanks.
_________________
"There is no spoone"
-The Matricks
Back to top
View user's profile Send private message
haust



Joined: 01 Oct 2005
Posts: 25
Location: France

PostPosted: Wed Oct 26, 2005 1:51 pm    Post subject: Reply with quote

Take a look here, this may help.
Back to top
View user's profile Send private message
Mr Billy



Joined: 26 Oct 2005
Posts: 10

PostPosted: Thu Oct 27, 2005 4:58 am    Post subject: Reply with quote

I know how to make pngs transparent, and how to set pixels to transparent, but I want to be able to identify whether or not a pixel is transparent in a loaded png.
_________________
"There is no spoone"
-The Matricks
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Thu Oct 27, 2005 5:44 am    Post subject: Reply with quote

You can use "pixel" to get the color and "colors" to get the color components of a color object:

Code:

image = Image.createEmpty(1, 1)
color = image:pixel(0, 0)
colors = color:colors()
assert(colors.r == 0)
assert(colors.g == 0)
assert(colors.b == 0)
assert(colors.a == 0)
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Thu Oct 27, 2005 6:44 am    Post subject: Reply with quote

@shine
would it be faster than lua if supported by a C-funtion?
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Thu Oct 27, 2005 7:03 am    Post subject: Reply with quote

LuMo wrote:

would it be faster than lua if supported by a C-funtion?


What should this C function do?

Anyway, with the new true color mode and perhaps your collision test, there is no reason to read pixel components.
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Thu Oct 27, 2005 7:08 am    Post subject: Reply with quote

true;
so new model will be 8888 for sure?
cause then i can rewrite my stuff ;)
if you grand me svn access i could put it up too
note: 8888 would make my life much easier ;)

greets
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Thu Oct 27, 2005 7:31 am    Post subject: Reply with quote

Yes, I think 8888 should be the new pixelmode mode for Lua Player, because this makes things a lot easier and you have alpha blending and true color. The drawback is less speed, but you can use the Timer class for smooth animations, so you don't need 60 fps.

Not relying on a fixed fps rate, but using the Timer class, has another advantage: a port to the PC version would be much easier and it would run on PC smooth, too and on other consoles. And if someone wants to implement a caching algorithm for images in VRAM, it would be faster than the current Lua Player, even in true color :-)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group