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. C#
  4. Screen Capture Image bit depth question.. [modified]

Screen Capture Image bit depth question.. [modified]

Scheduled Pinned Locked Moved C#
graphicsquestioncsharpadobehelp
1 Posts 1 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.
  • G Offline
    G Offline
    Greg Ellis
    wrote on last edited by
    #1

    Hey Guys, I have a c# application that uses win32 code to take a screencapture of a window running on the system. It then compares a portion of that screencapture with a bitmap that I have already pre-captured to see if that window is in a certain state. When I first wrote the code it compared no problem, but now when I use it the two images are not EXACTLY the same. My application captured the right part of the graphic, but when I compared both images (by zooming in in photoshop) they are not the same. Looks like the screencapture was worse quality. I saved the image I compare to as a Windows Bitmap 24 bit and the image I capture I am not sure what quality it is. Although my screen resolution is 32 bit. Is there someway that I can make sure that the image I capture and the image I compare to are the same bit depth and quality using c#? Here is some code I have public static Bitmap GetWindowCaptureAsBitmap(int handle) { #region GetWindowCaptureAsBitmap IntPtr hWnd = new IntPtr(handle); Win32.Rect rc = new Win32.Rect(); if (!Win32.GetWindowRect(hWnd, ref rc)) return null; // create a bitmap from the visible clipping bounds of //the graphics object from the **window** Bitmap bitmap = new Bitmap(rc.Width, rc.Height); // create a graphics object from the bitmap Graphics gfxBitmap = Graphics.FromImage(bitmap); // get a device context for the bitmap IntPtr hdcBitmap = gfxBitmap.GetHdc(); // get a device context for the **window** IntPtr hdcWindow = Win32.GetWindowDC(hWnd); // bitblt the **window** to the bitmap Win32.BitBlt(hdcBitmap, 0, 0, rc.Width, rc.Height, hdcWindow, 0, 0, (int)Win32.TernaryRasterOperations.SRCCOPY); // release the bitmap's device context gfxBitmap.ReleaseHdc(hdcBitmap); Win32.ReleaseDC(hWnd, hdcWindow); // dispose of the bitmap's graphics object gfxBitmap.Dispose(); // return the bitmap of the **window** return bitmap; #endregion } private bool IsPlayersTurn(Image imgScreen) {

    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