GDI+ standard library 1.45 by tic
Re: GDI+ standard library 1.45 by tic
There should be one here:
https://github.com/buliasz/AHKv2-Gdip
I was hoping buliasz would post it himself.
https://github.com/buliasz/AHKv2-Gdip
I was hoping buliasz would post it himself.
Re: GDI+ standard library 1.45 by tic
Wasn't aware that had been created. That's good to know.
Re: GDI+ standard library 1.45 by tic
For google findability: the buliasz github file is a v2 version of the Gdip_All.ahk GDI+ library that is compatible with AutoHotKey v2.beta3 .
This is worth mentioning because some other posts and versions in the v2 forums are not compatible with v2.beta3.
Another v2.beta3 compatible version is by TheArkive at github and AHK forum. It also contains C++ source for the mcode.
Re: GDI+ standard library 1.45 by tic
@robodesign Someone came to me with a modification of one of my functions, and it appears that it is incorrectly changed. Please see the last below.
viewtopic.php?f=76&t=99406
viewtopic.php?f=76&t=99406
-
- Posts: 934
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: GDI+ standard library 1.45 by tic
After repeated tests... your claims seem to be unfounded and easily to refute. They were hastly formulated. Please download/use the latest version of the library. Your functions were not broken.iseahound wrote: ↑27 Jan 2022, 19:25@robodesign Someone came to me with a modification of one of my functions, and it appears that it is incorrectly changed. Please see the last below.
viewtopic.php?f=76&t=99406
But thank you for signaling a potential bug.
Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Re: GDI+ standard library 1.45 by tic
For the Gdip_BitmapFromHWND , it casued flicker under win11 with high frequency call . changed the PrintWindow with bitblt , it works without flicker.
Code: Select all
Gdip_BitmapFromHWND(hwnd)
{
WinGetPos,,, Width, Height, ahk_id %hwnd%
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
RegExMatch(A_OsVersion, "\d+", Version)
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
return pBitmap
}
Re: GDI+ standard library 1.45 by tic
I have a strange issue:
Using old Gdip_All_dropbox.ahk the script works, but updating to the new version on github it saves a black screenshot (with correct width/height)
I am using AHK 1.1.35.00 with Win7 32 bit.
Could please give a a hand?
Thank you.
Using old Gdip_All_dropbox.ahk the script works, but updating to the new version on github it saves a black screenshot (with correct width/height)
I am using AHK 1.1.35.00 with Win7 32 bit.
Could please give a a hand?
Thank you.
Code: Select all
;dont work, black output:
#include Gdip_All.ahk ; https://github.com/marius-sucan/AHK-GDIp-Library-Compilation
;works:
;#include Gdip_All_dropbox.ahk ; https://www.dropbox.com/s/0e9gdfetbfa8v0o/Gdip_All.ahk
hwnd:=WinExist("ahk_exe msedge.exe")
if (hwnd)
{
msgbox hwnd=%hwnd% ; hwnd=0x1b0a50
ptok := Gdip_startup()
;win1 := Gdip_BitmapFromScreen( "hwnd:" . hwnd ) ; Note: always works
win1 := Gdip_BitmapFromHWND( hwnd)
msgbox Result Gdip_BitmapFromHWND: %win1% ; Result Gdip_BitmapFromHWND: 25436720
save1:=Gdip_SaveBitmapToFile(win1,"win1.PNG")
msgbox result Save= %save1% ; result Save= 0
Gdip_disposeImage( win1 )
Gdip_shutdown(ptok)
}
Re: GDI+ standard library 1.45 by tic
In the Gdip_BitmapFromHWND() function, replace this line:
…to these:
Code: Select all
PrintWindow(hwnd, hdc)
Code: Select all
RegExMatch(A_OsVersion, "\d+", Version)
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
-
- Posts: 934
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: GDI+ standard library 1.45 by tic
I'll fix this. Thank you.boiler wrote: ↑26 Nov 2022, 02:39In the Gdip_BitmapFromHWND() function, replace this line:…to these:Code: Select all
PrintWindow(hwnd, hdc)
Code: Select all
RegExMatch(A_OsVersion, "\d+", Version) PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Re: GDI+ standard library 1.45 by tic
I'm trying to test out the different InterpolationModes for resizing an image to be larger than the original. I'm using Gdip_ResizeBitmap() to do the resizing, but no matter what value I give it for InterpolationMode it creates identical results. Here's my code.
However, swapping out the call to Gdip_ResizeBitmap() for the following seems to work fine. What am I missing?
Also while I'm at it, would setting different SmoothingModes on the graphics have an effect on the resizing operation?
Code: Select all
OriginalFile:=A_ScriptDir "\bscckey00000.png"
RequestedWidth:=RequestedHeight:=64
InterpolationMode:=["Default","LowQuality","HighQuality","Bilinear","Bicubic","NearestNeighbor","HighQualityBilinear","HighQualityBicubic"]
InterpolationMode.RemoveAt(0)
MsgBox % st_printArr(InterpolationMode)
pToken:=Gdip_Startup()
For InterpMode,v1 in InterpolationMode
{
NewPath:=A_ScriptDir "\bscckey00000_" v1 ".bmp"
pBitmapFile:=Gdip_CreateBitmapFromFile(OriginalFile) ; Get the bitmap of the original file
pBitmap:=Gdip_ResizeBitmap(pBitmapFile,RequestedWidth,RequestedHeight,1,InterpMode,0x26200A)
Gdip_DisposeImage(pBitmapFile) ; Delete the bitmap of the original image
Gdip_SaveBitmapToFile(pBitmap,NewPath) ; Save the new bitmap to file
Gdip_DisposeImage(pBitmap) ; Delete the new bitmap
}
Gdip_Shutdown(pToken)
ExitApp
st_printArr(array, depth=5, indentLevel=""){
list:=""
for k,v in Array
{
list.= indentLevel "[" k "]"
if (IsObject(v) && depth>1)
list.="`r`n" st_printArr(v, depth-1, indentLevel . " ")
Else
list.=" => " v
list.="`r`n"
}
return rtrim(list)
}
#Include %A_ScriptDir%\lib\Gdip_All.ahk
Code: Select all
pBitmap:=Gdip_CreateBitmap(RequestedWidth,RequestedHeight,0x26200A) ; Create a new 32-bit RGBA bitmap
G:=Gdip_GraphicsFromImage(pBitmap) ; Get a pointer to the graphics of the bitmap
Gdip_SetInterpolationMode(G,InterpMode) ; Set Interpolation Mode
Gdip_DrawImage(G,pBitmapFile,0,0,RequestedWidth,RequestedHeight) ; Draw the original image onto the new bitmap
-
- Posts: 934
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: GDI+ standard library 1.45 by tic
I'm under the impression you are passing strings. Such as default, low quality and so on...
You must pass numbers, values. For example, 5 for lowest quality, 7 for highest.
Smoothing mode doesn't affect resizing of bitmaps.
You must pass numbers, values. For example, 5 for lowest quality, 7 for highest.
Smoothing mode doesn't affect resizing of bitmaps.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Re: GDI+ standard library 1.45 by tic
I'm passing the key from the array to the Gdip_ResizeBitma() function, which is a number, and using the value (human friendly term) in the file name. I have manipulated the array to start at index 0.robodesign wrote: ↑21 Mar 2023, 17:12I'm under the impression you are passing strings. Such as default, low quality and so on...
You must pass numbers, values.
Thanks.
Re: GDI+ standard library 1.45 by tic
@robodesign
I haven't figured out what my issue with using Gdip_ResizeBitmap() with different values for InterpolationMode might be, but I have noticed that pBrush isn't always initialized but isalways queried always queried when the pointer to the Graphics is successfully created (which throws a warning), and when it is created it is never deleted. I think the function is missing a call to Gdip_DeleteBrush(pBrush) in that case?
I haven't figured out what my issue with using Gdip_ResizeBitmap() with different values for InterpolationMode might be, but I have noticed that pBrush isn't always initialized but is
-
- Posts: 934
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: GDI+ standard library 1.45 by tic
Yes, you are correct. I omitted to delete the brush when bgrColor was provided.Sam_ wrote: ↑22 Mar 2023, 17:40@robodesign
I haven't figured out what my issue with using Gdip_ResizeBitmap() with different values for InterpolationMode might be, but I have noticed that pBrush isn't always initialized but isalways queriedalways queried when the pointer to the Graphics is successfully created (which throws a warning), and when it is created it is never deleted. I think the function is missing a call to Gdip_DeleteBrush(pBrush) in that case?
I updated the library with numerous fixes and improvements, and new functions. Current version now is v1.94.
Please download it from:
https://github.com/marius-sucan/AHK-GDIp-Library-Compilation
Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Re: GDI+ standard library 1.45 by tic
When I used the library within a script that runs as admin, it always crashes at "Gdip_Shutdown(pToken)".
ChatGPT suggested "explicit library loading and unloading" by adding a line to the function, which made things work perfectly:
ChatGPT suggested "explicit library loading and unloading" by adding a line to the function, which made things work perfectly:
Code: Select all
Gdip_Shutdown(pToken) {
hModule := DllCall("LoadLibrary", "Str", "gdiplus.dll")
DllCall("GdiplusShutdown", "UPtr", pToken)
DllCall("FreeLibrary", "UPtr", hModule)
return 0
}
Re: GDI+ standard library 1.45 by tic
Hi
idk but something is different in 1.94 for "Gdip_TextToGraphics()".
I get more or less random colors. If I use the complete 1.94 Version and change only the "Gdip_TextToGraphics()" back to 1.92 then everything is fine and works well with my own colors.
Strange thing...
I have no sample code, because it's to complex for the whole thing...
but I use this in my class:
I can live with only replacing "Gdip_TextToGraphics()" and otherwise using 1.94. Just wanted to let you know here.
GreetingZ
KruschenZ
idk but something is different in 1.94 for "Gdip_TextToGraphics()".
I get more or less random colors. If I use the complete 1.94 Version and change only the "Gdip_TextToGraphics()" back to 1.92 then everything is fine and works well with my own colors.
Strange thing...
I have no sample code, because it's to complex for the whole thing...
but I use this in my class:
Code: Select all
GDIp_Brush := GDIp_BrushCreateSolid( "0xFF" GUI_Color_FontControl )
, GDIp_TextToGraphics( GDIp_Graphic, This.Text, "s" This.Font_Size " Center R3 vCenter c" GDIp_Brush " x" This.GUI_Control_Size " y2", This.Font, This.GUI_Control_Width_2, This.GUI_Control_Height - 1 )
, GDIp_DeleteBrush( GDIp_Brush )
GreetingZ
KruschenZ
-
- Posts: 934
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: GDI+ standard library 1.45 by tic
Please offer a clear example. I'd be happy to fix the bug if there's one. Thank you.
Best regards, Marius.
Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Re: GDI+ standard library 1.45 by tic
Hi @robodesign,
here I have a simple example for that:
with 1.94 with 1.92
Thank you
GreetingZ
KruschenZ
here I have a simple example for that:
with 1.94 with 1.92
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Persistent
#SingleInstance, Force
#Include %A_LineFile%\..\Gdip_All.ahk
GDIp_Startup()
GUI_Color_FontNormal := "FF0000"
GUI_Color_FontControl := "EB0000"
GUI_Color_BG := "000000"
GUI_Color_BGControl := "141414"
GUI_Color_Border := "FF0000"
Gui, New
Gui, Default
Gui, Color, % GUI_Color_BG
Gui, Font, s12 c%GUI_Color_FontNormal% Arial
Gui, Add, Text,, ABC abc
Gui, Add, Picture, w100 h100 HwndH_Icon +BackgroundTrans Icon2, % A_WinDir "\System32\shell32.dll"
GDIp_BitMap := GDIp_CreateBitmap(100, 102)
GDIp_Graphic := GDIp_GraphicsFromImage( GDIp_BitMap )
;BackGround
GDIp_Brush := GDIp_BrushCreateSolid( "0xFF" GUI_Color_BGControl )
GDIp_FillRectangle( GDIp_Graphic, GDIp_Brush, 0, 0, 100, 101)
GDIp_DeleteBrush( GDIp_Brush )
;Border
GDIp_Pen := GDIp_CreatePen( "0xFF" GUI_Color_Border, 2 )
GDIp_DrawRoundedRectangle( GDIp_Graphic, GDIp_Pen, 0, 0, 100, 102, 0 )
GDIp_DeletePen( GDIp_Pen )
;Adding: Text
GDIp_Brush := GDIp_BrushCreateSolid( "0xFF" GUI_Color_FontControl )
GDIp_TextToGraphics( GDIp_Graphic, "This is a test.", "s13 Bold NoWrap vCenter c" GDIp_Brush " x2 y3 ", "Arial", 100, 99)
GDIp_DeleteBrush( GDIp_Brush )
GDIp_DeleteGraphics( GDIp_Graphic )
Image_On := GDIp_CreateHBITMAPFromBitmap( GDIp_BitMap )
GDIp_DisposeImage( GDIp_BitMap )
SetImage( H_Icon, Image_On )
Gui, Show, w200 h200
Return
GuiEscape:
GuiClose:
ExitApp
Thank you
GreetingZ
KruschenZ
-
- Posts: 934
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: GDI+ standard library 1.45 by tic
@KruschenZ . Thank you . The bug is fixed now. Please redownload the Gdip_All.ahk file from Github. It was a regression, my bad.
Thanks for the example.
Best regards, Marius.
Thanks for the example.
Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Re: GDI+ standard library 1.45 by tic
Hi @robodesign
it work's like a charm
Thank you very much for the lightning fast fix
GreetingZ
KruschenZ
it work's like a charm
Thank you very much for the lightning fast fix
GreetingZ
KruschenZ