-
Notifications
You must be signed in to change notification settings - Fork 1
/
5 Light Up.ahk
68 lines (60 loc) · 1.3 KB
/
5 Light Up.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
SetBatchlines,-1
OnMessage(0xF,"Redraw")
;Init
#Include <gdip>
pToken:=gdip_startup()
LoadedImage:=Gdip_CreateBitmapFromFile("Test.jpg")
Gdip_LockBits(LoadedImage,0,0,Gdip_GetImageWidth(LoadedImage),Gdip_GetImageHeight(LoadedImage),LoadedStride,LoadedScan0,LoadedBitmapData)
W:=Gdip_GetImageWidth(LoadedImage)
H:=Gdip_GetImageHeight(LoadedImage)
;GUI
Gui,add, Text, x20 y20 w%w% h%h% hwndDrawArea,Loading...
Gui,Show,% "w" w+40 " h" h+40
;GDI to GUI stuff
DrawAreaDC:=GetDC(DrawArea)
GDrawArea:=gdip_graphicsfromHDC(DrawAreaDC)
BufferBitmap:=Gdip_CreateBitmap(w,h)
BufferGraphics:=gdip_GraphicsfromImage(BufferBitmap)
Gdip_LockBits(BufferBitmap,0,0,W,H,BufferStride,BufferScan0,BufferBitmapData)
Startup:
diff:= 30
max:=0xff-diff
running:=1
Loop,% W
{
x:=A_Index-1
Loop,% H
{
Gdip_FromARGB(Gdip_GetLockBitPixel(LoadedScan0, X, A_Index-1, LoadedStride), A, R, G, B)
Calc(A,R,G,B)
Gdip_SetLockBitPixel(Gdip_ToARGB(A,R,G,B), BufferScan0, X, A_Index-1, BufferStride)
}
}
Gdip_UnlockBits(BufferBitmap, BufferBitmapData)
Redraw()
return
Redraw()
{
global
Gdip_DrawImage(GDrawArea, BufferBitmap)
}
GuiClose:
ExitApp
Calc(byref A,byref R,byref G,byref B){
If (V:=(R+G+B)/3)
{
RV:=R/V
GV:=G/V
BV:=B/V
If (RV>GV)
MV:=RV
Else
MV:=GV
If (BV>MV)
MV:=BV
V:=255/MV
R:=RV*V
G:=GV*V
B:=BV*V
}
}