ColorReplace 명령어는 비트맵의 특정색상을 모두 교체하거나
특정색상을 제외한 다른 모든색을 교체 하는데 사용합니다.
ImageSearch 명령어와 병용해서 사용하면 효과적인 코딩이 가능합니다.
ColorReplace , hNewBmpVar, hOrgBmp, searchColor, replaceColor [, option]
[결과값]
ErrorLevel = 0 : 명령어 정상 실행
ErrorLevel = 1 : 명령어 실행 오류
[변수]
searchColor : 찾아야 할 컬러값(여러개의 컬러일 경우 '|' 기호로 구분)
replaceColor : 교체할 컬러값
[옵션]
*BGR : BGR 컬러를 사용할때 쓰는 옵션이며, 이 옵션이 없을시 RGB 로 적용 됩니다.
*Except : searchColor 값을 제외한 모든 컬러값을 교체합니다.
*SrcNotDel : hOrgBmp 핸들을 초기화 하지 않습니다. 이 옵션이 없을시엔 초기화 됩니다.
*n(variation) : 0~255사이의 숫자값으로 searchColor 값에 공차값을 적용합니다.
주의 1) hOrgBmp가 DC에서 사용중인 경우 DC에서 선택해제 후에 사용해야 합니다.
주의 2) 반환되는 hNewBmpVar 핸들은 사용이 끝날시 꼭 초기화 시켜줘야 합니다.
->ex) DllCall("DeleteObject", Ptr,hNewBmpVar)
Test.ahk 파일을 다운로드한 'Ahk+ 전용 AutoHotkey.exe 파일' 위에 드래그해서 실행하세요.
사용예)
bmpFile = 0.원본비트맵.bmp
ImageGet, hBitmapOrg,,,,, bmpFile
cRed := 0xED1C24
cBlack := 0x000000
cBlue := 0x00A2E8
;빨강색 -> 검정색
;*SrcNotDel 옵션시 hBitmapOrg 핸들값은 ColorReplace 명령후에도 유지된다.
ColorReplace, hBitmap, hBitmapOrg, cRed, cBlack, *SrcNotDel
SaveHBITMAPToFile(hBitmap, "1.빨강색-검정색.bmp")
DllCall("DeleteObject", Ptr,hBitmap)
;검정색 -> 빨강색
ColorReplace, hBitmap, hBitmapOrg, cBlack, cRed, *SrcNotDel
SaveHBITMAPToFile(hBitmap, "2.검정색-빨강색.bmp")
DllCall("DeleteObject", Ptr,hBitmap)
;빨강색을 제외한 모든색상 파랑색으로 교체
ColorReplace, hBitmap, hBitmapOrg, cRed, cBlue, *SrcNotDel *Except
SaveHBITMAPToFile(hBitmap, "3.빨강색제외-파랑색.bmp")
DllCall("DeleteObject", Ptr,hBitmap)
;검정색을 제외한 모든색상 파랑색으로 교체
ColorReplace, hBitmap, hBitmapOrg, cBlack, cBlue, *SrcNotDel *Except
SaveHBITMAPToFile(hBitmap, "4.검은색제외-파랑색.bmp")
DllCall("DeleteObject", Ptr,hBitmap)
;사용이 끝난 hBitmapOrg 비트맵 해제
DllCall("DeleteObject", Ptr,hBitmapOrg)
0. 원본비트맵
1. 빨강->검정 2.검정->빨강
3.빨강제외->파랑 4.검정제외->파랑
'AHK+ 명령어' 카테고리의 다른 글
오토핫키+ PixelSearch 기능 확장 (17) | 2015.09.28 |
---|---|
오토핫키+ ImageCompare 명령어 추가 (8) | 2015.09.19 |
오토핫키+ CursorMatchTest 명령어 추가 (0) | 2015.09.18 |
오토핫키+ ImageGet 명령어 추가 (28) | 2015.09.06 |
오토핫키+ ImageSearch 명령어 기능 확장 (8) | 2015.09.04 |