system.drawing命名空间问题" Graphics" [英] system.drawing namespace question "Graphics"

查看:96
本文介绍了system.drawing命名空间问题" Graphics"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道是否有人知道C#中是否有可能给出x,y

坐标的几条直线在屏幕上绘制这些然后

将此保存为图像文件,还将文本添加到文件中,如标题?

-

Paul G

软件工程师。

解决方案

是的,这是可能的。


但是你可能会最好在Bitmap对象的屏幕外绘制

。在您正在绘制的区域中,不存在因窗口更新而导致干扰的风险,您不需要进行

屏幕截图来获取 s绘制,并且大小不限于

屏幕分辨率。


创建一个Bitmap对象,使用Graphics.FromImage方法获取

图形对象,使用图形对象在位图上绘图,并将位图保存为文件。


Paul写道:< blockquote class =post_quotes>
我想知道是否有人知道C#中是否有可能给出x,y
坐标的几条直线在屏幕上绘制这些然后
将其保存为图像文件,还将文本添加到文件中,如标题?



是的,这很容易。

Google是您的朋友。
http://www.c -sharpcorner.com/2/gdi_plus.asp


看看Graphics.DrawLine()

Graphics.DrawString()并且不要忘记Graphics.MeasureString(),它是

非常有用


有很多例子。


如果你想保存为文件,得到一个Graphics对象来自你想要的

大小的位图

IE:

图形g = Graphics.FromBitmap(位图bm);


借给它

保存

" Paul" <帕** @ discussions.microsoft.com>在消息中写道

news:78 ********************************** @ microsof t.com ...


我想知道是否有人知道C#中是否有可能给出x,y
几条直线的坐标来绘制这些屏幕,然后将其保存为图像文件,还将文本添加到文件中,如标题?
-
Paul G
软件工程师。


好的谢谢你的信息。我不太熟悉图形

命名空间,但创建图形对象似乎确实是要走的路。你知道如何在屏幕外实际写入对象的任何例子吗?

你提到了吗?

再次感谢

-

Paul G

软件工程师。

" G ?? ran Andersson"写道:

是的,它是可能的。

你可能会更好地在Bitmap对象的屏幕外绘制
而不是。在您正在绘制的区域中,不存在因窗口更新而受到干扰的风险,您不需要进行屏幕捕获以获取所绘制的内容,并且大小不是仅限于
屏幕分辨率。

创建一个Bitmap对象,使用Graphics.FromImage方法获取一个
图形对象,使用图形对象在位图上绘图,然后保存
将位图作为文件。

Paul写道:


我想知道是否有人知道在C#给出x是否可行, y
几条直线的坐标在屏幕上绘制这些,然后将其保存为图像文件,还将文本添加到文件中,如标题?


Hi,
I was wondering if anyone knows if it is possible in C# given x,y
coordinates of several straight lines to draw these on the screen and then
save this as an image file, also adding text to the file like a title?
--
Paul G
Software engineer.

解决方案

Yes, it''s possible.

You might however be better of drawing it off-screen in a Bitmap object
instead. There is no risk of interference from windows updating
themselves in the area where you are drawing, you don''t need to do a
screen capture to get what''s drawn, and the size is not limited to the
screen resolution.

Create a Bitmap object, use the Graphics.FromImage method to get a
graphics object, draw on the bitmap using the graphics object, and save
the bitmap as a file.

Paul wrote:

Hi,
I was wondering if anyone knows if it is possible in C# given x,y
coordinates of several straight lines to draw these on the screen and then
save this as an image file, also adding text to the file like a title?



yes, this is easy.
Google is your friend.
http://www.c-sharpcorner.com/2/gdi_plus.asp

look at Graphics.DrawLine()
Graphics.DrawString() and don''t forget about Graphics.MeasureString(), it''s
very useful

There are tons of examples.

If you want to save as a file, get a Graphics object from a Bitmap of the
size you want
IE:
Graphics g = Graphics.FromBitmap(Bitmap bm);

draw on it
save it
"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...

Hi,
I was wondering if anyone knows if it is possible in C# given x,y
coordinates of several straight lines to draw these on the screen and then
save this as an image file, also adding text to the file like a title?
--
Paul G
Software engineer.



ok thanks for the information. I am not too familiar with the graphics
namespace but creating a graphics object does seem to be the way to go. Do
you know of any examples on how to actually write to the object off screen as
you mention?
thanks again
--
Paul G
Software engineer.
"G??ran Andersson" wrote:

Yes, it''s possible.

You might however be better of drawing it off-screen in a Bitmap object
instead. There is no risk of interference from windows updating
themselves in the area where you are drawing, you don''t need to do a
screen capture to get what''s drawn, and the size is not limited to the
screen resolution.

Create a Bitmap object, use the Graphics.FromImage method to get a
graphics object, draw on the bitmap using the graphics object, and save
the bitmap as a file.

Paul wrote:

Hi,
I was wondering if anyone knows if it is possible in C# given x,y
coordinates of several straight lines to draw these on the screen and then
save this as an image file, also adding text to the file like a title?



这篇关于system.drawing命名空间问题&quot; Graphics&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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