http://rosettacode.org/wiki/Grayscale_image
Code: Select all
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
OnExit, Exit
; Uncomment if Gdip.ahk is not in your standard library
;#Include, Gdip.ahk
If !pToken := Gdip_Startup(){
MsgBox, 48, Gdiplus error!, Gdiplus failed to start. Please ensure you have Gdiplus on your system.
ExitApp
}
if (Gdip_LibraryVersion() < 1.30)
{
MsgBox, 48, Version error!, Please download the latest version of the gdi+ library
ExitApp
}
URLDownloadToFile, http://rosettacode.org/mw/images/4/4e/BASIC256_greyscale_Mona_Lisa.jpg, %A_ScriptDir%\Before.jpg
Width := A_ScreenWidth, Height := A_ScreenHeight
Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 1: Show, NA
hwnd1 := WinExist()
hbm := CreateDIBSection(Width, Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
File = %A_ScriptDir%\Before.jpg
Matrix = 0.2126|0.2126|0.2126|0|0|0.7152|0.7152|0.7152|0|0|0.0722|0.0722|0.0722|0|0|0|0|0|1|0|0|0|0|0|1
pBitmap := Gdip_CreateBitmapFromFile(File)
Gdip_GetDimensions(pBitmap, w, h)
Gdip_DrawImage(G, pBitmap, 0, 0, w, h, 0, 0, w, h)
Gdip_DrawImage(G, pBitmap, 0, h+10, w, h, 0, 0, w, h, Matrix)
Gdip_DisposeImage(pBitmap)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height)
return
ESC::
Exit:
Gdip_Shutdown(pToken)
ExitApp
Code: Select all
File = %A_ScriptDir%\Rosetta.htm
UrlDownloadToFile, http://rosettacode.org/wiki/RC_POP.OUT, %File%
Loop, Read, %File%
{
LineNumber = %A_Index%
Loop, parse, A_LoopReadLine, `n
{
IfInString, A_LoopReadLine, rank:
if Result is Space
Result := A_LoopReadLine
else
Result := Result . "`n" . A_LoopReadLine
IfInString, A_LoopReadLine, AutoHotkey
ahk := A_LoopReadLine
}
}
Gui, Add, Edit, w300 ReadOnly, %ahk%
Gui, Add, Edit, w300 h600 ReadOnly, %Result%
Gui, Show,, Rosetta Code Rank
FileDelete, %File%
return
Esc::
ExitApp