2016-01-17 72 views
0

正在处理一个需要我创建货运标签并将其作为PNG存储的项目。当我查看PNG文件时,我设置了布局,一切都很好,但是当我在热敏/喷墨/激光打印机上进行打印时,质量非常糟糕。PNG文件质量差

我搜遍了所有,但我找不到任何似乎解决我的问题。我不是一个图形人,但我想知道是否需要以更高的分辨率构建文件,但最终结果需要是4乘6运输标签。什么是改善图像质量的最佳方法?

下面是用来生成PNG文件的代码:

   Bitmap bitMapImage = new System.Drawing.Bitmap("blanklabel.png"); 
       Graphics graphicImage = Graphics.FromImage(bitMapImage); 
       graphicImage.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; 
       string dttime = DateTime.Now.ToString("HHmmss"); 

       // Create pen. 
       Pen blackPen0 = new Pen(Color.Gray, 1); 
       Pen blackPen1 = new Pen(Color.Black, 1); 
       Pen blackPen2 = new Pen(Color.Black, 2); 
       Pen blackPen3 = new Pen(Color.Black, 3); 

       //Top Rectangle - Draw Box 
       Rectangle topRect = new Rectangle(5, 5, 367, 338); 
       graphicImage.DrawRectangle(blackPen1, topRect); 
       //Top Rectangle - Horizontial Lines 
       graphicImage.DrawLine(blackPen1, 5, 41, 372, 41); 
       graphicImage.DrawLine(blackPen1, 5, 77, 372, 77); 
       graphicImage.DrawLine(blackPen2, 5, 129, 372, 129); 
       graphicImage.DrawLine(blackPen2, 5, 210, 372, 210); 
       graphicImage.DrawLine(blackPen0, 5, 225, 372, 225); //Draw row1 in middle 
       graphicImage.DrawLine(blackPen0, 5, 240, 372, 240); //Draw row2 in middle 
       graphicImage.DrawLine(blackPen0, 5, 255, 372, 255); //Draw row3 in middle 
       graphicImage.DrawLine(blackPen1, 5, 271, 372, 271); 
       graphicImage.DrawLine(blackPen1, 5, 322, 372, 322); 
       //Top Rectangle - Vertical Lines 
       graphicImage.DrawLine(blackPen1, 258, 41, 258, 322); 
       graphicImage.DrawLine(blackPen1, 103, 210, 103, 271); 
       graphicImage.DrawLine(blackPen1, 172, 210, 172, 271); 
       //graphicImage.DrawLine(blackPen1, 257, 210, 257, 271);      
       graphicImage.DrawLine(blackPen1, 304, 210, 304, 271); 

       //Top Rectangle - Label Text 
       graphicImage.DrawString("Shipper's Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 43)); 
       graphicImage.DrawString("Receiver's Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 79)); 
       graphicImage.DrawString("Origin", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 43)); 
       graphicImage.DrawString("Destination", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 79)); 
       graphicImage.DrawString("Time-definite type", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 131)); 
       graphicImage.DrawString("Total packages", new Font("Arial", 6), SystemBrushes.WindowText, new Point(10, 213)); 
       graphicImage.DrawString("Total Actual weight", new Font("Arial", 6), SystemBrushes.WindowText, new Point(10, 228)); 
       graphicImage.DrawString("Total Chargeable weight", new Font("Arial", 6), SystemBrushes.WindowText, new Point(10, 243)); 
       graphicImage.DrawString("Freight Charges", new Font("Arial", 6), SystemBrushes.WindowText, new Point(10, 258)); 
       graphicImage.DrawString("Additional Service", new Font("Arial", 6), SystemBrushes.WindowText, new Point(180, 213)); 
       graphicImage.DrawString("Charges", new Font("Arial", 6), SystemBrushes.WindowText, new Point(264, 213)); 
       graphicImage.DrawString("Total Charges", new Font("Arial", 6), SystemBrushes.WindowText, new Point(310, 213)); 
       graphicImage.DrawString("Payment Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 275)); 
       graphicImage.DrawString("Credit Account No.:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 290)); 
       graphicImage.DrawString("3rd Party District code:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 305)); 
       graphicImage.DrawString("Receiver's Signature:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 275)); 
       graphicImage.DrawString("Delivery Date:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(263, 305)); 
       graphicImage.DrawString("Remarks:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 327)); 

       //Bottom Rectangle - Draw Box 
       Rectangle bottomRect = new Rectangle(5, 349, 367, 211); 
       graphicImage.DrawRectangle(blackPen1, bottomRect); 
       //Bottom Rectangle - Horizontial Lines 
       graphicImage.DrawLine(blackPen1, 258, 377, 372, 377); 
       graphicImage.DrawLine(blackPen1, 5, 401, 258, 401); 
       graphicImage.DrawLine(blackPen1, 5, 468, 372, 468); 
       graphicImage.DrawLine(blackPen1, 5, 528, 372, 528); 
       //Bottom Rectangle - Vertical Lines 
       graphicImage.DrawLine(blackPen1, 258, 349, 258, 560); 
       //Bottom Rectangle - Label Text 
       graphicImage.DrawString("Shipment Type:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 352)); 
       graphicImage.DrawString("Description of Contents:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 380)); 
       graphicImage.DrawString("Declared value for Customs:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 420)); 
       graphicImage.DrawString("Country of Origin:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 450)); 
       graphicImage.DrawString("Shipper's Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 404)); 
       graphicImage.DrawString("Receivers's Information:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 471)); 
       graphicImage.DrawString("Total Charges:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 471)); 
       graphicImage.DrawString("Payment Information:", new Font("Arial", 6), SystemBrushes.WindowText, new Point(261, 495)); 
       graphicImage.DrawString("Customer remarks:", new Font("Arial", 7, FontStyle.Bold), SystemBrushes.WindowText, new Point(10, 538)); 
       //Bottom Rectangle - Self Drop Selection Box 
       Rectangle bottomselectRect1 = new Rectangle(261, 538, 12, 12); 
       graphicImage.DrawRectangle(blackPen1, bottomselectRect1); 
       //Bottom Rectangle - Self Pickup Selection Box 
       Rectangle bottomselectRect2 = new Rectangle(313, 538, 12, 12); 
       graphicImage.DrawRectangle(blackPen1, bottomselectRect2); 
       graphicImage.DrawString("Self-drop:", new Font("Arial", 5), SystemBrushes.WindowText, new Point(276, 541)); 
       graphicImage.DrawString("Self-pickup:", new Font("Arial", 5), SystemBrushes.WindowText, new Point(328, 541)); 

       HttpContext.Current.Response.ContentType = "image/png"; 

       bitMapImage.Save("test_label_" + dttime + ".png", ImageFormat.Png); 
       blackPen0.Dispose(); 
       blackPen1.Dispose(); 
       blackPen2.Dispose(); 
       blackPen3.Dispose(); 
       graphicImage.Dispose(); 
       bitMapImage.Dispose(); 

enter image description here

enter image description here

+0

在600dpi激光打印机上打印高质量4x6“标签需要位图为4 * 600 * 6 * 600 = 2400 x 3600位图,您的大小约为6倍,无论如何打印为4x6”将位图中的像素转换为打印机上的6x6墨点。当然,除非你有很长的手臂,否则这看起来很糟糕。 –

+0

感谢汉斯,所以为了让我的基本96dpi我需要一个384X576大小的图像。这给了我一些方向。 – jrobinson6274

回答

0

这只是局部的答案,但它可能会有所帮助。以下是您的图像是: 图像Dinensions:377 x 566像素 10.19 x 15.30 Cm 像素每厘米:37 它可能有助于知道您的输出设备(s)使用,但我用过的大多数喷墨打印机都很高兴每英寸300像素(或300 dpi的几倍)。其他决议将不得不缩小,对于这样的细节可能是灾难性的。 您是否有图形程序可用于修改PNG的分辨率和缩放比例,以便您可以在不必更改程序的情况下进行实验? (我使用的是不再可用的Paint Shop Pro的古老版本,但我也有Corel Photo Paint,它也可以完成这项工作。)如果你没有任何东西,你可以试试gimp(免费的位图软件)。

+0

感谢输入Tamias,目标是将标签打印到使用4X6标签的热敏打印机。我使用的打印机是203dpi。 – jrobinson6274

+0

类似于@Hans Passant所说的,如果你的输出设备是203 dpi,输出尺寸是4 x 6英寸,我想发送一个812 x 1218的图像,而不是377 x 566.再次,我想你可能会通过一些图形程序来加强你的开发循环,然后当程序运行良好时,让你的程序生成一个具有相同图像参数的图形。 – Tamias