Page 1 of 3

Alpha supported ?

Posted: Fri Feb 10, 2006 9:15 pm
by Polo
Hi !
Are the alpha channel supported in PB4 ?
I've searched in the help but haven't found...

Posted: Fri Feb 10, 2006 10:31 pm
by djes
Yes it is, do a search on the forum. :wink:

Posted: Sat Feb 11, 2006 12:23 am
by Steve Elliott

Code: Select all

texture = LoadSprite(#PB_Any,"filename.png",#PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
CreateSprite3D(3dsprite,texture)

Start3D()
  Sprite3DQuality(1)               
  DisplaySprite3D(3dsprite,x,y)
Stop3D()

Posted: Sat Feb 11, 2006 9:45 am
by Polo
I'm just talking about images, not sprites ;)

Posted: Sat Feb 11, 2006 9:49 am
by netmaestro
DrawAlphaImage() will render the alpha channel in png and tiff image formats. It works for 2d non-sprite images.

Posted: Sat Feb 11, 2006 11:11 am
by Steve Elliott
Interesting, didn't realise that netmaestro - but surely it will be quicker using hardware acceleration for this type of task?

I'm using 3DSprites because I do need it in my program for scaling and rotation.

Posted: Sat Feb 11, 2006 11:13 am
by Polo
Can someone answer my question ?
Is the alpha channel supported ?

Posted: Sat Feb 11, 2006 11:14 am
by Polo
Polo wrote:Can someone answer my question ?
Is the alpha channel supported ?
I mean, is the LoadImage loads the alpha channel and is there a way to get it using Point ?

Posted: Sat Feb 11, 2006 12:13 pm
by netmaestro
If you use the Point(x,y) command on a pixel in the transparent area of an image loaded with an alpha channel it returns a color equal to RGB(0,0,0) or #Black. You wouldn't be able to distinguish this from actual black areas of the image using Point(x,y) Is that what you want to do?

Posted: Sat Feb 11, 2006 12:15 pm
by Polo
netmaestro wrote:If you use the Point(x,y) command on a pixel in the transparent area of an image loaded with an alpha channel it returns a color equal to RGB(0,0,0) or #Black. You wouldn't be able to distinguish this from actual black areas of the image using Point(x,y) Is that what you want to do?
In short, alpha channel is not supported ?
No, I need to get the alpha color of a pixel...
But anyway, since the Point function is slow...
Well I guess I'll stick to my homemade images functions....

Posted: Sat Feb 11, 2006 12:29 pm
by Fred
You can still give it a try, it should work.

Posted: Sat Feb 11, 2006 1:36 pm
by Polo
Fred wrote:You can still give it a try, it should work.
Er, what exactly should work ?
If you mean getting the alpha front the color returned by Point, then no, it's not working, I use this :

Code: Select all

  Procedure Alpha(color)
    ProcedureReturn PeekB(@color+3)&$FF
  EndProcedure

Posted: Sat Feb 11, 2006 1:53 pm
by Fred
Strange, i will take a look.

Posted: Sat Feb 11, 2006 2:15 pm
by Dare2
Out of curiosity, how would you go about getting the alpha value from point? "And" it with $FF000000, for example?

But

Code: Select all

k = Point(x,y)
Debug Red(k)
Debug Green(k)
Debug Blue(k)
Uses up all the values. Eg, for yellow = $0FFFF get 255 - 255 - 0 debug results, with nothing left.

Posted: Sat Feb 11, 2006 10:31 pm
by Polo
Have you looked at it ?
That was something I really wanted v4 to have :(
BTW, will there be a function to grab a whole image to a memory buffer one day ? Sometime it's just so better to have that ;)