Alpha supported ?

Everything else that doesn't fall into one of the other PB categories.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Alpha supported ?

Post by Polo »

Hi !
Are the alpha channel supported in PB4 ?
I've searched in the help but haven't found...
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

Yes it is, do a search on the forum. :wink:
Steve Elliott
Enthusiast
Enthusiast
Posts: 109
Joined: Sun Jan 01, 2006 9:34 pm
Location: Wales, UK

Post 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()
Project S: loading...
Intel Core2 Duo E7200 @ 2.53Ghz, 3Gb RAM Intel G45 Express
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

I'm just talking about images, not sprites ;)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

DrawAlphaImage() will render the alpha channel in png and tiff image formats. It works for 2d non-sprite images.
Last edited by netmaestro on Tue Feb 21, 2006 2:33 pm, edited 2 times in total.
BERESHEIT
Steve Elliott
Enthusiast
Enthusiast
Posts: 109
Joined: Sun Jan 01, 2006 9:34 pm
Location: Wales, UK

Post 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.
Last edited by Steve Elliott on Sat Feb 11, 2006 11:13 am, edited 1 time in total.
Project S: loading...
Intel Core2 Duo E7200 @ 2.53Ghz, 3Gb RAM Intel G45 Express
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Can someone answer my question ?
Is the alpha channel supported ?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post 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 ?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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?
Last edited by netmaestro on Tue Feb 21, 2006 2:31 pm, edited 3 times in total.
BERESHEIT
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post 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....
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

You can still give it a try, it should work.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post 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
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Strange, i will take a look.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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.
@}--`--,-- A rose by any other name ..
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post 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 ;)
Post Reply