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.

Dark GDK .NET / Clearing a bitmap

Author
Message
aerostudios
14
Years of Service
User Offline
Joined: 20th May 2009
Location: Oklahoma City OK (USA)
Posted: 3rd Nov 2011 18:44 Edited at: 3rd Nov 2011 19:14
Okay, I'm baffled here. But I am using a bitmap/sprite to output a text window overlay on my 3d world. I set the bitmap to be current, draw text on it, then create a sprite of it. For some reason, I can't figure out how to clear the bitmap area before I draw new text on it. Is there an equivalent CLS() command for the bitmap from the DBPro command set in the DarkGDK?

here is my original DB PRO code:



Russell B. Davis/aerostudios
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 6th Nov 2011 04:30
I use a similar method for some of my windows in DGDK.NET and VB. It was a while ago but I remember having problems with the Cls command and the current bitmap. As a temporary workaround, consider pasting a blank image or using the box command to fill the area; or use a seperate bitmap and sprite for the text and background respectively.

Something else just in-case you did not know; in DBPRO and the GDK, camera bitmaps can be drawn on aswell; the same as drawing to bitmap 0 for camera 0; so, camera 1 uses bitmap -1, camera 2 uses bitmap -2 etc. The camera can then be shown as a small view; or rendered to an image. I have not used cameras for UI, but it is good to know about this option if bitmap work gets to laggy.

aerostudios
14
Years of Service
User Offline
Joined: 20th May 2009
Location: Oklahoma City OK (USA)
Posted: 6th Nov 2011 16:53
thanks Chris, I'll give the paste image command a try. I hadn't thought of that. Even creating a blank bitmap and then copying it doesn't work to clear the bitmap I am writing text to.

Russell B. Davis/aerostudios
aerostudios
14
Years of Service
User Offline
Joined: 20th May 2009
Location: Oklahoma City OK (USA)
Posted: 7th Nov 2011 23:34 Edited at: 8th Nov 2011 00:05
Boy, I am really baffled here. I created a blank BMP that is 512x256 and is black. I thought I could load that BMP and use the bitmap.COPYTO command to clear the bitmap I am writing text to. I am creating a sprite of the text so it can be moved wherever the user wants to place it. That's the last step of my code.

Here is my code:



Everything appears fine until I reach the 10th item.
Then, next text is pasted over the previous lines of text.
You can see the before and after effects. What I am doing wrong? since the CLS command is not available in the Dark GDK.NET

I tried using an image instead and it didn't have an effect either.
If I fill the background with a color other than black, that works.

Could it be that since the BlankBMP is filled with rgb(0,0,0), and that is used as the transparent color, is it simply not doing anything via the COPYTO command? rather, those bytes are simply ignored?

Russell B. Davis/aerostudios

Attachments

Login to view attachments
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 8th Nov 2011 00:12 Edited at: 8th Nov 2011 00:13
It appears so, the blank bitmap may not be pasting any pixels; due to being transparent. Save the bitmap to file to see.

The concept only works when the bitmap overrides previous text pixels with new backdrop pixels; to go underneath the new text.

If changing the background does not work, you may need to try pasting an opaque image, or deleting and creating a new bitmap when the text changes.

If that fails and you are good with bitmap memblocks then consider taking full control of the bitmap pixels by setting them. Unfortunately that is as far as you can go with DGDK with all the fancy DBPRO plugins.

aerostudios
14
Years of Service
User Offline
Joined: 20th May 2009
Location: Oklahoma City OK (USA)
Posted: 8th Nov 2011 00:25 Edited at: 8th Nov 2011 00:29
thanks Chris. Yeah, I may have to resort to taking control of the pixels. I tried to first clear the background with green, and then use the SetColorKey(Color.Green) command before grabbing the image. If I didn't use the SetColorKey(Color.Green),then the background remained green and my text appeared to scroll upward, as it should. But, then I tried the SetColorKey(Color.Green) and the problem returned. I like the HUD style text reporting systems, and have plans to do more. So I may not have any choice but to work directly in memory. I appreciate your help.

And you realize that I am using VS2010-VB.NET. I didn't have this issue using native DB Pro, because it has the CLS command. So I hope the bitmap example using MAKE MEMBLOCK doesn't have similar issues in VB.NET. that would suck..

Russell B. Davis/aerostudios
aerostudios
14
Years of Service
User Offline
Joined: 20th May 2009
Location: Oklahoma City OK (USA)
Posted: 15th Nov 2011 00:39 Edited at: 15th Nov 2011 00:55
I solved my own issue. So I've decided to share my technique with anyone else wanting to have a textual display with a transparent background. This also provides shadowed text.

Here is my subroutine in VS2010 (VB.NET):

1. Commback is a blank 512x256 bitmap
2. CommWindow is my foreground bitmap created from Commback
3. Commout is the captured image AFTER writing text to the CommWindow. This happens twice; first after the blank bitmap is copied, and then after text is written to it.
4. sprite_comm is deleted first before being recreated from Commout.
5. sprite_comm is then positioned onscreen.



the key was knowing when to paste the blank bitmap.

In my example, the bitmap is centered on the screen, right below the game logo icon. The bitmap window size is 512x256. The variable "ControlObject" is derived/set by detecting sprite collisions. I am using an array (RADIOLOG) of 12 lines of text for output that appear to scroll upward out of view as new messages are sent to the routine. I created "MyColor" for the shadow. The shadow is produced by outputting the same line of text using "MyColor" at an offset of 2 pixels in both the X/Y direction. Then, the next output is using either Yellow or Cyan at the default X/Y location which is controlled by the first word being either "TWR:" or "CODE:" The word "CODE:" is used when I want to output something dealing with the programming for debug purposes. Otherwise, this display is used to show game dialog.

this is nothing new in terms of programming, but it has been troublesome using the Dark GDK.NET library. So, I wanted to share my solution with others who are trying to accomplish the same thing. Have fun!

Russell B. Davis/aerostudios

Login to post a reply

Server time is: 2024-04-16 07:28:07
Your offset time is: 2024-04-16 07:28:07