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.

Author
Message
jayell leedham
20
Years of Service
User Offline
Joined: 24th Jan 2006
Location: North Yorkshire
Posted: 21st Jul 2010 11:13
set display mode 640,480,32
create bitmap 1, 640,380
SET CURRENT BITMAP 1
ink rgb(255,255,255),rgb(0,0,0)
line 10,380,630,380
copy bitmap 1, 0
wait key
end

does not work! Changing to line 10,379,630,379 does.
Why is that please?
sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 11:21
Screen coordinates start at 0 so for 640 x 380 resolution the range is from x = 0 to 639 and y = 0 to 379.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2010 11:51
I think you have to allow for the extra pixel though, so if you want to grab that bitmap as an image:

GET IMAGE 1,0,0,640,380

Rather than 0,0,639,379 - if you grabbed a single pixel like this 10,10,10,10 then the image would contain nothing, you'd have to use 10,10,11,11. It's kinda weird, but not too insufferable.


Health, Ammo, and bacon and eggs!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2010 12:10
Quote: "It's kinda weird, but not too insufferable."

Makes sense to me, you would expect a rectangle starting at 0,0 and ending at 10,10 to be 10 units by 10 units, so why shouldn't something 10,10 to 11,11 be one unit by one unit?

11-10=1... simples

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 12:22
Seems inconsistent to me.

Baxslash: Flawed logic there because in math operations 0 has no value, in coordinates it has. But I'm just being pedantic.

As Van B said you have to allow for the extra pixel with get image. In the example below why is the bottom right pixel of the box missing when they both end at 9,9?

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2010 12:46
Quote: "Flawed logic there because in math operations 0 has no value, in coordinates it has. But I'm just being pedantic"


11-10=1 so a rectangle 10,10,11,11 would be 1x1
1-0=1 so a rectangle 0,0,1,1 would also be 1x1...

Where was my logic flawed? What has zero having no value have to do with it?

You were being pedantic yes but I don't understand your point?

An argument without a point also has a value of zero...

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 12:51
How many pixels would be lit for a line going from 0,0 to 1,0?
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2010 12:54
0-0=0
1-0=1
1x0=0 answer
[/logic intact]

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 13:00
Ok, forget everything I just said lol, You are 100% correct.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2010 13:03
No worries, I thought I was going slightly crazy!

I had an issue with lines and boxes and "get image" for my space invaders comp entry so I wasn't 100% certain for a while there...

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 13:12
Me too. Using coordinates if you draw a line on graph paper by filling squares (equating to pixels) from 0,0 to 0,1 then you will fill 2 squares. I just tried it on dbpro and it dosent fill the last pixel which in my book is wrong, because in my earlier example drawing a box by using lines the corner is missing! I guess there is some reason for that, but I would expect it to inclusively fill the pixels from the start to the end coordinates.

p.s. Can I just apologise to jayell for >totally< hijacking his thread.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Jul 2010 13:15 Edited at: 21st Jul 2010 13:17
@baxslash
Your formula makes no sense

A line going from 0,0 to 1,0 will light exactly 1 pixel (try it)

The reason for this is that the line command draws every pixel on the line except for the very last one. This is a feature of Direct3D which is by default enabled, so that if you draw multiple connected lines, you don't draw pixels multiple times.

A box going from 0,0 to 1,1 will light exactly 1 pixel.

The reason for this is similar. The box command lights every pixel inside the box, except for the bottom row and the right column. This is also a feature of Direct3D so that if you draw multiple boxes next to each other, they don't overlap.

This actually happens with all drawing in Direct3D. The triangles which make up 3D objects do not draw their bottom right edge(s). The 'box' command actually uses 4 triangles (used to be 2, but it made the colour transition behave oddly) to draw itself.

http://msdn.microsoft.com/en-us/library/bb147314.aspx

[b]
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2010 13:43 Edited at: 21st Jul 2010 13:44
Quote: "
@baxslash
Your formula makes no sense
"

It does, I just didn't explain it very well...

...using algebra I was writing it as follows:

where sx,sy= start x,start y and fx,fy=finish x,finish y
fy-sy=dy [0-0=0]
fx-sx=dx [1-0=1]
dx*dy=ar [1x0=0]

EDIT: ar=area

Perhaps I should have been more explicit, sorry.

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 14:10 Edited at: 21st Jul 2010 14:12
So if area=0 how come you can see a single pixel? That was my point about 0 in coordinates and 0 in maths. In your original example I would expect a rectangle starting at 0,0 and ending at 10,10 to have dimensions of 11 pixels by 11 pixels. But it seems it DOES have dimensions of 10x10 because directX dosen't draw the last pixel.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2010 14:26
Quote: "So if area=0 how come you can see a single pixel?"

Show me some code for this. When I use:


I don't get anything...

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2010 14:38 Edited at: 21st Jul 2010 14:48
Maybe this small illustration will help:


The box starts at 0,0 and finishes at 2,2. It is therefore 2 units wide by 2 units high. How does that not make sense?

EDIT: I just noticed that sladeiw said "line" earlier, my mistake I was still talking about boxes diggsey...
Quote: "How many pixels would be lit for a line going from 0,0 to 1,0? "


