Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / pasting an image to a bitmap with alpha channel?

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th Aug 2010 13:43
Yeah, so I have this problem where I create a bitmap, and want to paste one image over and over on to this bitmap. The problem is that this image has an alpha channel, which is just displayed as black on the bitmap... Is there a way to paste the image to the bitmap so the alpha channel is used?

Thanks,

TheComet

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 15th Aug 2010 13:56
I'm sure you just add a ,1 when creating the bitmap:

CREATE BITMAP 1,256,256,1

Health, Ammo, and bacon and eggs!
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 15th Aug 2010 14:12
When you create the bitmap you also need to use the "set bitmap format" command first,depending on the type of image your going to be pasting to it later,there is a list in the help to show which format needs what number,i just tend to use 21 which is for a 32 bit ARGB bitmap.If you use this command at the top of your file then all the bitmaps you create after will use this format.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 15th Aug 2010 18:13
I thought you just had to add a 1 to paste image:

paste image imgnr, x, y, 1

Adding this 1 will enable transparency for an image.

Cheers!
Sven B

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 15th Aug 2010 18:26
I think Sven B is correct although I do sometimes have issues using the point command on certain computers. My Space Invaders entry works fine on all 3 of my test computers, but will not work on a netbook I tried it on and also a friends computer. The netbook I have no idea of specs, but the computer is one I built so I know the only real difference between machines is an ATI video card.
I figured it was some odd difference in the way the drivers handle colour. But as I no longer have an ATI based system to test on had to forget about it.
I didn't know about the set bitmap format either, perhaps that may help.

http://s6.bitefight.org/c.php?uid=103081
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 15th Aug 2010 22:50
Yeah, just a ,1 at the end of PASTE IMAGE should show the transparency on the bitmap. Now if you want to use GET IMAGE to grab an image from that bitmap it will need SET BITMAP FORMAT 21 before the bitmap is created to grab the alpha channel with GET IMAGE.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Aug 2010 13:36
Quote: " but the computer is one I built so I know the only real difference between machines is an ATI video card."


I don't know about this specific case but in general you might be right. Some of my shader demos work differently on ATI versus nVidia GFX cards. The issue seems to be how colours are initialised - one card defaults to black, the other to white. When it matters I try to make sure everything is initialised correctly in my code but often don't bother. In other words it's the usual story - don't rely on variables defaulting to the values you want even if the manual says you can.
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 16th Aug 2010 14:48
The Nvidia vs ATI Card problem is why i started trying other things and stumbled across the set bitmap format commamnd in another post,since ive used it in the basic set up code at the top of all my projects i havnt run into any of the problems i used to get switching from my laptop(ATI) to my desktop(Nvidia). It may just be coincedence or i may not have been doing something else correctly but it seems to have worked.Its certainley needed if like
Grog says you want to use get image on the bitmap you have created to later paste it to the screen and keep the alpha chanel intact.So it just made sence,in my head at least,to do it before trying to paste to the bitmap with an image that had an alpha chanel too.
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 17th Aug 2010 21:05
I have put it in the space invaders code but am unable to test it on any of the offending machines. Only person I know I can ask is on their hols at present. I sure hope it works. I always wondered if you could set the bitmap's initial settings, now I know As far as I am aware no one had any problems with it, or didn't mention them at the time. So I guess they all had Nvidia setups so it wasn't noticed.

http://s6.bitefight.org/c.php?uid=103081
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Aug 2010 22:30
This is strange...

I used:

set bitmap format 21

and then paste image <image>,<x>,<y>,1, but it still isn't transparent... I have an ATI Radeon HD 4670

I also noticed that the text commands in DBC don't work anymore... It's the new card... It has turned... evil

TheComet

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 18th Aug 2010 01:14
Quote: "but it still isn't transparent"


Post the image so we can see if the image itself is the problem.

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 18th Aug 2010 01:40
Are you using the load image"",1,1 flag as well? Or if you are getting your image there is a flag for that also.

http://s6.bitefight.org/c.php?uid=103081
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 19th Aug 2010 20:28
If you're searching for alpha blending, then I think you won't get far. DBP doesn't really support alpha blending.
You might want to try Image Kit for this, which does support alpha blending, but not on bitmaps (only images).

Cheers!
Sven B

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 19th Aug 2010 20:54
Be sure to use the SET BITMAP FORMAT 21 command BEFORE you create the new bitmap.

Login to post a reply

Server time is: 2026-07-24 20:35:58
Your offset time is: 2026-07-24 20:35:58