2D QR CODE with embedded text Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
labrint
Posts: 379
Joined: 14 Jun 2017, 05:06
Location: Malta

2D QR CODE with embedded text

10 Aug 2020, 09:46

Any progress on QR codes apart from the https://www.autohotkey.com/boards/viewtopic.php?t=5538. Linked system requires two libraries and has no embedded text function.

Anyone has a silky smooth solution to the above? Perhaps a concise piece of code that I can insert at the end and use as a function without relying on bulky libraries? The embedded text / captioning of the QR code is very important.

Please help
User avatar
labrint
Posts: 379
Joined: 14 Jun 2017, 05:06
Location: Malta

Re: 2D QR CODE with embedded text  Topic is solved

18 Aug 2020, 04:49

Edit the "Testing" in the urldownloadtofile and the "Testing" in the line below to change the QR code and caption. Its important to have Gdip_All.Ahk

Code: Select all

#SingleInstance Force

; Uncomment if Gdip.ahk is not in your standard library
#Include ../Gdip_All.ahk

UrlDownloadToFile, http://chart.apis.google.com/chart?cht=qr&chs=400x400&chl=Testing&choe=UTF-8&chld=|0, C:\AHK\vcc.png

url := "http://api.img4me.com/?text=Testing&font=Impact&fcolor=000000&size=22&bcolor=FFFFFF&type=png" ;get rules from google drive

HttpRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HttpRequest.Open("GET", url)
HttpRequest.Send()
CaptionURL := HttpRequest.ResponseText

UrlDownloadToFile, %CaptionURL%, CaptionText.png

; Specify both of the files we are going to use
File1 := "vcc.png"
File2 := "CaptionText.png"

If !(FileExist(File1) && FileExist(File2))
{
	MsgBox "Cannot find image files. Retry"
	Return
}

; Start gdi+
If !pToken := Gdip_Startup()
{
	MsgBox "Gdiplus failed to start. Please ensure you have gdiplus on your system"
	ExitApp
}

; If the images we want to work with do not exist on disk, then download them...


; Create a 500x500 pixel gdi+ bitmap (this will be the entire drawing area we have to play with)
pBitmap := Gdip_CreateBitmap(600, 600)
G := Gdip_GraphicsFromImage(pBitmap)
Gdip_DeleteBrush(pBrush)


; Get bitmaps for both the files we are going to be working with
pBitmapFile1 := Gdip_CreateBitmapFromFile(File1), pBitmapFile2 := Gdip_CreateBitmapFromFile(File2)

; Get the width and height of the 1st bitmap
Width := Gdip_GetImageWidth(pBitmapFile1), Height := Gdip_GetImageHeight(pBitmapFile1)

FirstHeightIsY := Height + 15

; Draw the 1st bitmap (1st image) onto our "canvas" (the graphics of the original bitmap we created) with the same height and same width
; at coordinates (25,30).....We will be ignoring the matrix parameter for now. This can be used to change opacity and colours when drawing
Gdip_DrawImage(G, pBitmapFile1, 10, 10, Width, Height, 0, 0, Width, Height)

; Do the same again for the 2nd file, but change the coordinates to (250,260).....

Width := Gdip_GetImageWidth(pBitmapFile2), Height := Gdip_GetImageHeight(pBitmapFile2)
Gdip_DrawImage(G, pBitmapFile2, 10, FirstHeightIsY, Width, Height, 0, 0, Width, Height)


Gdip_DisposeImage(pBitmapFile1), Gdip_DisposeImage(pBitmapFile2)
Gdip_SaveBitmapToFile(pBitmap, "FinalImage.png")
Gdip_DisposeImage(pBitmap)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)

ExitApp
Return



Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5, jollyjoe and 158 guests