Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

New icons, generic and costumized


  • Please log in to reply
1 reply to this topic
Zaelia
  • Members
  • 754 posts
  • Last active: Jan 17 2015 02:38 AM
  • Joined: 31 Oct 2008

I am not the first about trying to change AHK icon, however I worked on a simple design and a script for generate a customized icon. I think it is a good add to embbed the feature inside AHK2EXE (Fincs) and just get a cog (auto/script) and a key (hot or not) like a "C key" icon for discard this horrible "H" or other old thing (my opinion) for pause and suspend feature of AHK (Lexikos)... Do as you wish, maybe I can help more if you are interested. More beautiful if you generate them yourself but I give a sample:

 sample.png

This script can generate a 256*256 size picture and a multi image file icon (as current AHK_L icon, argb32 for xp+, added a png max size for vista+), maybe possible to add a lot of new thing or just a simple command line like "text-color1-color2". It did it during some insomnias so it can be half shorter with loop and a better logic, but it is more readable and you will need Gdip library...

#NoEnv
SetBatchLines,-1

;#include Gdip.ahk
;http://www.autohotkey.com/board/topic/29449-gdi-standard-library-145-by-tic/

;GUI to customize and create a generic icon file?
;Run charmap ;get a lot of cool characters
;Windows color picker control is lacking in ahk ;color1 for cog, color2 for key
;maybe a command line "TXT-RRGGBB-RRGGBB" when ".ICO" is missing for AHK2EXE

text := "AHK"
color1 := 0xff448844
color2 := 0xffeeeeee

n := 4
;number of images and size inside the icon file, 256 stored as a full PNG, other as a ARGB32 DIB
; 3 = 16,32,48 (14510 bytes)
; 4 = 16,32,48,256 (around 35000 bytes)


;########

if !(FileExist("1a.png") && FileExist("1b.png") && FileExist("2a.png") && FileExist("2b.png"))
{
	UrlDownloadToFile, http://adrien.guichard.free.fr/autohotkey/1a.png, 1a.png
	UrlDownloadToFile, http://adrien.guichard.free.fr/autohotkey/1b.png, 1b.png
	UrlDownloadToFile, http://adrien.guichard.free.fr/autohotkey/2a.png, 2a.png
	UrlDownloadToFile, http://adrien.guichard.free.fr/autohotkey/2b.png, 2b.png
}

if !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}

;######## mask1

pBitmapIn := Gdip_CreateBitmap(256, 256)
GIn := Gdip_GraphicsFromImage(pBitmapIn)
Gdip_SetSmoothingMode(GIn, 4)

pBrush := Gdip_BrushCreateSolid(color1)
Gdip_FillRectangle(GIn, pBrush, 0, 0, 256, 256)
Gdip_DeleteBrush(pBrush)

pBitmapMask := Gdip_CreateBitmap(256, 256)
GMask := Gdip_GraphicsFromImage(pBitmapMask)
Gdip_SetSmoothingMode(GMask, 4)

pBitmapFile := Gdip_CreateBitmapFromFile("1a.png")
Gdip_DrawImage(GMask, pBitmapFile, 0, 0, 256, 256, 0, 0, 256, 256)
Gdip_DisposeImage(pBitmapFile)

pBitmapOut1 := Gdip_CreateBitmap(256, 256)
E := Gdip_MaskImage(pBitmapIn, pBitmapMask, pBitmapOut1)

Gdip_DisposeImage(pBitmapIn), Gdip_DeleteGraphics(GIn)
Gdip_DisposeImage(pBitmapMask), Gdip_DeleteGraphics(GMask)

;######## mask2

pBitmapIn := Gdip_CreateBitmap(256, 256)
GIn := Gdip_GraphicsFromImage(pBitmapIn)
Gdip_SetSmoothingMode(GIn, 4)

pBrush := Gdip_BrushCreateSolid(color2)
Gdip_FillRectangle(GIn, pBrush, 0, 0, 256, 256)
Gdip_DeleteBrush(pBrush)

pBitmapMask := Gdip_CreateBitmap(256, 256)
GMask := Gdip_GraphicsFromImage(pBitmapMask)
Gdip_SetSmoothingMode(GMask, 4)

pBitmapFile := Gdip_CreateBitmapFromFile("2a.png")
Gdip_DrawImage(GMask, pBitmapFile, 0, 0, 256, 256, 0, 0, 256, 256)
Gdip_DisposeImage(pBitmapFile)

pBitmapOut2 := Gdip_CreateBitmap(256, 256)
E := Gdip_MaskImage(pBitmapIn, pBitmapMask, pBitmapOut2)

