Click here to Skip to main content
15,890,557 members
Home / Discussions / C#
   

C#

 
AnswerRe: ******** into the wind? Pin
Josh Smith16-Jun-06 4:48
Josh Smith16-Jun-06 4:48 
AnswerRe: ******** into the wind? Pin
BoneSoft16-Jun-06 10:29
BoneSoft16-Jun-06 10:29 
QuestionPanel_paint method Pin
reshsilk16-Jun-06 4:21
reshsilk16-Jun-06 4:21 
AnswerRe: Panel_paint method Pin
Josh Smith16-Jun-06 4:26
Josh Smith16-Jun-06 4:26 
GeneralRe: Panel_paint method Pin
Guffa16-Jun-06 5:00
Guffa16-Jun-06 5:00 
GeneralRe: Panel_paint method Pin
reshsilk16-Jun-06 5:08
reshsilk16-Jun-06 5:08 
Questiondatatype error datagridview Pin
adamoz16-Jun-06 4:17
adamoz16-Jun-06 4:17 
QuestionScreen Capture Image bit depth question.. [modified] Pin
Greg Ellis16-Jun-06 4:16
Greg Ellis16-Jun-06 4:16 
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)<br />
        {<br />
            #region GetWindowCaptureAsBitmap<br />
            IntPtr hWnd = new IntPtr(handle);<br />
            Win32.Rect rc = new Win32.Rect();<br />
            if (!Win32.GetWindowRect(hWnd, ref rc))<br />
                return null;<br />
<br />
<br />
            // create a bitmap from the visible clipping bounds of <br />
            //the graphics object from the <br />
            IntPtr hdcWindow = Win32.GetWindowDC(hWnd);<br />
<br />
            // bitblt the ^__B style="COLOR: black; BACKGROUND-COLOR: #ff9999">window to the bitmap<br />
            Win32.BitBlt(hdcBitmap, 0, 0, rc.Width, rc.Height,<br />
                hdcWindow, 0, 0, (int)Win32.TernaryRasterOperations.SRCCOPY);<br />
<br />
            // release the bitmap's device context<br />
            gfxBitmap.ReleaseHdc(hdcBitmap);<br />
<br />
<br />
            Win32.ReleaseDC(hWnd, hdcWindow);<br />
<br />
            // dispose of the bitmap's graphics object<br />
            gfxBitmap.Dispose();<br />
<br />
            // return the bitmap of the ^__B style="COLOR: black; BACKGROUND-COLOR: #ff9999">window<br />
            return bitmap;<br />
            #endregion<br />
        }<br />


private bool IsPlayersTurn(Image imgScreen)<br />
        {<br />
            #region IsPlayersTurn<br />
            bool bRetVal = false;<br />
<br />
            Image imgIsPlayerTurn = EmbeddedResources.LoadImage(EmbeddedResources.PartyIsPlayersTurn);<br />
            Bitmap IsPlayerTurn = GetImage(imgScreen, 188, 463, 455, 11);<br />
            Bitmap oCompare = new Bitmap(imgIsPlayerTurn);<br />
<br />
            <br />
            if (Imagio.ComparingImages.Compare(IsPlayerTurn, oCompare) == Imagio.ComparingImages.CompareResult.ciCompareOk)<br />
            {<br />
                bRetVal = true;<br />
                Debug.WriteLine("Match OK"); //NEVER gets here anymore<br />
            }<br />
            <br />
            return bRetVal;<br />
            #endregion<br />
        }



Thanks,
Greg

-- modified at 10:20 Friday 16th June, 2006
QuestionProblem opening and reading file [modified] Pin
jjvainav16-Jun-06 4:14
jjvainav16-Jun-06 4:14 
AnswerRe: Problem openning and reading file Pin
Chikuu16-Jun-06 5:05
Chikuu16-Jun-06 5:05 
GeneralRe: Problem openning and reading file Pin
jjvainav16-Jun-06 5:55
jjvainav16-Jun-06 5:55 
GeneralRe: Problem openning and reading file Pin
Rizwan Majeed16-Jun-06 6:41
professionalRizwan Majeed16-Jun-06 6:41 
AnswerRe: Problem opening and reading file Pin
BoneSoft16-Jun-06 10:39
BoneSoft16-Jun-06 10:39 
QuestionCreation of Wizard to generate C# files Pin
tom groezer16-Jun-06 3:56
tom groezer16-Jun-06 3:56 
QuestionHow to show files in listView Pin
akualopetak16-Jun-06 3:13
akualopetak16-Jun-06 3:13 
AnswerRe: How to show files in listView Pin
Robert Rohde16-Jun-06 3:51
Robert Rohde16-Jun-06 3:51 
Questionproblem with Tab Key & Mouse click Pin
maaran16-Jun-06 2:39
maaran16-Jun-06 2:39 
AnswerRe: problem with Tab Key & Mouse click Pin
aarthi@yahoo.com16-Jun-06 3:08
aarthi@yahoo.com16-Jun-06 3:08 
QuestionUrgent Pin
Shiv516-Jun-06 2:33
Shiv516-Jun-06 2:33 
AnswerRe: Urgent Pin
J4amieC16-Jun-06 3:18
J4amieC16-Jun-06 3:18 
QuestionReading Excel to Dataset Pin
meeram39516-Jun-06 2:09
meeram39516-Jun-06 2:09 
AnswerRe: Reading Excel to Dataset Pin
Eric Dahlvang16-Jun-06 3:16
Eric Dahlvang16-Jun-06 3:16 
GeneralRe: Reading Excel to Dataset Pin
meeram39516-Jun-06 4:37
meeram39516-Jun-06 4:37 
GeneralRe: Reading Excel to Dataset Pin
Eric Dahlvang16-Jun-06 10:01
Eric Dahlvang16-Jun-06 10:01 
QuestionDataGridView scrolling problem Pin
florinp316-Jun-06 2:06
florinp316-Jun-06 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.