That explains why none of this was making sense...

I guess a good way of difining the difference between "line" and "box" is that box works on a 'co-ordinate' system while line works on a 'pixel to pixel' system...

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 15:12
Quote: "The box starts at 0,0 and finishes at 2,2."


Only because directX dosen't draw the last pixel, as explained by Diggsey. Your illustration includes pixels at coordinates:
0,0
1,0
0,1
1,1

Notice no pixels at 2,2 so it cannot finish at 2,2!
It is 2 units wide & high, but it finishes at coordinates 1,1.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2010 15:25
I guess it's probably a pain for DX to deal with boxes with no width or height. Like DOT 10,10 will put a dot at 10,10 - but BOX 10,10,10,10 will do nothing, because it's width and height are nothing - perhaps it needs some sort of width/height to even start drawing. It's probably a happy convenience that a box would automatically skip it's bottom and rightmost lines, they probably did the box drawing first and the ruleset just stuck.


Health, Ammo, and bacon and eggs!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2010 15:29 Edited at: 21st Jul 2010 15:31
Maybe it just isn't as obvious to you as it is to me. To me it makes sense as it is... I give up trying to explain the logic of it as you seem unprepared to accept it.

Quote: "Men are apt to mistake the strength of their feeling for the strength of their argument. The heated mind resents the chill touch and relentless scrutiny of logic."


EDIT: Or like Van B said...

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 15:43
Quote: "I give up trying to explain the logic of it as you seem unprepared to accept it."


I could say the same thing! In practice (as in what appears on the screen) you are correct and that's all that matters really.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jul 2010 16:36
Sorry, yes you could say the same thing too I agree

I wasn't saying you were wrong, you are right of course because it doesn't make sense when you look at it the way you are looking at it! I was just trying to explain another way I look at it that does make sense!

Sorry to @jayell leedham for this too! This is my last word on the subject:

If you forget that you are looking at solid pixels and think of it as a grid like a sheet of graph paper made up of lines, then draw a square that starts at point 0,0 and is drawn out to point 2,2 (like my previous image) it fills in four squares (2x2).

I really hope you don't think I'm trying to get 'one-up' on you, I'm not. I just wanted to explain how I remember to use the command correctly on the off chance it might help someone. I hope you understand my logic this time @sladeiw but if not then I'm sorry, maybe it will help someone else.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jul 2010 17:01
Quote: "Flawed logic there because in math operations 0 has no value, in coordinates it has. But I'm just being pedantic."


Pedantic and wrong. Zero has a value in maths - the value zero of course.

Regarding the line and get image issues, I tend to agree with those who think the DBPro implementation is confusing (especially if you read the Help files). The subtleties of DirectX should be kept firmly in the background. There really is no good reason why the line command, for example, shouldn't include the final point (as implied by the Help file) - similarly with the get image command.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2010 17:24
Yeah, this thread hold testament to that! - I mean we wouldn't be discussing this if it was more predictable. 2D isn't exactly DBPro's strong point anyway, but I think that they could do better with what they have, maybe allow easier alpha colouring, built in AA. One thing I would really like to see is better image quality controls.

Going between OpenGLES on the iPhone, and DBPro sprites - OpenGLES kills it, I mean rotate a DBPro sprite and it looks ugly as hell in comparison, GL sprite rotation does a much prettier job of it. Post processing AA is not the answer, I'm thinking about 2D games for netbooks, not desktop PC's with monster GFX cards just to paste some sprites that don't look like burnt lego the minute you rotate them.

Rant over - felt good.


Health, Ammo, and bacon and eggs!
sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Jul 2010 17:33
Quote: "I really hope you don't think I'm trying to get 'one-up' on you, I'm not. I just wanted to explain how I remember to use the command correctly on the off chance it might help someone. I hope you understand my logic this time @sladeiw but if not then I'm sorry, maybe it will help someone else."


I don't think that at all, and I'm not ignoring what you are saying! This is just discussion and pretty much what a forum is for! Peace
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 21st Jul 2010 18:05
Just thought I'd let you know, you can't copy a bitmap that is smaller or larger than the bitmap your copying to, well the root bitmap anyway (haven't tested others). They have to be the same size or you'll have to use the extra COPY BITMAP params.

Your error:


So set the bitmap to the resolution of the bitmap your copying to, so in this case the screen resolution:


A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jul 2010 23:53
Quote: "you can't copy a bitmap that is smaller or larger than the bitmap your copying to"


Not true when it's smaller. I do it all the time. Try it.
jayell leedham
20
Years of Service
User Offline
Joined: 24th Jan 2006
Location: North Yorkshire
Posted: 22nd Jul 2010 01:19
Wow! who would have thought my innocent question would attract such a flurry of activity.
Thanks for all your contributions, particularly the first reply, pointing out what the numbers of the edge pixels are.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 22nd Jul 2010 03:12
Quote: "Not true when it's smaller. I do it all the time. Try it."


Woops, Yeah your right, looking back now, I totally got confuse on what was being said here. Anyway, I swear I had issues with bitmaps a while back, wonder if the recent update corrected this.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.

Login to post a reply

Server time is: 2026-07-25 05:32:48
Your offset time is: 2026-07-25 05:32:48