Prev: URGENT
Next: DataRow InsertAt Database
From: Loren Pechtel on 4 Nov 2009 15:15 On Tue, 03 Nov 2009 23:02:14 -0800, Peter Duniho <no.peted.spam(a)no.nwlink.spam.com> wrote: >Loren Pechtel wrote: >> [...] >> The behavior would make sense if somehow I was drawing between pixels >> on the y axis but all the DrawLines are being fed integer coordinates. > >With no scaling/transformation whatsoever? And you are displaying the >images also without any scaling or transformation of any sort? How are >you determining what the exact pixel values are? > >Your description sounds as though you're drawing on fractional >coordinates, in spite of your statement that you're not. But it's also >possible you're simply not gathering your data correctly and that the >pixels in the bitmap aren't what you think. I agree it sounds exactly like fractional coordinates. How do you draw on fractional coordinates with integer variables, though? There is no float variable in any routine in the file that actually draws anything.
From: Peter Duniho on 4 Nov 2009 15:30 Loren Pechtel wrote: > I agree it sounds exactly like fractional coordinates. How do you > draw on fractional coordinates with integer variables, though? [...] By drawing in an environment where coordinates given as integers are scaling somehow. I posted a code example that shows that in general, the problem you describe does not occur. Either your own code does something different, or you are simply not observing the results correctly (i.e. you think there's a problem when there's not). In the latter case, obviously there's nothing to fix. In the former case, until you post a concise-but-complete code example that reliably demonstrates the issue, there's no way to tell you how to fix your code. Pete
From: Jeff Johnson on 4 Nov 2009 17:41 "Loren Pechtel" <lorenpechtel(a)hotmail.invalid.com> wrote in message news:%23edaYuQXKHA.1280(a)TK2MSFTNGP04.phx.gbl... > I'm having trouble with what seems to be a simple task: > > I'm trying to draw some vector images on a field of tiles. The tiles > are always of integer sizes and can zoom over any reasonable range of > values. > > The images themselves are vector images but they don't simply scale > up, as the tile gets bigger more detail is added. (Yeah, I know I'll > have to handle printing a bit differently.) > > The problem I'm having is with images composed entirely of vertical > and horizontal lines, black on a gray field. > > The horizontal lines are fine, I get exactly what I want. Vertical > lines aren't working too well, though. A lone vertical line is good > enough--two pixels of dark gray instead of one of black but it looks > close enough I didn't even realize it was wrong until I got digging > into the case that's awful: > > I have some stripes, some are black/background/background and others > are black/background. > > With antialiasing on the ones with the black every three look fuzzy > and the closer ones just look like a blurry blob. > > With it turned off I'm getting a very clear image, albeit very wrong: > The three-step one produces dark gray/dark gray/background and the > two-step one simply produces a box of dark gray. > > Everything is being drawn on a bitmap that is then put in a > picturebox. The picturebox is in a panel that fills the form other > than a few controls on the right for manipulating the view. > > The behavior would make sense if somehow I was drawing between pixels > on the y axis but all the DrawLines are being fed integer coordinates. I have to ask: are you absolutely positive you're actually getting different-colored pixels, or does it just LOOK that way. In other words, have you saved your bitmap to disk and then loaded it into a graphics application and increased the zoom so that you can see the individual pixels?
From: Peter Duniho on 4 Nov 2009 18:28 Jeff Johnson wrote: > I have to ask: are you absolutely positive you're actually getting > different-colored pixels, or does it just LOOK that way. In other words, > have you saved your bitmap to disk and then loaded it into a graphics > application and increased the zoom so that you can see the individual > pixels? To elaborate on this point: the code example I posted last evening is specifically designed to illustrate this point. It provides for scaling the image during presentation, as well as inspecting RGB values for any specific pixel. With the example, you can see that scaling the image by (for example) 200%, you get the aliasing behavior described by the OP, but the pixel values are still exactly as he wants (i.e. 0,0,0 RGB where a black line is drawn, 128,128,128 on the gray background where it wasn't). Pete
From: Loren Pechtel on 4 Nov 2009 20:17
On Wed, 04 Nov 2009 12:30:56 -0800, Peter Duniho <no.peted.spam(a)no.nwlink.spam.com> wrote: >Loren Pechtel wrote: >> I agree it sounds exactly like fractional coordinates. How do you >> draw on fractional coordinates with integer variables, though? [...] > >By drawing in an environment where coordinates given as integers are >scaling somehow. > >I posted a code example that shows that in general, the problem you >describe does not occur. Either your own code does something different, >or you are simply not observing the results correctly (i.e. you think >there's a problem when there's not). > >In the latter case, obviously there's nothing to fix. In the former >case, until you post a concise-but-complete code example that reliably >demonstrates the issue, there's no way to tell you how to fix your code. I managed to reproduce it very easily: A form containing a panel that contains a picture box. Drawing: Bitmap Image = new Bitmap(Box.ClientSize.Width ,Box.ClientSize.Height); Pen Ink = new Pen(Color.Black, -1); using (Graphics Paper = Graphics.FromImage(Image)) { Paper.Clear(Color.LightGray); for (int x = 2; x < Image.Width / 2; x += 2) Paper.DrawLine(Ink, x, 0, x, Image.Height - 1); for (int y = 2; y < Image.Height; y += 2) Paper.DrawLine(Ink, Image.Width / 2, y, Image.Width - 1, y); } Box.Image = Image; Obviously the panel in this case is useless but I simply copied the layout from the main code--in the main code there are some controls off to the side and I use the panel to make the picture box take up the whole form. This code *SHOULD* draw one half of the screen with vertical lines and one half with horizontal. I'm getting a gray mass on the left and the expected behavior on the right. |