|
-
Oct 5th, 2002, 11:06 PM
#1
is this a bug or what?!!!!!
This is driving me crazy!!!!
If you try to draw a rectangle of any size with GDI+, it will draw a rectangle that is one pixel larger in height and width!!!!
try it yourself!
VB Code:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim gr As Graphics = e.Graphics
Dim rect As New Rectangle(100, 100, 10, 10)
gr.DrawRectangle(Pens.Cyan, rect)
End Sub
I took a screen shot and examined the drawn rectangle in ms paint. it's SUPPOSED to be 10x10 pixels, but it's 11x11!!!!!!!! it does the same thing for any other value
DOESNT MAKE SENSE!!!
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 5th, 2002, 11:27 PM
#2
AAAA!!! I dont get it
This ONLY happens if penwidth is set to 1, I tried different penAlignments, but it doesnt work
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 6th, 2002, 01:16 AM
#3
Whle we are on the subject of bugs sometimes the Edit Name part of the Main Menu control doesn't work. It shows that they are changed on the menu but then they aren't and it resets if you go away from that part and back again.
-
Oct 6th, 2002, 09:35 AM
#4
Member
this might be a shot in the dark, but i've noticed that with some things, like arrays, vb likes to start at 0, not 1. maybe that's the problem.
What does "formatting drive C..." mean?!
-
Oct 6th, 2002, 10:10 AM
#5
Fanatic Member
Originally posted by Edneeis
Whle we are on the subject of bugs sometimes the Edit Name part of the Main Menu control doesn't work. It shows that they are changed on the menu but then they aren't and it resets if you go away from that part and back again.
Unrelated to the rectangle problem but yeah, I have seen wierd behavior working with the menu editor as well. In fact the only times the IDE has ever crashed on my machine was when I was doing things with the menu editor like moving menuitems with drag/drop.
-
Oct 6th, 2002, 11:07 AM
#6
Good Ol' Platypus
White_As_Snow is exactly correct. The way that the new language works, when you set the size of an array, you're actually setting the upper bound, where the lower bound MUST BE 0. Thus, an 'array' of pixels that has a bound of 10 will be 0 to 10:
0 1 2 3 4 5 6 7 8 9 10
Count them yourself, there's 10 of them. Too bad.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 6th, 2002, 05:34 PM
#7
But he isn't making or using an array. He is setting the size of a Rectangle. I think it has to do with the penwidth being included in the rectangle size, why not just -1 it?
-
Oct 6th, 2002, 08:12 PM
#8
Originally posted by Edneeis
But he isn't making or using an array. He is setting the size of a Rectangle. I think it has to do with the penwidth being included in the rectangle size, why not just -1 it?
oh well I could -1 the size of rectangle I guess, but this is dumb!

also I needed something else: I want to draw one single pixel on a certain location. I tried to make a rectangle of size 1,1 but that would draw a rectangle of size 2,2
Dont know how I could do this is there anything like SetPixel?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 6th, 2002, 08:13 PM
#9
Hyperactive Member
That does seem like a bug. You say it only happens when penwidth is set to 1?. Do you have SP1 of the framework? Maybe that would fix it!
I wonder if its a problem with the Pen object. Aren't there 20+ other overloaded Graphics.DrawRectangle methods? Try using one that doesn't use a pen!
-
Oct 6th, 2002, 08:20 PM
#10
Originally posted by Hu Flung Dung
That does seem like a bug. You say it only happens when penwidth is set to 1?. Do you have SP1 of the framework? Maybe that would fix it!
I wonder if its a problem with the Pen object. Aren't there 20+ other overloaded Graphics.DrawRectangle methods? Try using one that doesn't use a pen!
the weird thing is that there are only 3 overloaded methods
and yeah it only happens with penwidth set to 1. I have SP2, aint fixed 
btw anyone else tried this? I put the code in the first post.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Oct 6th, 2002, 08:27 PM
#11
Hyperactive Member
Originally posted by MrPolite
oh well I could -1 the size of rectangle I guess, but this is dumb!

also I needed something else: I want to draw one single pixel on a certain location. I tried to make a rectangle of size 1,1 but that would draw a rectangle of size 2,2
Dont know how I could do this is there anything like SetPixel?
There is a SetPixel method in the Bitmap object! You could draw all of your graphics on that, then draw the bitmap onto a form or control (You can also use Graphics.FromImage to get a graphics object for it, so you can draw some pretty complex stuff on the Bitmap if you need to)!
Also, as I've said, you dont have to use pens when drawing rectangles!
If you have any more questions about graphics in .NET, ask me! I am currently making a heavily graphical game as my first .NET project!
EDIT:
Sorry, Just checked, there are only 3 DrawRectangle procedures, all of which use pens! I'll go see how to fix these probs next time I have the chance!
Last edited by Hu Flung Dung; Oct 6th, 2002 at 08:37 PM.
-
Oct 8th, 2002, 03:20 AM
#12
Member
Matthew Draper
[email protected]
"Genius may have its limitations, but stupidity is not thus handicapped." - Elbert Hubbard
"I like long walks, especially when they are taken by people who annoy me." - Noel Coward
-
Oct 8th, 2002, 04:57 PM
#13
Originally posted by Matthew Draper
Without having tried it... don't you need to create a rectangle of size 0, 0 for one pixel?
And for a rectangle which measures 10 pixels wide, use 9, 9, etc?
<disclaimer>I haven't touched any graphics in .NET yet, so you should probably completely ignore this entire post </disclaimer>
no, aint like that
and as I said, it works fine if the penwidth is anything other than 1 pixel. So it should be a problem with 1 pixel-think borders only
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|