Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#打印机只打印提交图片的四分之一_C#_Image_Printing - Fatal编程技术网

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

C#打印机只打印提交图片的四分之一,c#,image,printing,C#,Image,Printing,您好 我有一个小应用程序,应该能够打印单个jpeg文件到网络打印机。现在打印本身可以工作,但问题是打印机只打印图片的左上角,无论我使用哪一张图片。通常,图片为1800x1200像素,jpeg格式 im用于打印的代码如下所示: protected void Button5_Click(object sender, EventArgs e) { PrintDocument doc = new PrintDocument(); doc.PrinterSettings.PrinterNa

您好

我有一个小应用程序,应该能够打印单个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);
}
函数的作用是:从网络驱动器返回带有图片的位图。 有人知道为什么会发生这种奇怪的行为吗

提前谢谢
xen

边界高度/宽度是多少? 再看看图像的尺寸

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);
}

我希望您能看到它们尺寸之间的差异。

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