Jump to content
Sign in to follow this  
joshtp

PixelSearch on an image file? (JPG, GIF, BMP)

Recommended Posts

joshtp

I'm in the process of writing a "Rain Notifier", where the user selects a region on a map, then periodically downloads the radar data from the National Weather Service and checks the selected area for the presence of rain, indicated by a certain set of colors. What I'm doing now is displaying the GIF after using GUICtrlCreatePic, and then using PixelSearch on that using the handle gotten by GuiCtrlGetHandle.

However, what I'd like to do is use PixelSearch on an image file, specifically a GIF in this case, instead of having to display the radar data on screen and then use PixelSearch. I've tried using some WinApi and GDIPlus code to do this, but I'm not familiar enough with those APIs to do this.

Anyone have any suggestions how to do this?

Thanks,

-Josh

Share this post


Link to post
Share on other sites
joshtp

I'm in the process of writing a "Rain Notifier", where the user selects a region on a map, then periodically downloads the radar data from the National Weather Service and checks the selected area for the presence of rain, indicated by a certain set of colors. What I'm doing now is displaying the GIF after using GUICtrlCreatePic, and then using PixelSearch on that using the handle gotten by GuiCtrlGetHandle.

However, what I'd like to do is use PixelSearch on an image file, specifically a GIF in this case, instead of having to display the radar data on screen and then use PixelSearch. I've tried using some WinApi and GDIPlus code to do this, but I'm not familiar enough with those APIs to do this.

Anyone have any suggestions how to do this?

Thanks,

-Josh

If AutoIt cannot do this natively, is there some standalone binary that can do this for me that I can integrate into my script? Thank you

Share this post


Link to post
Share on other sites
joshtp

It appears that there is no possible way to do this natively in AutoIt, other than reading in the BMP using _GDIPlus_BitmapCreateFromFile and then recreating the PixelSearch functionality again. Somone please correct me if I'm wrong. Thank you.

Share this post


Link to post
Share on other sites
joshtp

Okay, this isn't working but it seems very close. Can someone please take a look at it and tell me if I'm on the right track? The image I'm using is:

(from Wikimedia )

#include <GDIPlus.au3>

$imageFile=@TempDir&"\image.gif"
InetGet("http://upload.wikimedia.org/wikibooks/en/7/70/Editing.gif",$imageFile,1)

_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile ($imageFile)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap ($hImage)
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)

$array=PixelSearch(0,0,$width-1,$height-1,0x000000,0,1,$hBitmap)
If @error Then
    MsgBox(0,"","Not found")
Else
    MsgBox(0,"",$array[0]&","&$array[1])
EndIf

_GDIPlus_ImageDispose ($hImage)
_WinAPI_DeleteObject ($hBitmap)
_GDIPlus_Shutdown()

Thank you all in advance for any input!

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.