使用紧凑框架中的图形在Image上绘制DrawLines [英] DrawLines over Image using graphics in compact framework
本文介绍了使用紧凑框架中的图形在Image上绘制DrawLines的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个图片框控件,通过使用鼠标按下和鼠标移动事件,我使用点绘制图像并将其存储在我的数据库中。在更新模式下,我正在检索字节并将图像绘制到图片框控件中,现在我在图像上添加了几行,但要么是我新添加的行还是旧图像,但我想要两者
// rect是我的图片框
位图bmp =新位图(rect.Width,rect.Height );
//创建兼容的图形
图形gxComp = Graphics.FromImage(bmp);
//如果我有图像
System.IO.MemoryStream memStream = new System.IO.MemoryStream(TmpSign);
Bitmap im = new Bitmap(memStream);
Tmp是我图像的字节数组
gxComp.DrawLines(pen,_currentStroke.ToArray ());
_currentStroke是点列表。
解决方案
创建图像和绘图的grahics那个图形对象上的线已经解决了我的问题。
// 参考上面代码
// 创建图像的图形(如果存在)
gxcomp = Graphics.FromImage(im) ;
和
// 将新绘制的点写入图形
gxComp.DrawLines(pen,_ currentStroke.ToArray());
I have a picturebox control in which by using mouse down and mouse move events ,I am drawing a image using points and storing it in my database. and in update mode I am retrieving the bytes and drawing an image in to the picture box control and now I am adding few lines more on the image but either I am getting newly added lines or the old image but i want both
//rect is my picture box Bitmap bmp = new Bitmap(rect.Width, rect.Height); // Create compatible graphics Graphics gxComp = Graphics.FromImage(bmp); //If i have a image System.IO.MemoryStream memStream = new System.IO.MemoryStream(TmpSign); Bitmap im = new Bitmap(memStream);
Tmp is my byte array of my image
gxComp.DrawLines(pen, _currentStroke.ToArray());
_currentStroke is the list of points.
解决方案
Creating the grahics of image and drawing lines on to that graphics object has solved my problem.
//Ref with above Code //Creating the graphics of the image if exists
gxcomp=Graphics.FromImage(im);
and
//writing my new drawn points on to the graphics
gxComp.DrawLines(pen, _currentStroke.ToArray());
这篇关于使用紧凑框架中的图形在Image上绘制DrawLines的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文