I have a panel with an UltraPictureBox in my WinForms application for annotating selections; when the user clicks an item I draw text or a picture to the box. This works great with pictures, but when I draw text it appears blurry with little jags in it. It looks like the text has been shrunken ever so slightly.
I am creating a Graphics canvas the size of the pictureBox content area to draw my text, how can this be a different size? The code is like:
Bitmap detailImage = new Bitmap(_ultraPictureBox.ClientSize.Width, _ultraPictureBox.ClientSize.Height);using (Graphics g = Graphics.FromImage(detailImage)){ g.FillRectangle(Brushes.Grey, 0, 0, detailImage.Width, detailImage.Height); g.DrawString(annotation, _ultraPictureBox.Font, Brushes.Black, annotationPos);}
The pictureBox is the same size as the ClientSize, and it has no padding, borders, or shadow. Yet if I fill the detailImage above with a color, there is a thin white strip around my image inside the pictureBox. Where is this coming from and how do I get rid of it?
I just tried this and it was working fine for me. Do you get the same result in a new UltraPictureBox with the default properties? Is there anything else that you're doing that could account for this? Do you have the BorderStyle property set? If you have something like one of the rounded styles, this would explain the excess padding.
-Matt
Tried it on a new project, and it worked fine for me as well. It must be something with my original project. But what? BorderStyle is Default for both, Margin is 3, 3, 3, 3. I have found if I use:
Bitmap detailImage = new Bitmap(_ultraPictureBox.ClientSize.Width - 2, _ultraPictureBox.ClientSize.Height - 2);
In both projects that works without scaling. Is there anything other than Borders, Margin, and Padding that affect the ClientSize?
I can't really think of anything else that might affect this area, other than the DrawBorderShadow. The only other thing that I can think of is that something you might be doing is resizing the control, and if you don't have it set to maintain the aspect ratio, it would stretch/squash the image. The only thing that I can think of that would leave spaces on the sides would be the border or border shadow.