;------------------------------------------------------------------------------------------
; 이미지 필터링 효과 스크립트...
;
; http://lodev.org/cgtutor/filtering.html
;
; 위 사이트의 C++ 소스코드를 오토핫키 스크립트용으로 컨버젼 해봤습니다.
; 역시 오토핫키로는 엄청나게 느려서 써먹진 못할듯 합니다.
;
;------------------------------------------------------------------------------------------

#SingleInstance Force
#include gdip.ahk ;https://autohotkey.com/board/topic/29449-gdi-standard-library-145-by-tic/
srcImageFile = 1.png
outImageFile = 2.bmp
filter := [1, 1, 1
,1, -7, 1
,1, 1, 1]
gdipToken := Gdip_Startup()
if pBmpSrc := Gdip_CreateBitmapFromFile(srcImageFile)
{
if pBmpOut := ImageFilterCore(pBmpSrc, filter)
Gdip_SaveBitmapToFile(pBmpOut, outImageFile), Gdip_DisposeImage(pBmpOut)
Gdip_DisposeImage(pBmpSrc)
}
Gdip_Shutdown(gdipToken)
MsgBox, 테스트완료
ExitApp
;filter = {w,h, factor, bias}
ImageFilterCore(pBitmap, filter)
{
if !pBitmap or !IsObject(filter) or !filter.MaxIndex()
return
factor := filter.factor? filter.factor:1.0
bias := filter.bias? filter.bias:0.0
filterW := filter.w? filter.w: filter.h? filter.MaxIndex()//filter.h:Round(Sqrt(filter.MaxIndex()))
filterH := filter.h? filter.h: filter.w? filter.MaxIndex()//filter.w:Round(Sqrt(filter.MaxIndex()))
if (filterW * filterH > filter.MaxIndex())
return
imageW := Gdip_GetImageWidth(pBitmap)
imageH := Gdip_GetImageHeight(pBitmap)
if !imageW or !imageH
return
pBmpOut := Gdip_CreateBitmap(imageW, imageH)
If Gdip_LockBits(pBitmap,0,0,imageW,imageH,StrideSrc,ScanSrc,DataSrc)
return
If Gdip_LockBits(pBmpOut,0,0,imageW,imageH,StrideOut,ScanOut,DataOut)
return
loop % imageW
{
x := A_Index - 1
loop % imageH
{
y := A_Index - 1
red := green := blue := 0.0
loop % filterH
{
filterY := A_Index - 1
loop % filterW
{
filterX := A_Index - 1
imageX := Mod(x - filterW//2 + filterX + imageW, imageW)
imageY := Mod(y - filterH//2 + filterY + imageH, imageH)
Gdip_FromARGB( Gdip_GetLockBitPixel(ScanSrc, imageX, imageY,StrideSrc) , cA, cR, cG, cB)
red += cR * filter[filterY * filterW + filterX + 1]
green += cG * filter[filterY * filterW + filterX + 1]
blue += cB * filter[filterY * filterW + filterX + 1]
}
}
cR := factor * red + bias, cG := factor * green + bias, cB := factor * blue + bias
cR := cR<0? 0: cR>255? 255: cR, cG := cG<0? 0: cG>255? 255: cG, cB := cB<0? 0: cB>255? 255: cB
Gdip_SetLockBitPixel( Gdip_ToARGB(0, cR, cG, cB) ,ScanOut,X,Y,StrideOut)
}
}
Gdip_UnlockBits(pBitmap,DataSrc)
Gdip_UnlockBits(pBitmap,DataOut)
return pBmpOut
}
'오토핫키' 카테고리의 다른 글
| 이미지 서치등 질문합니다 (0) | 2017.07.04 |
|---|---|
| 오토핫키가 바탕화면에서만 실행되네요 (0) | 2017.07.04 |
| 고수님들 조언좀 부탁드립니다 (0) | 2017.07.03 |
| 변수 선언에 관하여 여쭤볼것이 있습니다 (0) | 2017.07.01 |
| 바탕화면이나 폴더에서는 이미지써치 잘되는데 미뮤 앱플레이어에서는 안되네요 (0) | 2017.06.30 |
| 혹시 모모 앱플레이어로 오핫 사용하시는분 계세요? (0) | 2017.06.28 |
| 요즘은 오토핫키 오버워치 에임핵 다 막혔죠? (0) | 2017.06.27 |
| 이미지서치 인식이 안되여 (0) | 2017.06.27 |
| 녹스 또는 미뮤에서 이미지 서치 후 클릭 (0) | 2017.06.26 |
| [AHK C#?] PostMessage를 이용해 마우스 드래그 구현시 팁 (0) | 2017.06.26 |