当前位置:编程学习 > C#/ASP.NET >>

.net中对图片操作后打印出来的效果模糊,高手进

刚开始接触.net,请教各位高手,具体需求如下:

1,将两个数字画在一个图片下方(不在图片里,相隔图片有点点距离)
2,画好后打印出来,我这里用的是zebra 105SL 300DPI 打印机,
            public static void jprint(Image image){
            string accode = "1234567890";//方在图片下的字符
            Bitmap map = new Bitmap(500, 76);//GID位图
            Graphics graphics = Graphics.FromImage(map);//生成画布
            Font font = new Font("Arial", 8, FontStyle.Regular);
            PointF pointf = new PointF(0, 0);
            SizeF sizef = new SizeF(255, 75);
            graphics.FillRectangle(Brushes.White, new RectangleF(pointf, sizef));//设置以pointf坐标为起点sizef指定范围为白色
            graphics.DrawImage(image, 0, 17, 50, 50);
            //倾斜字体
            float angle = -90;//倾斜的角度
            graphics.ResetTransform();
            SizeF size=graphics.MeasureString(accode,font);
            graphics.TranslateTransform(size.Width/2,size.Height/2);//设置旋转中心为文字中心
            graphics.RotateTransform((float)angle);
            graphics.DrawString(accode, font, new SolidBrush(Color.Black), -65, 25);
            map.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            PrintService ps = new PrintService();
            ps.StartPrint(ms, "image");
         }
       class PrintService{
                private System.Drawing.Printing.PrintDocument docToPrint=new PrintDocument();
               public void StartPrint(Stream streamToPrint)
                  System.Drawing.Image image = System.Drawing.Image.FromStream(this.streamToPrint);
                    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;
                    }
                    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);           
}
}


打印出来的效果就是很粗糙,向请教大家有什么办法吗? --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 检查目标位图的分辨率 --------------------编程问答--------------------
引用 3 楼 wuyq11 的回复:
检查目标位图的分辨率

查看看 --------------------编程问答--------------------
引用 3 楼 wuyq11 的回复:
检查目标位图的分辨率


多谢提醒,是分辨率的原因,public static void jprint(Image image)传进来的image的分辨率为43X43,所以很粗糙,而在之后将这个image进行操作的时候,bitmap的分辨率设为500X76。
现在我想把图片的分辨率提高,不知道哪位大侠有什么办法,或者能给以个将字符转换成二维码图片(Image对象)的代码(分辨率高一点的,最好可以设置),谢了!  --------------------编程问答--------------------
补充:.NET技术 ,  .NET Framework
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,