在Picturebox上绘图 [英] Drawing on Picturebox

查看:104
本文介绍了在Picturebox上绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我正在编程一个工具,该工具给出了一个部分(例如16 x 16),用于绘制图像中的字符,但是我做不到,因为我在Internet上找到的所有内容都可以绘制表格.谁能帮我吗?
这是我做的代码,但是不起作用.
在此先感谢:)

Hello everyone.

I''m programming a tool that given a section (eg 16 x 16), drawings of characters from an image, but I can not, because everything that I found on the Internet, draw the form. Can anyone help me?
This is the code that I did, but that does not work.
Thanks in advance:)

private void btnWrite_Click(object sender, EventArgs e)
        {
            Image img = new Bitmap(ofd.OpenFile());

            Rectangle section = new Rectangle();

            section.Height = (int)gridHeigth.Value;
            section.Width = (int)gridWidth.Value;
            section.X = 0;
            section.Y = 0;
            Graphics grp = CreateGraphics();
            grp.DrawImage(img, section);
        }

推荐答案

噢(叹气)…我发现了另一种尝试滥用PictureBox的情况.让我解释一下.此控件是为根本不想处理任何图形的人设计的.一些简单的事情.没有动态,动画,组合,操纵的内容.纯静态图像,有时可能会被替换,但并不经常.

由于对图形的深深困惑,许多人试图做更多的事情,这是可能的,但是很愚蠢.此控件无济于事,只会带来麻烦.

那么,该怎么办呢?更简单的方法:
如何从旧图纸中清除面板 [ ^ ].

如果您拍摄的照片是静态的,则比这更简单.做无效,没有双重缓冲.但是您可以进行运动图像,动画,保存到文件或从文件加载等等.

—SA
Oh (sigh)… I discovered yet another case of an attempt to misuse of PictureBox. Let me explain that. This control is designed for somebody who does not want to deal with any graphics at all. Something simple and simpler. Nothing dynamic, animated, combined, manipulated. Pure static image, maybe sometimes replaced, but not often.

By the reason of deep confusion about graphics, many try to do a lot more, which is possible but just silly. This control does not help it, only presents a hassle.

So, what do to? Something way more simple:
How do I clear a panel from old drawing[^].

If you picture is static, it''s even simpler than that. Do invalidation, no double buffering. But you can do moving images, animation, saving to file or loading from files and a lot more.

—SA


这篇关于在Picturebox上绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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