Higher quality bitmap captures C#
I'm capturing a control and printing it out, the control is a panel. This is the code I am using
[CODE]
private Bitmap FImage;
private Bitmap PImage;
private Point p;
private int width = 0;
private int height = 0;
private void PrintDoc_PrintPage(object sender, PrintPageEventArgs e)
{
OverPanel.AutoSize = true;
int x = 0;
int y = 0;
int width = OverPanel.Width;
int height = OverPanel.Height;
Rectangle bounds = new Rectangle(x,y, width, height);
PImage = new Bitmap(width, height);
OverPanel.DrawToBitmap(PImage, bounds);
p = new Point(0, 0);
label1.Text = width.ToString() + " " + height.ToString();
int bound1 = 0;
int bound2 = 0;
float boundsH = e.Graphics.VisibleClipBounds.Height;
float boundsW = e.Graphics.VisibleClipBounds.Width;
float boundsS = e.PageBounds.Height;
float boundsE = e.PageBounds.Width;
float CBound1 = boundsS - boundsH;
float CBound2 = boundsE - boundsW;
float boundHD = (boundsH - CBound1);
float boundHW = (boundsW - CBound2);
int bounds1 = Convert.ToInt32(boundHD);
int bounds2 = Convert.ToInt32(boundHW);
int check1 = ((bounds1 * 100) / OverPanel.Height);
int check2 = ((bounds2 * 100) / OverPanel.Width);
if (check1 < check2)
{
bound1 = (OverPanel.Height * check1) / 100;
bound2 = (OverPanel.Width * check1) / 100;
}
else
{
bound1 = (OverPanel.Height * check2) / 100;
bound2 = (OverPanel.Width * check2) / 100;
}
Point TPoint = new Point(0,0);
Graphics HQImage = Graphics.FromImage(PImage);
HQImage.CompositingQuality = CompositingQuality.HighQuality;
HQImage.InterpolationMode = InterpolationMode.HighQualityBicubic;
HQImage.SmoothingMode = SmoothingMode.HighQuality;
FImage = new Bitmap(PImage, bound2, bound1);
HQImage.DrawImage(FImage, TPoint);
e.Graphics.DrawImage(FImage, p);
}
private void button1_Click_1(object sender, EventArgs e)
PrintDocument PrintDoc = new PrintDocument();
PrintDoc.PrintPage += PrintDoc_PrintPage;
PrintDoc.Print();
FImage.Save("C:\\Test\\TestBMP.bmp");
PImage.Save("C:\\Test\\OBMP.bmp");
[/CODE]
When I print it out, the image comes out blurry. I uploaded a zip with 3 images.
PrintScrn is the one I capture with printscrn from my computer and cropped the form out of the picture - it looks and prints very acceptably.
OBMP is my original picture, it looks fairly bad and prints fairly bad.
TestBMP is my resized picture, it looks and print blurry, a little worse then OBMP.
Does anyone know a way to get a high quality screen capture? I'm already tried all the filters and highqualitybicubic and such.