07-04-2012, 12:34 PM
Examples with GflAx component.
Image manipulation
Need it to save/load png.
Macro capture image and save in png format
Macro get color from png file
Macro find color or image in png file
Function BitmapHandleToIPicture
Image manipulation
Need it to save/load png.
Macro capture image and save in png format
;file
str sFile="$desktop$\qm test png.png"
;________________________
;capture to memory
__GdiHandle hb
CaptureImageOnScreen(0 0 ScreenWidth ScreenHeight "" hb)
;save as png
typelib GflAx {059321F1-207A-47A7-93A1-29CDF876FDD3} 1.0
GflAx.GflAx g._create
g.SetPicture(BitmapHandleToIPicture(hb))
g.SaveFormat=GflAx.AX_PNG ;;use other constants to save in other formats
g.SaveBitmap(_s.expandpath(sFile))
;________________________
;show the image
run sFileMacro get color from png file
;file, pixel
str sFile="$desktop$\qm test png.png"
int x(8) y(100)
;int x(xm) y(ym) ;;from mouse
;________________________
;open file
typelib GflAx {059321F1-207A-47A7-93A1-29CDF876FDD3} 1.0
GflAx.GflAx g._create
g.LoadBitmap(_s.expandpath(sFile))
;get pixel color
int color=g.GetColorAt(x y)
out "0x%06X" colorMacro find color or image in png file
;file, pixel
str sFile="$desktop$\qm test png.png"
;int color=0xFFE0C0
int color=pixel(xm ym) ;;color from mouse
;________________________
;open file
typelib GflAx {059321F1-207A-47A7-93A1-29CDF876FDD3} 1.0
GflAx.GflAx g._create
g.LoadBitmap(_s.expandpath(sFile))
;get bitmap handle
IPicture p=g.GetPicture
int hb; p.get_Handle(hb)
;find color in bitmap (in memory)
RECT r
if scan(F"color:{color}" hb r 0x280)
,out "color 0x%06X found at x=%i y=%i" color r.left r.top
else out "not found"
;to find image: if scan("file.bmp" hb r 0x280)Function BitmapHandleToIPicture
