Results 1 to 13 of 13

Thread: is this a bug or what?!!!!!

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    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:
    1. Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    2.         Dim gr As Graphics = e.Graphics
    3.         Dim rect As New Rectangle(100, 100, 10, 10)
    4.         gr.DrawRectangle(Pens.Cyan, rect)
    5.     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!!

  2. #2

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    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!!

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  4. #4
    Member
    Join Date
    Oct 2002
    Location
    la la la you can't see me
    Posts
    46
    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?!

  5. #5
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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.

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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?

  8. #8

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    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!!

  9. #9
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261
    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!

  10. #10

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    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!!

  11. #11
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261
    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.

  12. #12
    Member
    Join Date
    May 2001
    Location
    Adelaide, Australia
    Posts
    51
    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?
    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>
    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

  13. #13

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    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
  •  



Click Here to Expand Forum to Full Width