Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Dec 2003
    Location
    Zeist, Netherlands
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Visual screen scraping (C#)

    Here's what I'd like to do: I'd like to program a something(in C#) that will accept an image as a parameter and will 'scan' a window for the image. It would then reply something like: "Image found at position 836,224!".

    I've Googled on this subject, but almost all results talked about screen scraping in DotNet, which means that you can fetch the content of some html page and use it for your own purposes (for example to include weather info on your own homepage). I don't want to get text and I don't want to use html or browsers, I want to try and find an image on a specific window in my local machine (without Internet connection).

    Any help, hint or tip would be greatly appreciated.

    __________________________________________________

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visual screen scraping (C#)

    What do you mean by "'scan' a window for the image"? Do you mean an image file? Or are you trying to compare pixels of an input image with pixels of a base image to see if the input image is contained in the base image?

    Can you give some examples?
    <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

  3. #3
    New Lounger
    Join Date
    Dec 2003
    Location
    Zeist, Netherlands
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visual screen scraping (C#)

    What I mean is indeed comparing pixels of an input image with pixels of a base image. If, for example, I'm playing chess on my computer, I'd like to compare the image of a black pawn with the chessboard on my screen (the base image) and determine where all the black pawns are. Then I can let my PC do some calculations and give me an advice for my move. Of course the position of the pawns is not nearly enough to determine my best move, but as an example I hope you get what I mean.

    This is the idea. Any suggestions on how to obtain the pixels of the game-window and compare them with the image of, for example, a pawn?

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visual screen scraping (C#)

    Not to get off-topic here, but if your goal for this process is related to chess then there are MUCH easier ways to perform chess-related calculations than trying to do this with graphics.

    I'm not terribly well-versed with .NET's GDI+ programming, but I imagine that comparing graphics would be fairly processor-intensive. For instance, I imagine it would have to search on a pixel-by-pixel basis for each pixel of the input image and each pixel of the base image. If pixel 1x1 of the input image matches any pixel of the base image, examine pixel 1x2 of the input image against the next pixel of the base image, etc.... It could be much more trouble than it's worth.

    Also, something else to consider is that the two images would have to be an exact match - pixel for pixel. It's not likely that any screenshot would be so precise as to have pixel-for-pixel matching against a control (input image).

    That's just my 2 cents <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>

  5. #5
    New Lounger
    Join Date
    Dec 2003
    Location
    Zeist, Netherlands
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visual screen scraping (C#)

    MarkJ, thank you for your response.

    I'm afraid I don't completely agree with you. First of all I would do it like this: Compare pixel 1x1 with every pixel of the base image. If they match, cut out a piece of the base image with the exact dimensions of the image you're looking for and compare these two in one comparison (not pixel by pixel). If they match, good, if not then continue. Yes, the images would have to be an exact match. For my purposes the screenshots are precise enough for me to accept this programming challenge.

    So could you (or anyone else) help me get started here?

  6. #6
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visual screen scraping (C#)

    You might try a Google search on .NET GDI+

    Here's a site I've used on occasion: GDI+ FAQ

    Hope this helps - good luck!

  7. #7
    New Lounger
    Join Date
    Dec 2003
    Location
    Zeist, Netherlands
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Visual screen scraping (C#)

    MarkJ, thank you very much! I've just peeked at the site and it seems an excellent starting place for my challenge.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •