Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Drawing / September 2003

Tip: Looking for answers? Try searching our database.

StretchBlt "shoot" from memory?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leo da Perdi - 01 Sep 2003 09:56 GMT
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 -----

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.