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 / Transparent Image-Background won't work

Author
Message
DBProUser
15
Years of Service
User Offline
Joined: 28th Oct 2010
Location:
Posted: 15th Nov 2010 20:06
Hello,

i hope i can explain my problem (it is very difficult for me, because my english is quite bad)

I have the following Code:



Image 8-11 is a flying Banana. But when the Banana reach the Human, the Black Background of the Banana is drawed over the colored Human. Why won't the Transparancy work in this case (i have other examples, where the Black Background is not drawed

Like This One (The Sync-Command is in the Main Loop)


In this case, everything worked well, so why not in the Start-Screen.

Thanks for your help
DBProUser
15
Years of Service
User Offline
Joined: 28th Oct 2010
Location:
Posted: 15th Nov 2010 22:07
Ok. Never mind.

I used another way, to avoid that problem, although i didn't find a Answer myself yet. My Box-problem in the other thread is much more important.

But if you have the answer, i am very interested to Know, why i can see the Black Background ovet the other Image.

But as i already said. For the moment this is not so important like this damn Box.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Nov 2010 14:36
Quote: "Why won't the Transparancy work in this case"

Two things are required for pasting with transparency - first is the extra flag on the PASTE IMAGE command, which for the most part yu have included.

The second thing is that DBPro either has to be given an image that contains a transparency layer (eg PNG, TGA or DDS image types), or to be given a colour that it can use as transparent instead via the SET IMAGE COLORKEY command.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
DBProUser
15
Years of Service
User Offline
Joined: 28th Oct 2010
Location:
Posted: 17th Nov 2010 15:04 Edited at: 17th Nov 2010 15:12
Hello IanM,

i already tried that out, but it won't work, so i changed some settings to see, whether it would change or not. But the effect was the same. As i know, DBPro have had a Standard-Colorkey of 0, so that it is not needed to declare the Image Colorkey as long as i use the Standard Background of Deep Black.

Maybe it is not possible in DBPro to load an Image with a Transparent Background, which is not especially formated (in programs like Gimp) with a transparent Background. I mean, Not with the "Load Image" Command, that i use in my first example that didn`t work)

But if i load the Image with Load Bitmap, and not with Load Image, and grasp an Image from the Bitmap (with the Get Image Command like i did in the second Code Snippet), then everything worked fine



Maybe i misconceive that, but if i change it like i said, than i get the result i wanted. So i was a little bit confused, because i thought, that the Load Image Command would work the same, like the Load Bitmap Command

But i have another question. My Pause-Function did not work as expected. The Pause-Screen appears, but with another Press on the P-Button it won't disappear, or it only disappears with hunderts of tries (and only if you push the button fast enough )

Do you have a Solution for me?

Thanks!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Nov 2010 15:48
The colorkey and the additional flags for setting transparency ONLY work with formats that naturally don't support an alpha channel. If your images are PNG for example, you won't be able to set the transparent color in DBP, you'll have to edit it in a program. What you can do however is save your images in a BMP format, and then it will be possible to set transparency. That's exactly what you do with load bitmap and get image, you converted the file to a bitmap before proceeding.

TheComet

DBProUser
15
Years of Service
User Offline
Joined: 28th Oct 2010
Location:
Posted: 17th Nov 2010 16:22 Edited at: 17th Nov 2010 16:24
Thanks, i thought so.

As i found out, you are also experienced in programming with dbpro and all that stuff.

Can you tell me, how to make a pause-function (as i already told, my Pausefunction sucks somewhat and i dont want to open a new Thread)?
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 17th Nov 2010 16:59
I suppose you are referring to this?



It looks ok as it is, but you can make quite a few improvements. First of all, you have the exact same code twice. This means you can get rid of half of it:



You don't need the clear entry buffer command. This command will clear the buffer in which all of the entries from the keyboard are stored, but you never access that buffer:



Also, why wait a second? Isn't that just keeping the player from unpausing?



Instead of Until Inkey$() = "p" or Inkey$() = "P", you can use Until lower$(Inkey$())="p":



I bet you can put some of that into a for...next loop :



And last, why load the image in the middle of the game? Shouldn't you load the pause image at the beginning? If you do want to load it in-game, you have to delete it after the pause loop.



TheComet

DBProUser
15
Years of Service
User Offline
Joined: 28th Oct 2010
Location:
Posted: 17th Nov 2010 17:50 Edited at: 17th Nov 2010 18:18
First of all, Thanks a lot for the Optimizations

What i want to do is a blinking "Pause"-writing, so i need a Second wait-Command between the two status (visible and invisible "Pause")

If i delete the Wait-Commands than in fact the Pause-Function work, but not with the intention i had first (the blinking "Pause"-Letters).

The wait commands seems to block everything but i somehow need a delay between the two states, with the ability to scan inputs.

What i can do to avoid that is to change my one-press-function to a press and hold function (Press and hold r-button to resume, or so) than everything is fine, but that should be not the solution.

Login to post a reply

Server time is: 2026-07-21 18:57:47
Your offset time is: 2026-07-21 18:57:47