Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Why this Method save the same bitmap every times called?

Why this Method save the same bitmap every times called?

Scheduled Pinned Locked Moved COM
graphicshelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bicphuong
    wrote on last edited by
    #1

    I have the following method to capture image from a window it works ok but today it save the same image to disk every times called. Please help me! I cannot understand what is the problem. _______________________________________________ public void GetWindowPicture(IntPtr hWnd) { IntPtr hdcDest = default(IntPtr); IntPtr hdcSrc = default(IntPtr); RECT r = new RECT(); int w = 0; int h = 0; GetWindowRect(hWnd, ref r); w = r.Right - r.Left; h = r.Bottom - r.Top; Bitmap bm = new Bitmap(w, h); Graphics g = Graphics.FromImage(bm); hdcSrc = GetWindowDC(hWnd); hdcDest = g.GetHdc(); BitBlt(hdcDest, 0, 0, w, h, hdcSrc, 0, 0, SRCCOPY); g.ReleaseHdc(hdcDest); ReleaseDC(hWnd, hdcSrc); bm.Save(GetOutputInfo(),System.Drawing.Imaging.ImageFormat.Jpeg); } _____________________________________ Thanks for your attention,

    B 1 Reply Last reply
    0
    • B bicphuong

      I have the following method to capture image from a window it works ok but today it save the same image to disk every times called. Please help me! I cannot understand what is the problem. _______________________________________________ public void GetWindowPicture(IntPtr hWnd) { IntPtr hdcDest = default(IntPtr); IntPtr hdcSrc = default(IntPtr); RECT r = new RECT(); int w = 0; int h = 0; GetWindowRect(hWnd, ref r); w = r.Right - r.Left; h = r.Bottom - r.Top; Bitmap bm = new Bitmap(w, h); Graphics g = Graphics.FromImage(bm); hdcSrc = GetWindowDC(hWnd); hdcDest = g.GetHdc(); BitBlt(hdcDest, 0, 0, w, h, hdcSrc, 0, 0, SRCCOPY); g.ReleaseHdc(hdcDest); ReleaseDC(hWnd, hdcSrc); bm.Save(GetOutputInfo(),System.Drawing.Imaging.ImageFormat.Jpeg); } _____________________________________ Thanks for your attention,

      B Offline
      B Offline
      Baltoro
      wrote on last edited by
      #2

      This doesn't really look like a COM problem,...but, copying the same image every time is probably because the HWND is the same every time. Give us some context as to where in an application this code is being executed.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups