我在做打印图片时,打印出的图片不能自动缩放,我曾经想过是不是可以调整图像文件的大小,但是又确定不了调多大才适合A4纸张。请哪位老大给指点个高招啊!!顶者有分。
现用的打印代码如下:
string FileName="";

switch(tbTreat.SelectedIndex)
{
case 0:
FileName=mCurImgFile;
break;
case 1:
case 2:
                    FileName=mCurTreatImg;
break;
}
Image image=new Bitmap(FileName);
int x=e.MarginBounds.X;
int y=e.MarginBounds.Y;
int width=image.Width;
int height=image.Height;
if((width/e.MarginBounds.Width)>(height/e.MarginBounds.Height))
{
width=e.MarginBounds.Width;
height=image.Height*e.MarginBounds.Width/image.Width;
}
else
{
height=e.MarginBounds.Height;
width=image.Width*e.MarginBounds.Height/image.Height;
}
MessageBox.Show(width.ToString(),height.ToString());
System.Drawing.Rectangle destRect=new System.Drawing.Rectangle(x,y,width,height);
e.Graphics.DrawImage(image,destRect,0,0,image.Width,image.Height,System.Drawing.GraphicsUnit.Pixel);