Gdip_DisposeImage(pBitmapIn), Gdip_DeleteGraphics(GIn)
Gdip_DisposeImage(pBitmapMask), Gdip_DeleteGraphics(GMask)

;######## 256.png icon source

pBitmap := Gdip_CreateBitmap(256, 256)
G := Gdip_GraphicsFromImage(pBitmap)
Gdip_SetSmoothingMode(G, 4)

pBitmapFile1 := Gdip_CreateBitmapFromFile("1b.png")
pBitmapFile2 := Gdip_CreateBitmapFromFile("2b.png")

Gdip_DrawImage(G, pBitmapOut1, 0, 0, 256, 256, 0, 0, 256, 256)
Gdip_DrawImage(G, pBitmapFile1, 0, 0, 256, 256, 0, 0, 256, 256)
Gdip_DrawImage(G, pBitmapOut2, 0, 0, 256, 256, 0, 0, 256, 256)
Gdip_DrawImage(G, pBitmapFile2, 0, 0, 256, 256, 0, 0, 256, 256)
Gdip_TextToGraphics(G, text, "X135 Y100 S44 R4 Bold")

Gdip_DisposeImage(pBitmapFile1)
Gdip_DisposeImage(pBitmapFile2)
Gdip_DisposeImage(pBitmapOut1)
Gdip_DisposeImage(pBitmapOut2)

Gdip_SaveBitmapToFile(pBitmap, "256.png")

Gdip_DisposeImage(pBitmap)
Gdip_DeleteGraphics(G)

;######## 16.bmp 32.bmp 48.bmp
;gdi+ save them as ARGB32.dib with extra header

loop 3
{
	pBitmapFile := Gdip_CreateBitmapFromFile("256.png")
	pBitmap0 := Gdip_CreateBitmap(16*a_index, 16*a_index)
	G := Gdip_GraphicsFromImage(pBitmap0)
	Gdip_SetSmoothingMode(G, 4)
	Gdip_SetInterpolationMode(G, 7)
	Gdip_DrawImage(G, pBitmapFile, 0, 0, 16*a_index, 16*a_index, 0, 0, 256, 256)
	Gdip_SaveBitmapToFile(pBitmap0, 16*a_index ".bmp")
	Gdip_DisposeImage(pBitmap0)
	Gdip_DisposeImage(pBitmapFile)
	Gdip_DeleteGraphics(G)
}

Gdip_Shutdown(pToken)

;######## ico
;http://msdn.microsoft.com/en-us/library/ms997538.aspx

VarSetCapacity(data, 6+16*n, 0)
NumPut(1, data, 2, "UShort") ;icon file id
NumPut(n, data, 4, "UShort") ;image number
;entry 1
	NumPut(16, data, 6, "UChar") ;width
	NumPut(16, data, 7, "UChar") ;height
	NumPut(32, data, 12, "UShort") ;depth
	NumPut(40+16*16*4, data, 14, "UInt") ;size
	NumPut(6+16*n, data, 18, "UInt") ;offset
;entry 2
	NumPut(32, data, 6+16, "UChar")
	NumPut(32, data, 7+16, "UChar")
	NumPut(32, data, 12+16, "UShort")
	NumPut(40+32*32*4, data, 14+16, "UInt")
	NumPut(6+16*n+40+16*16*4, data, 18+16, "UInt")
;entry 3
	NumPut(48, data, 6+16*2, "UChar")
	NumPut(48, data, 7+16*2, "UChar")
	NumPut(32, data, 12+16*2, "UShort")
	NumPut(40+48*48*4, data, 14+16*2, "UInt")
	NumPut(6+16*n+40+16*16*4+40+32*32*4, data, 18+16*2, "UInt")
;entry 4
if (n = 4)
{
FileGetSize, size4, 256.png
	NumPut(0, data, 6+16*3, "UChar") ;size 256 = 0
	NumPut(0, data, 7+16*3, "UChar") ;size 256 = 0
	NumPut(32, data, 12+16*3, "UShort")
	NumPut(size4, data, 14+16*3, "UInt")
	NumPut(6+16*n+40+16*16*4+40+32*32*4+40+48*48*4, data, 18+16*3, "UInt")
}

;######## fix BITMAPINFOHEADER

VarSetCapacity(bih1, 40, 0)
NumPut(40, bih1, 0, "UInt") ;size
NumPut(16, bih1, 4, "UInt") ;width
NumPut(16*2, bih1, 8, "UInt") ;height*2 obsolete mask
NumPut(1, bih1, 12, "UShort") ;####del? plane, during icon entry was 0 or 1
NumPut(32, bih1, 14, "UShort") ;depth
NumPut(16*16*4, bih1, 20, "UInt") ;####del? size, this may be set to zero for an uncompressed format

