PB supports bmp transparency!!!

Advanced game related topics
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

PB supports bmp transparency!!!

Post by Num3 »

Well i didn't even know bmp could have transparency !
I've found it by accident actually, and it works under pb natively!

Here's the code!

Code: Select all

If InitSprite() And InitSprite3D() And InitKeyboard()
  
  OpenScreen(800,600,32,"bmp transparency!")
  For a=0 To 20
    LoadSprite(a+1,GetCurrentDirectory()+"gfx\p"+RSet(Str(a+1),4,"0")+".bmp",#PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
    CreateSprite3D(a+1,a+1)
  Next
  a=0
  Repeat
    
    ClearScreen(back)
    ;ClearScreen(0)
    
    Start3D() 
      DisplaySprite3D(a+1,200,200,255)
    Stop3D()
    
    FlipBuffers(2)
    
    
    ExamineKeyboard()
    
    If KeyboardReleased(#PB_Key_All)
      End
    EndIf
    
    If ElapsedMilliseconds() - last > 50
      last=ElapsedMilliseconds()
    a+1
    If a>=20
      a=2
      back=RGB(Random(255),Random(255),Random(255))
    EndIf
  EndIf
  ForEver 
  
  
EndIf
Here's a sample package with graphics!

File: 138kb->battle.zip
Image
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Neat. Thanks
Dare2 cut down to size
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

Must be a Vista thing?
I see only plain colors switching
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Edwin Knoppert wrote:Must be a Vista thing?
I see only plain colors switching
Hmmm... That might be so... Going to check that!

Works with alpha here :S (under vista)

Image


--Edit--
Did you download the package with graphics!?
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

After digging around i've discovered bmp alpha transparency exists for quite some time, and that GDI supports it!

It's called Format32bppArgb. It's present in GDI+...

Tech Article here (from 2003)
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

with Sprite3D, Alpha Transparency also works with PNGs
it's a capability of your grafix card when using Sprite3D.

I didn't know that BMP can hold an Alpha channel,
only knew that there is a special BMP format with a designated transparent color.
you could use them in imagegadgets to have a transparent color,
with the VB6 examples such bitmaps were included, but I didn't find a way to create those BMPs.
oh... and have a nice day.
Violet
Enthusiast
Enthusiast
Posts: 106
Joined: Sun Dec 23, 2007 6:30 pm

Post by Violet »

Nice to know, but I do not recommend to use Bitmaps with Alpha Channel. :? That is very special (already read in wiki some time ago), just very few applications can handle it (Photoshop of corse, with GIMP I am not sure).
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Num3 wrote:
Edwin Knoppert wrote:Must be a Vista thing?
I see only plain colors switching
Hmmm... That might be so... Going to check that!

Works with alpha here :S (under vista)
Yep, works here under Vista Business.
zefiro_flashparty
User
User
Posts: 74
Joined: Fri Mar 04, 2005 7:46 pm
Location: argentina

planetary explosion!!! XD

Post by zefiro_flashparty »

:shock:
woaa nice effect =)

epileptic kids, not see the example :P
User avatar
bobobo
Enthusiast
Enthusiast
Posts: 206
Joined: Mon Jun 09, 2003 8:30 am

Post by bobobo »

bmp (v4/5) can hold alphachannel und are usable as container for
png / jpeg(fif) formats

look @ http://msdn.microsoft.com/en-us/library/ms532301.aspx
사십 둘 .
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Does IE supports bmp with alpha transparency?
Violet
Enthusiast
Enthusiast
Posts: 106
Joined: Sun Dec 23, 2007 6:30 pm

Post by Violet »

I know that Internet Explorer 7 is supporting PNG Images with Transparency (I tested it).
best regards,

Violet
Post Reply