When i am trying to print an image to a printer for a 700kb file it is sending 120MB of data over to the printer. I can see this because I see the printer spooling 120MB. why would this happend?
Here is the code for the PrintDocument.PrintPage
private void PrintPage(object sender, PrintPageEventArgs ev)
{
sw.WriteLine("start,PrintPage," + DateTime.Now.ToLongTimeString());
if (_running && _currentPage != null)
{
RectangleF PrintArea = ev.Graphics.VisibleClipBounds;
RectangleF NewImageSize = new RectangleF();
Double SF = Convert.ToDouble(PrintArea.Width) / Convert.ToDouble(_currentPage.Width);
NewImageSize.Width = Convert.ToInt32(_currentPage.Width * SF);
NewImageSize.Height = Convert.ToInt32(_currentPage.Height * SF);
//You can influence the quality of the resized image
ev.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
ev.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
ev.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Default;
//Draw the image to the printer
ev.Graphics.DrawImage(_currentPage, NewImageSize);
_currentPage.Dispose();
_currentPage = null;
//Trace.WriteLine(string.Format("IsFinished {0}, Count {1}", (_queue.IsFinished ? "True" : "False"), _queue.Count));
ev.HasMorePages = (!((_queue.IsFinished) && (_queue.Count == 0)));
}
sw.WriteLine("end,PrintPage," + DateTime.Now.ToLongTimeString());
}
There is two reasons that the printed image is larger than the image file:
The image file is most likely compressed. If it’s a JPEG image, it’s usually compressed to about 1/10 – 1/20 of it’s size. When you load the image it’s uncompressed to something around 10 MB.
You are resizing the image when you are sending it to the printer. The resolution of the printer is often quite high. If the resolution of the image is something like 300 PPI and the resolution of the printer is something like 1000 PPI, the image will be resized to about ten times it’s original size.