Hi,
I have a problem in printing, when I paint a control. It displays properly in screen. But when I am printing, the control appears tiny. I am using the following code block:
private void PaintCtrl(Control ctrl, Graphics graphics, RectangleF rectF)
{
Bitmap bitmap = null;
PictureBox pic = ctrl as PictureBox;
if (pic != null)
{
if (pic.Image != null)
{
bitmap = pic.Image as Bitmap;
}
}
if (bitmap == null)
{
bitmap = new Bitmap(ctrl .Width, ctrl .Height);
win32.CaptureWindow(ctrl , ref bitmap);
}
// Make the rectF the size of the bitmap.
PointF[] points =
{ new PointF(rectF.Location.X, rectF.Location.Y) };
graphics.TransformPoints(
CoordinateSpace.Device, CoordinateSpace.Page, points);
points[0].X += bitmap.Width;
points[0].Y += bitmap.Height;
graphics.TransformPoints(
CoordinateSpace.Page, CoordinateSpace.Device, points);
RectangleF bMapRect = new RectangleF(rectF.Location, rectF.Size);
bMapRect.Height = points[0].Y - rectF.Top;
bMapRect.Width = points[0].X - rectF.Left;
graphics.DrawImage(bitmap, bMapRect);
}
Can any one help me to fix it? Thanks in advance!
jjohn
I have a problem in printing, when I paint a control. It displays properly in screen. But when I am printing, the control appears tiny. I am using the following code block:
private void PaintCtrl(Control ctrl, Graphics graphics, RectangleF rectF)
{
Bitmap bitmap = null;
PictureBox pic = ctrl as PictureBox;
if (pic != null)
{
if (pic.Image != null)
{
bitmap = pic.Image as Bitmap;
}
}
if (bitmap == null)
{
bitmap = new Bitmap(ctrl .Width, ctrl .Height);
win32.CaptureWindow(ctrl , ref bitmap);
}
// Make the rectF the size of the bitmap.
PointF[] points =
{ new PointF(rectF.Location.X, rectF.Location.Y) };
graphics.TransformPoints(
CoordinateSpace.Device, CoordinateSpace.Page, points);
points[0].X += bitmap.Width;
points[0].Y += bitmap.Height;
graphics.TransformPoints(
CoordinateSpace.Page, CoordinateSpace.Device, points);
RectangleF bMapRect = new RectangleF(rectF.Location, rectF.Size);
bMapRect.Height = points[0].Y - rectF.Top;
bMapRect.Width = points[0].X - rectF.Left;
graphics.DrawImage(bitmap, bMapRect);
}
Can any one help me to fix it? Thanks in advance!
jjohn