报表是自带的rdlc报表。 绘图时已经做了 如何才能把分辨率提高到300? |
|
这不是分辨率的问题吧
|
|
不要用jpeg,用png或者bmp。
|
|
10分 |
解决方案1
传送到报表的时候,gdi以高分辨率重绘. 解决方案2: gdi绘制后以矢量图形格式输出,C#完全支持,以前我就是这么做的,效果非常好. 但要看你的报表控件是否支持矢量图形. |
是图的问题吧?
|
|
可能是jpeg的压缩率超出你的接受范围了.
|
|
Bitmap bmp = new Bitmap(100, 100);
bmp.SetResolution(300, 300); |
|
JPEG压缩造成的质量下降,试用无损压缩
|
|
就是用vs2010自带的报表,能否详细说明一下? |
|
用bmp效果一样 |
|
变成如下的效果,依然不清晰 |
|
在PrintDocument中绘制图片的时候,缩放到指定大小
grap.DrawImage(xx,new Rectangle()) //设置图片高分辨率后,图片会变大,缩放到实际大小 |
|
还是不行啊
|
|
求助求助
|
|
求助求助
|
|
这楼是正解。 |
|
30分 |
emf矢量图形绘制,我以前的代码,仅供参考
/// <summary> /// 绘制矢量图形,保存到指定位置 /// <para>Log-Log</para> /// </summary> /// <param name="width"></param> /// <param name="height"></param> /// <param name="rlu"></param> /// <param name="cv"></param> /// <returns></returns> private Bitmap DrawBmg2(int width, int height, double[] rlu, double[] cv) { //Bitmap bmp = new Bitmap(width, height); Bitmap bmp = new Bitmap(width, height); Graphics gs = Graphics.FromImage(bmp); Metafile mf = new Metafile("C:\aa.emf", gs.GetHdc()); Graphics gc = Graphics.FromImage(mf); int Hpace = 20;//坐标图距离底部的距离 int Wpace = 20;//距离左侧的距离 double dbxMaxCv = Math.Log10(cv[5]); double dbxMinCv = Math.Log10(cv[1]); double minY = Convert.ToDouble(((Math.Round(dbxMaxCv, 1) - Math.Round(dbxMinCv, 1)) / 4).ToString("f1")); minY = (minY * 4 + minY) / 4; // Graphics gc = Graphics.FromImage(bmp); Rectangle rect = new Rectangle(0, 0, width, height); gc.FillRectangle(Brushes.White, rect); Pen penRed = new Pen(Brushes.Red, 1); Pen penBlack = new Pen(Brushes.Black, 1); //x轴直线以及箭头 gc.DrawLine(penBlack, new Point(Wpace, height - Hpace), new Point(width - Wpace + 10, height - Hpace)); gc.DrawLine(penBlack, new Point(width - Wpace + 10, height - Hpace), new Point(width - Wpace + 10 - 5, height - Hpace + 5)); gc.DrawLine(penBlack, new Point(width - Wpace + 10, height - Hpace), new Point(width - Wpace + 10 - 5, height - Hpace - 5)); //y轴直线 gc.DrawLine(penBlack, new Point(Wpace, height - Hpace), new Point(Wpace, Hpace - 10)); gc.DrawLine(penBlack, new Point(Wpace, Wpace - 10), new Point(Wpace - 5, Hpace + 5 - 10)); gc.DrawLine(penBlack, new Point(Wpace, Wpace - 10), new Point(Wpace + 5, Hpace + 5 - 10)); int pxW = (width - Wpace * 2) / (rlu.Length - 1);// int pxH = (height - Hpace * 2) / (cv.Length - 1); // MessageBox.Show("pxW:" + pxW.ToString() + "\r\npxH:" + pxH.ToString()); //绘制坐标点 for (int i = 1; i < rlu.Length; i++) { //x gc.DrawLine(penBlack, new Point(Wpace + pxW * i, height - Hpace), new Point(Wpace + pxW * i, height - Hpace + 3)); //y gc.DrawLine(penBlack, new Point(Wpace, height - Wpace - pxH * i), new Point(Wpace - 3, height - Wpace - pxH * i)); /** * 需要四舍五入优化 * */ gc.DrawString(cv[i].ToString("f2"), new Font("Arial", 9), Brushes.Black, new Point(Wpace + pxW * i - 10, height - Hpace + 2)); gc.DrawString(rlu[i].ToString("f2"), new Font("Arial", 9), Brushes.Black, new Point(Wpace - 15, height - Wpace - pxH * i - 5)); } //0点位置wpace,height-hpace int pointRadius = 4;//必须为偶数 double xPointValue = (cv[5] - cv[0]) / (width - Wpace * 2);//一个像素对应的值 double yPointValue = (rlu[5] - rlu[0]) / (height - Hpace * 2); for (int i = 1; i < rlu.Length; i++) { // Rectangle rectPoint = new Rectangle(new Point(Wpace - pointRadius / 2, height - Hpace - pointRadius / 2), new Size(pointRadius, pointRadius)); Rectangle rectPoint = new Rectangle(new Point(Wpace + Convert.ToInt32((cv[i] - cv[0]) / (xPointValue)) - pointRadius / 2, height - Convert.ToInt32((rlu[i] - rlu[0]) / (yPointValue)) - Hpace - pointRadius / 2), new Size(pointRadius, pointRadius)); gc.DrawEllipse(penRed, rectPoint); gc.FillEllipse(Brushes.Red, rectPoint); //if (i < rlu.Length - 1) //{ // gc.DrawLine(penRed, new Point(Wpace + Convert.ToInt32((cv[i] - cv[0]) / (xPointValue)) - pointRadius / 2, height - Convert.ToInt32((rlu[i] - rlu[0]) / (yPointValue)) - Hpace), // new Point(Wpace + Convert.ToInt32((cv[i + 1] - cv[0]) / (xPointValue)) - pointRadius / 2, height - Convert.ToInt32((rlu[i + 1] - rlu[0]) / (yPointValue)) - Hpace)); //} } gc.DrawLine(penRed, new Point(Wpace + Convert.ToInt32((cv[1] - cv[0]) / (xPointValue)) - pointRadius / 2, height - Convert.ToInt32((rlu[1] - rlu[0]) / (yPointValue)) - Hpace), new Point(Wpace + Convert.ToInt32((cv[5] - cv[0]) / (xPointValue)) - pointRadius / 2, height - Convert.ToInt32((rlu[5] - rlu[0]) / (yPointValue)) - Hpace)); gs.Dispose(); mf.Dispose(); gc.Dispose(); return bmp; } 中间的是绘制点线图的代码,直接忽略. |
简单的demo
Metafile curMetafile = null; // Create a Graphics object Graphics g = this.CreateGraphics(); // Get HDC IntPtr hdc = g.GetHdc(); // Create a rectangle Rectangle rect = new Rectangle(0, 0, 200, 200); // Use HDC to create a metafile with a name try { curMetafile = new Metafile("newFile.wmf", hdc); } catch (Exception exp) { MessageBox.Show(exp.Message); g.ReleaseHdc(hdc); g.Dispose(); return; } // Create a Graphics object from the Metafile object Graphics g1 = Graphics.FromImage(curMetafile); // Set smooting mode g1.SmoothingMode = SmoothingMode.HighQuality; // Fill a rectangle on the Metafile object g1.FillRectangle(Brushes.Green, rect); rect.Y += 110; // Draw an ellipse on the Metafile object LinearGradientBrush lgBrush = new LinearGradientBrush( rect, Color.Red, Color.Blue, 45.0f); g1.FillEllipse(lgBrush, rect); // Draw text on the Metafile object rect.Y += 110; g1.DrawString("MetaFile Sample", new Font("Verdana", 20), lgBrush, 200, 200, StringFormat.GenericTypographic); // Release objects g.ReleaseHdc(hdc); g1.Dispose(); g.Dispose(); |
|
结贴啊 |
|
这个问题我也遇到了 我当时生成的是jpeg格式的图像 最后我给成了bmp格式的图片,整个人一下子都好了~~~
|