Create an image from AHK - with formula - possible?

Get help with using AutoHotkey and its commands and hotkeys
Albireo
Posts: 1278
Joined: 16 Oct 2013, 13:53

Create an image from AHK - with formula - possible?

10 Sep 2020, 16:57

- I wrote a script below, that creates an image (500x500pixels).
It works - an image 500x500dpi is created. (with a resolution of 96dpi)
Is it possible to create an image with another resolution? (150 / 300 / 600 dpi?)

- Wanted to add a blue square (50x50pixels) in that picture.
I only see a black image 500x500dpi. :?

- Save the result in a png file.
It works - a png-file is created.

What have I misunderstood? (ORGB correct structure?)
This library is used - Gdip_All.ahk

Code: Select all

#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir %A_ScriptDir%

#Include Gdip_All.ahk

; https://autohotkey.com/board/topic/29449-gdi-standard-library-145-by-tic/page-2
; By trik and tik
pToken	:= Gdip_Startup()	 ; Startup Gdip
sOutput	:= "MyBitmap.png" ; File to save bitmap to.
If FileExist(sOutput)
	FileDelete %sOutput%

pToken	:= Gdip_Startup()	; Startup Gdip
pBitmap	:= Gdip_CreateBitmap(500, 500) ; Make a new bitmap, 500x500 pixels

; Create the Blue Square
Size = 50
Loop % Size
{	yPos := A_Index
	Loop % Size
	{	xPos := A_Index
		Gdip_SetPixel(pBitmap, %xPos%, %yPos%, 0x7F0000FF)	; ARGB - Blue area with 50% opacity
	}
	xPos = 1
}

Gdip_SaveBitmapToFile(pBitmap, sOutput) ; Save pBitmap to sOutput
Gdip_Shutdown(pToken) ; Shutdown Gdip

MsgBox ,,, % "Ready!", 2



I found a solution by @trik (and @tic ) which provided my inspiration.
GDI+ standard library 1.45 by tic
Add two pixels to an existing bitmap and create a new result file

Return to “Ask For Help”

Who is online

Users browsing this forum: 300ddr, Bing [Bot], Bodhi, Google [Bot], Lem2001, mikeyww, pgarza and 49 guests