如何制作图像到图像或绘制图像。 [英] How do i make graphic to image or paint to image.

查看:89
本文介绍了如何制作图像到图像或绘制图像。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void drawPoint(int x, int y, SolidBrush brush)
{

    Graphics g = Graphics.FromHwnd(picImage.Handle);
    //using (Graphics g = Graphics .FromImage (bmp ))
    
    //provides methods for drawing objects to the display device

    //SolidBrush brush = new SolidBrush(Color.Black);
    Point dPoint = new Point(x, (picImage.Height - y));
    dPoint.X = dPoint.X - 2;
    dPoint.Y = dPoint.Y - 2;
    Rectangle rect = new Rectangle(dPoint, new Size(5, 5));

    g.FillRectangle(brush, rect);
    g.Dispose();
    
}

推荐答案

试试teh Graphics.FromImage [ ^ ]方法(如您所示,已注释掉)

然后您可以使用返回的上下文来调用FillRectangle方法,它将绘制到图像。



如果你想要坚持,你将不得不使用Image.Save方法或你的更改将被丢弃当您的应用关闭时。
Try teh Graphics.FromImage[^] method (as you show commented out)
You can then use the context returned to call the FillRectangle method and it will draw to teh image.

If you want that to persist, you will have to use the Image.Save method or your changes will be thrown away when your app closes.


这篇关于如何制作图像到图像或绘制图像。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