| View previous topic :: View next topic |
| Author |
Message |
Mr Billy
Joined: 26 Oct 2005 Posts: 10
|
Posted: Wed Oct 26, 2005 10:16 am Post subject: Check if pixel is transparent |
|
|
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 |
|
 |
haust
Joined: 01 Oct 2005 Posts: 25 Location: France
|
Posted: Wed Oct 26, 2005 1:51 pm Post subject: |
|
|
| Take a look here, this may help. |
|
| Back to top |
|
 |
Mr Billy
Joined: 26 Oct 2005 Posts: 10
|
Posted: Thu Oct 27, 2005 4:58 am Post subject: |
|
|
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 |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Thu Oct 27, 2005 5:44 am Post subject: |
|
|
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 |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Thu Oct 27, 2005 6:44 am Post subject: |
|
|
@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 |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Thu Oct 27, 2005 7:03 am Post subject: |
|
|
| 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 |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Thu Oct 27, 2005 7:08 am Post subject: |
|
|
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 |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Thu Oct 27, 2005 7:31 am Post subject: |
|
|
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 |
|
 |
|