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 Discussion / Opening and working with bmps

Author
Message
psylent letterz
18
Years of Service
User Offline
Joined: 8th Oct 2006
Location:
Posted: 25th Jan 2007 09:14
I am new to db and I am still confused with how to open and save .bmps

Lets say you want to open a image "myfile.bmp"

then create a second file "newfile.bmp" that is exactly like myfile.bmp but each of the R G B values is incremeted by , lets say, 10

Could someone post a snippet?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Jan 2007 15:26 Edited at: 25th Jan 2007 15:28
Quote: "I am still confused with how to open and save .bmps"


Those are the easy parts!

The Load Bitmap command loads a bitmap to a hidden screen and the Save Bitmap command will save it after you've done what you want with it.

The brightening of the image itself isn't all that difficult - it's just slow. (DB's 2D commands are notoriously so).

If you loop through the pixels in the image, you can use the Point() function to get the colour number of each one. Using the RGBR(), RGBG() and RGBB() functions with that number will give you the red, green and blue values.

Add 10 to each one, then use the new values with Ink and the RGB() function to set the new colour, then use the Dot command to write the pixel in the new colour before moving onto the next one.

Save it and you are done.

On small to medium sized images it should be OK, but with larger ones it might be faster to access the pixel data directly from the bmp file and avoid the 2D commands altogether.

Try it first and see...

TDK_Man

psylent letterz
18
Years of Service
User Offline
Joined: 8th Oct 2006
Location:
Posted: 25th Jan 2007 18:42 Edited at: 25th Jan 2007 18:43
But can you have two or more bmps in memory at once (the original and the "new" one)?
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 25th Jan 2007 20:02
Yes you can.

You can switch between them by using
set current bitmap

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Login to post a reply

Server time is: 2025-05-26 04:56:58
Your offset time is: 2025-05-26 04:56:58