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.

Newcomers DBPro Corner / Loading/saving in Paint Program.

Author
Message
Acolyte Entertainment
19
Years of Service
User Offline
Joined: 28th Dec 2004
Location: Oregon, US
Posted: 2nd Dec 2005 07:13 Edited at: 2nd Dec 2005 07:14
i have searched all over on how to save/load an image after you make it in my paint program. here is my program.

i know i am asking alot but i really hope somehow i can get my hands on the save/load.

Everyone starts a noob. so lets not laugh at our younger souls.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 2nd Dec 2005 10:34
In classic you can use the "save bitmap" command to save the screen.

Acolyte Entertainment
19
Years of Service
User Offline
Joined: 28th Dec 2004
Location: Oregon, US
Posted: 2nd Dec 2005 16:27
yeah im using DBP though =(

Everyone starts a noob. so lets not laugh at our younger souls.
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 2nd Dec 2005 16:37
Use GET IMAGE to grab contents of screen and then SAVE IMAGE

Boo!
Acolyte Entertainment
19
Years of Service
User Offline
Joined: 28th Dec 2004
Location: Oregon, US
Posted: 3rd Dec 2005 00:45
yeah but when i use get image i get error

Everyone starts a noob. so lets not laugh at our younger souls.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Dec 2005 01:25 Edited at: 3rd Dec 2005 01:28
Quote: "yeah but when i use get image i get error"


There's probably 2 reasons why you get an error. First it doesn't look like you know what coordinates to use... and there's an error in saving some formats (with the latest update of Pro).

This line in your code:


Should be this:


The default size of the screen is 640x480. The first number in a screen coordinate is usually refered to as X which goes from left to right. The second is Y which goes from the top to the bottom. The upper left corner is 0,0... the lower right corner is 640,480.

Here's the way the screen is divided:

0,0--------------640,0
|
|
|
|
0,480------------640,480

So if you wanted to place a dot in the center of the screen you type "dot 320,240".

Now using this information the image you want to save starts at 161,0 and ends at the corner of the screen 640,480.

The image format for save image should allow .bmp, .jpg, .dds, and .dib (I don't have a .dds and .dib loader so those may work) but only 1 in that list works... .jpg and .png works (even though it doesn't have .png listed). Since .jpgs are the worst kind to use... stick to .png saves.

Acolyte Entertainment
19
Years of Service
User Offline
Joined: 28th Dec 2004
Location: Oregon, US
Posted: 3rd Dec 2005 07:37
thx. ill give it a try

Everyone starts a noob. so lets not laugh at our younger souls.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Dec 2005 09:23
Grog Grueslayer,

Sorry, but I have to give some comments:

1)
Quote: "LINE 160,0,0,1000000"

when a coordinate from a line goes out of the screen, the line will be drawed anyway. line 0,10,0,639 will display the same as 0,10,0,10000.

2)
Quote: "The default size of the screen is 640x480. The first number in a screen coordinate is usually refered to as X which goes from left to right. The second is Y which goes from the top to the bottom. The upper left corner is 0,0... the lower right corner is 640,480. "


This is a contradiction. You say the screen size is default 640X480, starting from 0,0. However, this means the most right-bottom coordinate is 639,479 and not 640,480.

A simple test would be:

You see the dot is not displayed.

However:

The dot is displayed.

3)
The reason why it is giving an error is probably lying with the "get image" command. Unlike the 2D-commands, this gives an error when a coordinate lies off the screen.

An important note is that the maximum coordinates is not 639,479 but 640,480. However, the data on X=640 and Y=480 are not stored in the image.

A simple test:


I hope this clears some things.

Immunity and Annihalation makes Immunihalation...
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Dec 2005 11:09 Edited at: 3rd Dec 2005 11:11
Quote: "Sorry, but I have to give some comments:"


Did I sound too harsh?... is that why you want to nit-pick?

Quote: "when a coordinate from a line goes out of the screen, the line will be drawed anyway. line 0,10,0,639 will display the same as 0,10,0,10000."


Of course... that is why it worked. But because he used a million for the y coordinate on a line statement it told me he had no idea about the screen sizes. Which was confirmed when he said that using "get image" gave him an error. His line statement appeared to work fine because he used such a high number the line was straight.



Quote: "This is a contradiction. You say the screen size is default 640X480, starting from 0,0. However, this means the most right-bottom coordinate is 639,479 and not 640,480.

The reason why it is giving an error is probably lying with the "get image" command. Unlike the 2D-commands, this gives an error when a coordinate lies off the screen.

An important note is that the maximum coordinates is not 639,479 but 640,480. However, the data on X=640 and Y=480 are not stored in the image."


Again you are right. I talked about the default screen size as being 640x480 because that is what we normally say... regardless of the last columns and rows of pixels being seen.

When you want to change the screen size do you type?


Or do you type?


