[英]How to get the bitmap from a Graphics object in C#?
How do you get a bitmap from a graphics object (or at least a pointer to it's Scan0)? 如何从图形对象(或至少指向它的Scan0)获取位图?
If a graphics object really always refers to a bitmap, then it IS possible to get to the bitmap data from the graphics object. 如果图形对象确实总是引用位图,则可以从图形对象获取位图数据。 (Think: the graphics object HAS TO have a pointer to the bmp data. I'd code it in C but I'm on a project that requires everyone be hobbled by .NET.)
(想想:图形对象有一个指向bmp数据的指针。我用C编写代码但是我正在一个需要每个人都被.NET踩踏的项目。)
Applications of this would include things like: - using unsafe code to obtain faster screenshots - modifying what's on a control using CreateGraphics - (and the task I'm actually trying to accomplish which would take too long to explain) 应用程序包括: - 使用不安全的代码获取更快的屏幕截图 - 使用CreateGraphics修改控件上的内容 - (我实际上要完成的任务需要很长时间才能解释)
Yes, this has been asked before but never answered. 是的,以前曾经问过,但从未回答过。 I'm not looking for how to get a graphics object from a bitmap (obviously trivial).
我不是在寻找如何从位图中获取图形对象(显然是微不足道的)。 FAIL1 , FAIL2 , FAIL3 , FAIL4 , FAIL5 , FAIL6 , FAIL7
FAIL1 , FAIL2 , FAIL3 , FAIL4 , FAIL5 , FAIL6 , FAIL7
I don't think what you're trying to do is possible since your assumption that "a graphics object really always refers to a bitmap" is false. 我不认为你想要做的是可能的,因为你假设“图形对象总是指向位图”是错误的。
There's a good article here that shows how to render a control to bitmap if you really want a bitmap and another one here that shows how to quickly update the screen at the WndProc level. 有一个很好的文章在这里显示了如何渲染控制位图,如果你真的想要一个位图和另外一个在这里展示了如何快速在WndProc的水平更新屏幕。 If you're more familiar with C++ that might get you going the right direction.
如果您对C ++更熟悉,可能会让您朝着正确的方向前进。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.