VarSetCapacity(bih2, 40, 0)
NumPut(40, bih2, 0, "UInt")
NumPut(32, bih2, 4, "UInt")
NumPut(32*2, bih2, 8, "UInt")
NumPut(1, bih2, 12, "UShort")
NumPut(32, bih2, 14, "UShort")
NumPut(32*32*4, bih2, 20, "UInt")

VarSetCapacity(bih3, 40, 0)
NumPut(40, bih3, 0, "UInt")
NumPut(48, bih3, 4, "UInt")
NumPut(48*2, bih3, 8, "UInt")
NumPut(1, bih3, 12, "UShort")
NumPut(32, bih3, 14, "UShort")
NumPut(48*48*4, bih3, 20, "UInt")

;######## out%a_tickcount%.ico (else refresh problem for testing)

FileRead, data1, *c 16.bmp
FileRead, data2, *c 32.bmp
FileRead, data3, *c 48.bmp
if (n = 4)
	FileRead, data4, *c 256.png

file := FileOpen("out" a_tickcount ".ico", "w")
file.RawWrite(&data, 6+16*n) ;ico file header
file.RawWrite(&bih1, 40) ;bitmap info header
file.RawWrite(&data1+14+40, 16*16*4) ;exclude file and info headers, only get bitmap raw data ARGB32
file.RawWrite(&bih2, 40)
file.RawWrite(&data2+14+40, 32*32*4)
file.RawWrite(&bih3, 40)
file.RawWrite(&data3+14+40, 48*48*4)
if (n = 4)
	file.RawWrite(&data4, size4)
file.Close()

return

;######## http://www.autohotkey.com/board/topic/75851-trying-to-add-maskstransparency-to-bitmaps-with-gdi/

Gdip_MaskImage(pBitmapIn, pBitmapMask, ByRef pBitmapOut)
{
	static _MaskImage
	if !_MaskImage
	{
		MCode_MaskImage := "8B4424188B4C24149983E20303C283EC08C1F80285C97E758B542410535503C0568B74242403C083C203578B7C24248944241489"
		. "54242C894C2410EB038D490085F67E2E8BCA8B54241C2B5424248BC70FB6298B1C0281E3FFFFFF00C1E5180BDD891883C10483C00483EE0175E28B742"
		. "4288B54242C03542430037C2414836C2410018954242C75B75F5E5D5B33C083C408C3"

		VarSetCapacity(_MaskImage, StrLen(MCode_MaskImage)//2)
		Loop % StrLen(MCode_MaskImage)//2      ;%
			NumPut("0x" SubStr(MCode_MaskImage, (2*A_Index)-1, 2), _MaskImage, A_Index-1, "char")
	}
	
	Gdip_GetImageDimensions(pBitmapIn, Width1, Height1)
	Gdip_GetImageDimensions(pBitmapMask, Width2, Height2)
	Gdip_GetImageDimensions(pBitmapOut, Width3, Height3)
	
	if (Width1 != Width2 || Width1 != Width3 || Height1 != Height2 || Height1 != Height3)
		return -1
	
	E1 := Gdip_LockBits(pBitmapIn, 0, 0, Width1, Height1, Stride1, Scan01, BitmapData1)
	E2 := Gdip_LockBits(pBitmapMask, 0, 0, Width1, Height1, Stride2, Scan02, BitmapData2)
	E3 := Gdip_LockBits(pBitmapOut, 0, 0, Width1, Height1, Stride3, Scan03, BitmapData3)
	if (E1 || E2 || E3)
		return -2
		
	E := DllCall(&_MaskImage, "uint", Scan01, "uint", Scan02, "uint", Scan03, "int", Width1, "int", Height1, "int", Stride1)
	
	Gdip_UnlockBits(pBitmapIn, BitmapData1)
	Gdip_UnlockBits(pBitmapMask, BitmapData2)
	Gdip_UnlockBits(pBitmapOut, BitmapData3)
	return (E = "") ? -3 : E
}

"You annoy me, therefore I exist."

SnowFlake_FlowSnake
  • Members
  • 845 posts
  • Last active: Jan 24 2016 05:24 PM
  • Joined: 08 Oct 2012

plz check your inbox Zaelia :D


  • Download link of my scripts on Autohotkey.com 2/10/2015 [DOWNLAND]
  • Contact Info:  https://github.com/floowsnaake //  FloowSnaake(A)gmail.com
  • IF you need Help send me a PM,Email or Post on Github

  • Quote by tank  Posted 29 September 2015 - 06:14 PM

  • "Eventually i will find a way to convert the DB back to PHPBB3. but i dont have the bandwidth right now. No one that has tried has had success. It is the Only way i can keep this open is if i could successfully convert it."