It is second nature to use the above code snip for screen sizes because we have grown up saying them out loud and using those numbers in programming.

So which is better? Letting him continue to think that using 1000000 for a Y coordinate is acceptable or telling him about the screen limits using screen size numbers that have been established long before Darkbasic existed? Pointing out the actual limits although right is just semantics.

Besides... I didn't make this thread and call it "Grog's Screen Tutorial For Newbies".
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Dec 2005 11:39 Edited at: 3rd Dec 2005 11:40
Quote: "Sorry, but I have to give some comments:"


It's never fun be corrected (in my opinion).

Quote: "Again you are right. I talked about the default screen size as being 640x480 because that is what we normally say... regardless of the last columns and rows of pixels being seen."


Well, it is kinda "extra work" for the pc to draw such a long line. But I thought you said it was 1 of the 2 reasons of the error.

Now I read it again and I see you're point is that he doesn't know how to use coordinates

So the points are:
Try not to define coords out of the screen.
Don't use buggy extensions for saving.
And finally, this thread isn't called "Grog's Screen Tutorial For Newbies"

Quote: "Quotes, quotes, quotes..."


And good luck with your programme...

Immunity and Annihalation makes Immunihalation...
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Dec 2005 12:07 Edited at: 3rd Dec 2005 12:29
Quote: "It's never fun be corrected (in my opinion)."


I wasn't offended or anything... it takes a lot to offend me.

You're still on my cool people list.

Quote: "
Try not to define coords out of the screen.
Don't use buggy extensions for saving.
And finally, this thread isn't called "Grog's Screen Tutorial For Newbies"
"


Yup, yup, and a big yup. I won't be qualified to write tutorials till at least a few more hours... er I mean years.
MonoCoder
18
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 4th Dec 2005 17:11
If you want to get pixels off an area of the screen, here is a fairly long way round it...
1. Make an array that has two parts, the size of the x and y axis. For example, in a program with a resolution of 640x480, use this array, remembering that the zeros count too: pixels(639,479)
2. Then lock the screen, use the for and next commands to write the colors of all the pixels into the array, and then unlock the pixels, like this:



3. Then save the array with:



err... so that's it. But if you want a bitmap file, this is all little or no use. gaah. But if at the moment you are having trouble with your computer saving out bitmaps, keep these .dat files safe, you can reload them when bitmap saving works.

If noone has this problem, then at least you can use these .dat files for your own kind of painting program, I dunno.

I sit, I write, I create quality code, and what is my reward? Windows errors. Oh. Great.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Dec 2005 04:57
DBC is well known for having inconsistencies with screen co-ordinates - most caused by the faulty Box and Get Image commands.

What's more, it's annoying that they still haven't been addressed in DB Pro.

The main cause of the problem is that the Box command doesn't do what you tell it to.

There are 800 pixels across the screen and 600 down in 800x600 screen mode. The top left corner pixel is 0,0 and the bottom right corner pixel is 799,599.

But the following code doesn't do what it should:

CLS RGB(255,0,0)
Ink 0,0: Box 0,0,799,599
Wait Key

Try it in 800x600 screen mode and you will see red lines down the right side and across the bottom which shouldn't be there.

The confusion arises when you use the box command with Get Image to create buttons - especially if you aren't aware that Box always draws one less pixel across and down than it should.

The same bug is with the Get Image command:

Ink RGB(255,255,255),0: Box 0,0,799,599
Ink RGB(0,0,200),0: Box 1,1,798,598
Get Image 1,0,0,799,599
CLS 0
Paste Image 1,0,0
Wait Key

When you run this, it creates a blue box with a single pixel white border, but if you save the image grabbed you will see that the far right column and bottom row of pixels are unused.

As box and Get Image are both one pixel out on the X and Y, using the same values means you end up grabbing what you drew - the trouble is that it isn't what you wanted!

Draw a box with the line command and use the same screen co-ords to grab it with Get Image.

This is why to grab the whole screen, you have to use:

Get Image 1,800,600

...when there isn't actually a pixel column 800 or row 600 on the screen!

TDK_Man

spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 8th Dec 2005 10:45
TDK is correct but answer needs a bit of correcting.

To correctly grab a screen 800*600 and make sure it's pixel perfect you have to utilise the 'texture' flag of the GET IMAGE command, so it should be;

GET IMAGE 1,0,0,800,600,1

If you don't include that magical ,1 on the end the resulting image will be blurry

Boo!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Dec 2005 19:48 Edited at: 8th Dec 2005 19:48
I didn't forget about the 1 on the end - I just left it off so it applied to both DBC and DB Pro.

In DBC, without the 1 parameter the image isn't blurry and the missing pixel effect is shown.

In DBPro, without the 1 parameter the image is blurry, but the effect is still shown. Well I hoped anyway!

TDK_Man

Login to post a reply

Server time is: 2024-09-24 11:29:00
Your offset time is: 2024-09-24 11:29:00