C#如何提高笔刷的速度 [英] c# How to Improve my brush's speed

查看:139
本文介绍了C#如何提高笔刷的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用pictureBox和Bitmap,放在表格上.
首先,我在位图上绘画,并使用图片的属性:image,直接渲染我绘制的内容.因为我的笔需要Alpha值,所以我使用GDI +来解决它.随着使用GDI +的出现,我发现笔刷的速度非常缓慢.在测试过程中,我知道需要计算每个用alpha绘制的内容的原因,并且我还发现我失去了参加mousemove事件的机会,这可能会导致我丢失点.我不知道如何改进它,如果您有什么想法,请尽快告诉我.

I use a pictureBox and Bitmap,drop on form.
First I paint on my bitmap,and using picture''s attribute :image, direct render what I have painted. Because my pen need Alpha value,so I use GDI+ to solve it. As the occurrence of using GDI+ ,I found the speed of my brush so slowly. During test ,I know the reason that each what I have painted with alpha needs to calculate,and I alse found I lost the chance to enter into mousemove event which may leads I lost dot. I don''t know how to improve it,if you have some idea,please let me know soon.

推荐答案

您可以提高速度并简化开发通过不使用PictireBox.当您需要显示一些静态图片或有时进行更改时,此类在某些最简单的情况下很有用.当您尝试执行动态,交互,动画等操作时,此类不会提供任何帮助,但会带来一些麻烦,会消耗一些额外的资源,影响性能,但绝对没有任何回报.您只需要在数据和图像渲染之间使用一些绝对冗余的附加层即可.只需将其删除.我会解释该怎么做.

请查看我过去的答案:
如何从旧图纸中清除面板 [ ^ ],
在C#中绘制矩形 [在图片框内添加图片 [在mdi子表单之间画线 [在面板上捕获图形 [ Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [
You can improve the speed and also simplify your development by not using the class PictireBox. This class is helpful in some simplest situations, when you need to show some static picture, or maybe change it sometimes. When you try to do something dynamic, interactive, animated, etc, this class provides no help but presents some additional hassles, eats some extra resources, compromises performance giving absolutely nothing in return. You just use some absolutely redundant additional layer between data and image rendering. Just remove it. I''ll explain what to do instead.

Please see my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^].

Please see my more general answers on GDI+ rendering:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].

Good luck,
—SA


这篇关于C#如何提高笔刷的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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