正在处理一个需要我创建货运标签并将其作为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();
在600dpi激光打印机上打印高质量4x6“标签需要位图为4 * 600 * 6 * 600 = 2400 x 3600位图,您的大小约为6倍,无论如何打印为4x6”将位图中的像素转换为打印机上的6x6墨点。当然,除非你有很长的手臂,否则这看起来很糟糕。 –
感谢汉斯,所以为了让我的基本96dpi我需要一个384X576大小的图像。这给了我一些方向。 – jrobinson6274