TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Akulenko Akulenko
NA
1
0
Bad quality (again)
May 11 2009 2:45 PM
Greetings everyone. I try to print my own control (combination of labels and textfields). I use DrawToBitmap() method but it gives bad quality in result.
I tried to override it (with better quality as i thought):
private void DrawToBitmapEx(Bitmap bitmap, Rectangle targetBounds)
{
int width = Math.Min(this.Width, targetBounds.Width);
int height = Math.Min(this.Height, targetBounds.Height);
Bitmap image = new Bitmap(width, height, bitmap.PixelFormat);
using (Graphics graphics = Graphics.FromImage(image))
{
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
IntPtr hdc = graphics.GetHdc();
UnsafeNativeMethods.SendMessage( (IntPtr)(new HandleRef(this, this.Handle)), 0x317, hdc, (IntPtr)30);
using (Graphics graphics2 = Graphics.FromImage(bitmap))
{
graphics2.SmoothingMode = SmoothingMode.HighQuality;
graphics2.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
graphics2.CompositingQuality = CompositingQuality.HighQuality;
graphics2.InterpolationMode = InterpolationMode.HighQualityBicubic;
IntPtr handle = graphics2.GetHdc();
SafeNativeMethods.BitBlt( (IntPtr)(new HandleRef(graphics2, handle)), targetBounds.X, targetBounds.Y, width, height, (IntPtr)(new HandleRef(graphics, hdc)), 0, 0, 0xcc0020);
graphics2.ReleaseHdcInternal(handle);
}
graphics.ReleaseHdcInternal(hdc);
}
}
but nothing changed. I see pixels on paper. Is there any way to solve this problem? Thnx.
Reply
Answers (
1
)
How to print panel contents in multiple pages in c#
How can I make catch Printing Events?