简体   繁体   中英

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)?

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.)

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)

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

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. If you're more familiar with C++ that might get you going the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM