[ radoica @ 19.07.2006. 01:37 ] @
Bilo bi idealno kada bi klasa Bitmap imala ovaj metod, ali nema. Kako da dobijem Bitmap-u od Graphics-a? |
[ radoica @ 19.07.2006. 01:37 ] @
[ ZokiR @ 20.07.2006. 03:03 ] @
To možeš da postigneš pomoću BitBlt GDI funkcije. Imaš primer na http://www.c-sharpcorner.com/Graphics/ScreenCaptFormMG.asp
[ radoica @ 21.07.2006. 14:34 ] @
To je to, hvala
Evo klase Code: public static class MyBitmap { [DllImport("gdi32.dll")] private static extern bool BitBlt( IntPtr hdcDest, // handle to destination DC int nXDest, // x-coord of destination upper-left corner int nYDest, // y-coord of destination upper-left corner int nWidth, // width of destination rectangle int nHeight, // height of destination rectangle IntPtr hdcSrc, // handle to source DC int nXSrc, // x-coordinate of source upper-left corner int nYSrc, // y-coordinate of source upper-left corner uint dwRop // raster operation code ); public static Bitmap FromGraphics(Graphics g) { int w = (int) g.VisibleClipBounds.Width; int h = (int) g.VisibleClipBounds.Height; Bitmap b = new Bitmap(w, h, g); Graphics bg = Graphics.FromImage(b); IntPtr gdc = g.GetHdc(); IntPtr bgdc = bg.GetHdc(); BitBlt(bgdc, 0, 0, w, h, gdc, 0, 0, 0x00CC0020); g.ReleaseHdc(gdc); bg.ReleaseHdc(bgdc); bg.Dispose(); return b; } } Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|