2009-11-23 92 views
0

问候,C#打印机打印只提交图片的四分之一

我有一个小应用程序,应该能够打印单个JPEG文件到网络打印机。现在,打印本身工作,但问题是打印机只打印图片的左上角四分之一,无论我使用哪张图片。通常情况下,图片是1800x1200像素和JPEG格式。

使用打印的代码IM如下:

protected void Button5_Click(object sender, EventArgs e) 
{ 
    PrintDocument doc = new PrintDocument(); 
    doc.PrinterSettings.PrinterName = "KONICA MINOLTA C250/C250P PCL"; 
    doc.PrintPage += this.Doc_PrintPage; 
    if(doc.PrinterSettings.IsValid) 
     doc.Print(); 
} 


private void Doc_PrintPage(object sender, PrintPageEventArgs e) 
{ 
    float x = e.MarginBounds.Left; 
    float y = e.MarginBounds.Top; 

    e.Graphics.DrawImage((System.Drawing.Image)ShowImg(bild.ToolTip),x, y); 
} 

的ShowImg()函数只返回与从网络驱动器的图象的位图。 有谁知道为什么会发生这种奇怪的行为?

在此先感谢 Xen的

回答

0

发现我使用的是300dpi的jpeg,而打印机只支持90dpi。傻我:)

0

什么是MarginBounds.Height /宽? 看一看图像尺寸太...

private void Doc_PrintPage(object sender, PrintPageEventArgs e) 
{ 
    float x = e.MarginBounds.Left; 
    float y = e.MarginBounds.Top; 
    var img = (System.Drawing.Image)ShowImg(bild.ToolTip); 

    Debug.Print("img: {0}x{1}", img.Width, img.Height);  
    Debug.Print("margins: {0}x{1}", e.MarginBounds.Width, e.MarginBounds.Height);  

    e.Graphics.DrawImage(img,x, y); 
} 

我希望你能看到它们的尺寸之间的差别。