ftscoding

How does ImageSearch handle .bmp's and transparency?

12 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

Thanks for the answers, they surely are helpful.

I'll try to look it up and see what I can do with it, thanks

Share this post


Link to post
Share on other sites

#5 ·  Posted

Did anybody ever get too see if this worked?

Share this post


Link to post
Share on other sites

#7 ·  Posted

Which ever one it would take to get an answer faster.

Share this post


Link to post
Share on other sites

#9 ·  Posted

13 hours ago, Jos said:

Wrong answer! :mad:

I know it's the wrong answer but you came off as mostly rude so I had too.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

@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

Share this post


Link to post
Share on other sites

#11 ·  Posted

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#12 ·  Posted

Ok no problem I apologize 

Share this post


Link to post
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