Jump to content

How does ImageSearch handle .bmp's and transparency?


Recommended Posts

Like the title says.

I made a script, and it relies on ImageSearch and .bmp's. I need it to search for a word in a certain context, and this word has backgrounds that change constantly. For this reason, I made a bmp file of the word, and removed the background for nothing, basically (on Photoshop, I deleted the areas that did not belong to the word, leaving only the word and a transparent background behind it).

However, I wasn't able to test this yet, since it is a rare occurance, and I have no idea on what else to test it on.

So, anyone has any experience on this? Does AutoIt/Imagesearch take the transparent area as white, or does it actually recognize the transparency?

Thank you for your help and time.

Link to comment
Share on other sites

Yes make a mask.

Only check flagged pixels in the mask, like anything not bkcolor.

So two images.

Sample actual data, then use a mask to decide what to check.

EDIT:

A bmp does not have transparency by it'self. You will detect the color that represents transparent, use your mask to negate that.

Edited by Xandy
Link to comment
Share on other sites

Actually I didn't use ImageSearch.

Here is a snip example, it's to complex for me to bother adapting it to run stand alone.

Maybe you can figure out what you need from it though.

if $mask= 1 then
    for $y= 0 to $rh-1
        for $x= 0 to $rw-1
            if _GDIPlus_BitmapGetPixel($hbmpmask, $x, $y)<> 4278190080 then;if not mask ignore
                if _GDIPlus_BitmapGetPixel($hbmpscreen, $x, $y)= _GDIPlus_BitmapGetPixel($hbmprect, $x, $y) then
                    $pixelmatch+=1
                endif
            endif
        next
        if $pixelmatch> $pixelmatchmax then
            $docondition= 1
            exitloop
        endif
    next
else;no mask
    for $ii= $ay to $ay+$ah;check a programmable area of any rect size
        $pixelmatch= 0
        for $i= $ax to $ax+$aw
            $pixelmatch= 0
            for $y= 0 to $rh-1
                for $x= 0 to $rw-1
                    if _GDIPlus_BitmapGetPixel($hbmpscreen, ($i+$x)-$ax, ($ii+$y)-$ay)= _GDIPlus_BitmapGetPixel($hbmprect, $x, $y) then
                        $pixelmatch+= 1
                    endif
                    if $pixelmatch= 0 then $x= $rw
                next
                if $pixelmatch> $pixelmatchmax then
                    $docondition= 1
                    ;store point found
                    $udvariable[$macro[$macroid][$macrocommand[$macroid][0]][35]]= $i
                    $udvariable[$macro[$macroid][$macrocommand[$macroid][0]][36]]= $ii
                    $i= $ax+$aw;this will exit loop
                    $ii= $ay+$ah;this will exit loop
                    exitloop;this will exit loop
                endif
                if $pixelmatch= 0 then $y= $rh
            next;next y
        next;next i
    next;next ii
endif;end if mask
Edited by Xandy
Link to comment
Share on other sites

  • 4 years later...

@ZxPwd

Never get back your reason on how people responded you in your post especially to our developers. Learn to be more cooperative like others, lets say you open up an old thread about 4 years old but have you tried it by yourself if that code works? as what your posted comment, I think you need to check it first before posting so many related thread in this forum with the same question.

 

KS15

Edited by KickStarter15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

  • Developers
7 hours ago, ZxPwd said:

you came off as mostly rude so I had too.

You were rude already by cross posting the same question at multiple places, hence my comment. 
Don't particularly have patience for people that do that and still  don't see you care much about it do you?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...