I need to save a bitmap taking the content of a panel (this is filled by a
Windows Media Encoder Preview). Using Encoder PostView (not PreView!!!, I
don't know why..) in a Windows Form application, everything works fine, but
if I compile a Console Application, "StretchBlt" catch the bitmap from the
screen and not from the panel "Panel_Postview" in memory.
I'm a novice in GDI so I don't know it very well....There is a way to force
StretchBlt (or BitBlt) to read from my fictitious panel?
Thanks in advance
Leo
----- Here my code -----
System.Windows.Forms.Panel Panel_Postview = new
System.Windows.Forms.Panel();
Panel_Preview.Width = 320;
Panel_Preview.Height = 240;
IntPtr dc11 = GetDC(Panel_Postview.Handle);
Graphics g11 = Graphics.FromHdc(dc11);
dc11 = g11.GetHdc();
Bitmap MyImage11 = new Bitmap(Panel_Postview.Width,
Panel_Postview.Height);
Graphics g22 = Graphics.FromImage(MyImage11);
IntPtr dc22 = g22.GetHdc();
StretchBlt(dc22, 0, 0, 320, 240, dc11, 0, 0,Panel_Postview.Width,
Panel_Postview.Height, 40000000);
g11.ReleaseHdc(dc11);
g22.ReleaseHdc(dc22);
g11.Dispose();
g22.Dispose();
MyImage1.Save("C:\\framepostview.bmp");
----- Here my code -----
Bob Powell [MVP] - 01 Sep 2003 19:55 GMT
I'm not certain but I think that you need to read directly from the desktop
DC, not the Panel.
Video/media playback is probaly using a DirectX overlay and so the panel
window will only be a placeholder.
Convert the panel coordinates to screen coordinates using PointToScreen and
then grab the rectangle from the desktop.
--
Bob Powell [MVP]
C#, System.Drawing
ANNOUNCING: Well Formed.
The monthy electronic magazine for
Windows Forms and GDI+ engineers
http://www.bobpowell.net/wellformed.htm
Check out the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
> I need to save a bitmap taking the content of a panel (this is filled by a
> Windows Media Encoder Preview). Using Encoder PostView (not PreView!!!, I
[quoted text clipped - 36 lines]
>
> ----- Here my code -----