I am writing a program that should print high resolution .tiff images. The problem I am facing is that I cannot print .tiff in good quality. Due to the large .tiff size (e.g. 8700x7200), it does not fit on any standard sheet. I tried increasing the DPI, but it showed no effect. The only way I can get .tiff to fit the page is to zoom out. but then the image has terrifying quality. (I scale it to fit 11x17, but this only has the specified resolution of 1100x1700). I tried to change the print permissions on the printer, tried to manually and programmatically set the quality / resolution of the printer, but to no avail. Basically, I want to allow for more .tiff pixels on the 11x17 page,so I don’t need to scale that much. I thought that increasing the DPI for printing would increase the number of pixels by 11x17 inches, but that didn't affect me. Maybe I'm doing something wrong. Any help would be greatly appreciated. thanks.
Below is the code I'm trying to do right now when pd.Print () is called.
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
try
{
Image tempImage = Image.FromFile(@"H:\21RR-G0K-30140-0220-0002.tiff");
Bitmap bMap = new Bitmap(tempImage);
bMap.SetResolution(1200, 1200);
string l = "";
tempImage = bMap;
float ImageAspectRatio = (float)tempImage.Height / (float)tempImage.Width;
float PageSizeAspectRatio = (float)_pSize.Height / (float)_pSize.Width;
if (ImageAspectRatio < 1 && PageSizeAspectRatio > 1)
{
double x_scale = (double)_pSize.Width / (double)tempImage.Height;
double y_scale = (double)_pSize.Height / (double)tempImage.Width;
int percent = 0;
if (y_scale < x_scale)
{
percent = Convert.ToInt32(y_scale * 100);
}
else
{
percent = Convert.ToInt32(x_scale * 100);
}
Image myImage = ImageManipulation.ScaleByPercent(tempImage, percent);
Bitmap tempMap = new Bitmap(myImage);
tempMap.SetResolution(1200, 1200);
RotateBicubic rotateBC = new RotateBicubic(90);
Image finalImage = rotateBC.Apply(tempMap);
ev.Graphics.DrawImage(finalImage, 0, 0);
}
else if (ImageAspectRatio >= 1 && PageSizeAspectRatio >= 1)
{
double x_scale = (double)_pSize.Width / (double)tempImage.Width;
double y_scale = (double)_pSize.Height / (double)tempImage.Height;
int percent = 0;
if (y_scale < x_scale)
{
percent = Convert.ToInt32(y_scale * 100);
}
else
{
percent = Convert.ToInt32(x_scale * 100);
}
Image myImage = ImageManipulation.ScaleByPercent(tempImage, percent);
ev.Graphics.DrawImage(myImage, 0, 0);
}
else
{
}
}
catch(Exception ex)
{
string breakingpoint = "";
}
}
source
share