cimgui-ahk
Auto generated ahk wrapper for Dear ImGui via cimgui
It comes with a default backend with win32 dx11
It works on , windows(x64)
Current solution is:
Use cimgui's json generate function and struct definition
The type system supports the ctypes library by thqby
https://github.com/sxzxs/cimgui-ahk
ahk binding library for cimgui
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
Re: ahk binding library for cimgui
add Log in to demo
Re: ahk binding library for cimgui
Thank you for your work.
What are its advantages over imgui4ahk? Which one should I use?
What are its advantages over imgui4ahk? Which one should I use?
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: ahk binding library for cimgui
Trying to run the examples from the freshly cloned repository (Authotkey V2.0.9):
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
Re: ahk binding library for cimgui
Sorry,sizeof is built in to version H.hoppfrosch wrote: ↑25 Sep 2023, 00:44Trying to run the examples from the freshly cloned repository (Authotkey V2.0.9):
AutoHotkey64_KAQIp0oN2Z.png
I checked it just now, and there may be a few changes that need to be made
You can run it with version H first
https://github.com/thqby/AutoHotkey_H/releases
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
Re: ahk binding library for cimgui
I have made compatibility changes to version L, version 2.0.10 testhoppfrosch wrote: ↑25 Sep 2023, 00:44Trying to run the examples from the freshly cloned repository (Authotkey V2.0.9):
AutoHotkey64_KAQIp0oN2Z.png
- hoppfrosch
- Posts: 443
- Joined: 07 Oct 2013, 04:05
- Location: Rhine-Maine-Area, Hesse, Germany
- Contact:
Re: ahk binding library for cimgui
Works now - thx for your fast response!I have made compatibility changes to version L, version 2.0.10 test
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
Re: ahk binding library for cimgui
Add demo
Re: ahk binding library for cimgui
What image formats does imgui support? I found that it can't open .avif images.
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
Re: ahk binding library for cimgui
Thanks. Can you add an example of displaying BGRA pixels?
GDIP() can display webp/avif which are emerging formats, but it can't display .jxl images because the current version of the jxl library only supports the RGB format and GdipCreateBitmapFromScan0() only supports the BGRA format and I haven't found any other GDIP function that supports RGB.
This is how gdip loads the webp:
This is the jxl library I packaged:
GDIP() can display webp/avif which are emerging formats, but it can't display .jxl images because the current version of the jxl library only supports the RGB format and GdipCreateBitmapFromScan0() only supports the BGRA format and I haven't found any other GDIP function that supports RGB.
This is how gdip loads the webp:
Code: Select all
data := FileRead(pic, "RAW")
pBits := DllCall("libwebp.dll\WebPDecodeBGRA", "uptr", data.ptr, "Int", data.size, "IntP", &pw := 0, "intP", &ph := 0, "Cdecl ptr")
DllCall("Gdiplus.dll\GdipCreateBitmapFromScan0", "Int", pw, "Int", ph, "Int", ((pw * 32 + 31) & ~31) >> 3, "UInt", 0x26200A, "Ptr", pBits, "PtrP", &pBitmap := 0)
Code: Select all
;pixel := jxl_pix(pic), pw := pixel.w, ph := pixel.h
;DllCall("Gdiplus.dll\GdipCreateBitmapFromScan0", "Int", pw, "Int", ph, "Int", ((pw * 32 + 31) & ~31) >> 3, "UInt", 0x26200A, "Ptr", pixel.ptr, "PtrP", &pBitmap := 0)
jxl_pix(buf, opt := "") { ; https://github.com/libjxl/libjxl/releases
static dll_dir := xxx "\jxl",
jth_hd := DllCall("GetModuleHandle", "str", "jxl_threads.dll")
|| (DllCall("SetDllDirectory", "Str", dll_dir), DllCall("LoadLibrary", "str", dll_dir "\jxl.dll", "Cdecl UPtr"),
DllCall("LoadLibrary", "str", dll_dir "\jxl_threads.dll", "Cdecl UPtr")),
JxlResizableParallelRunner := DllCall("GetProcAddress", "Ptr", jth_hd, "AStr", "JxlResizableParallelRunner", "ptr"),
JXL_DEC_FRAME := 0x400,
JXL_DEC_FULL_IMAGE := 0x1000,
JXL_DEC_NEED_IMAGE_OUT_BUFFER := 5,
JXL_DEC_NEED_MORE_INPUT := 2,
JXL_DEC_ERROR := 1,
JXL_DEC_BASIC_INFO := 0x40,
JXL_DEC_COLOR_ENCODING := 0x100,
JXL_DEC_FRAME_PROGRESSION := 0x8000,
JXL_DEC_SUCCESS := 0
if buf is String
buf := FileRead(buf, "RAW")
runn := DllCall("jxl_threads.dll\JxlResizableParallelRunnerCreate", "ptr", 0, "int", 8, "Ptr")
dec := DllCall("jxl.dll\JxlDecoderCreate", "ptr", 0, "Ptr")
DllCall("jxl.dll\JxlDecoderSubscribeEvents", "ptr", dec, "uint", JXL_DEC_BASIC_INFO | JXL_DEC_FULL_IMAGE, "int")
DllCall("jxl.dll\JxlDecoderSetParallelRunner", "ptr", dec, "ptr", JxlResizableParallelRunner, "ptr", runn, "int")
DllCall("jxl.dll\JxlDecoderSetInput", "ptr", dec, "ptr", buf, "uint", buf.size, "int")
DllCall("jxl.dll\JxlDecoderCloseInput", "ptr", dec, "Ptr")
fo := Buffer(24, 0)
NumPut "int", 4, "int", 2, "int64", 0, fo
loop 4
{
switch status := DllCall("jxl.dll\JxlDecoderProcessInput", "ptr", dec, "Ptr")
{
case JXL_DEC_BASIC_INFO: ;64
info := Buffer(2048, 0)
DllCall("jxl.dll\JxlDecoderGetBasicInfo", "ptr", dec, "ptr", info, "int")
pw := NumGet(info, 4, "uint")
ph := NumGet(info, 8, "uint")
th := DllCall("jxl_threads.dll\JxlResizableParallelRunnerSuggestThreads", "uint64", pw, "uint64", ph, "int")
DllCall("jxl_threads.dll\JxlResizableParallelRunnerSetThreads", "ptr", runn, "uint64", th, "Ptr")
case JXL_DEC_NEED_IMAGE_OUT_BUFFER: ;5
DllCall("jxl.dll\JxlDecoderImageOutBufferSize", "ptr", dec, "ptr", fo, "uintp", &sz := 0, "int")
out := Buffer(sz, 0), out.w := pw, out.h := ph
DllCall("jxl.dll\JxlDecoderSetImageOutBuffer", "ptr", dec, "ptr", fo, "ptr", out, "uint64", sz, "int")
case JXL_DEC_FULL_IMAGE: ;4096- One frame
break
default:
break
}
}
DllCall("jxl.dll\JxlDecoderDestroy", "ptr", dec, "Ptr")
DllCall("jxl_threads.dll\JxlResizableParallelRunnerDestroy", "ptr", runn, "Ptr")
return out
}
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
Re: ahk binding library for cimgui
I have add demo7 to show webp image from memorycrocodile wrote: ↑27 Sep 2023, 00:10Thanks. Can you add an example of displaying BGRA pixels?
GDIP() can display webp/avif which are emerging formats, but it can't display .jxl images because the current version of the jxl library only supports the RGB format and GdipCreateBitmapFromScan0() only supports the BGRA format and I haven't found any other GDIP function that supports RGB.
This is how gdip loads the webp:This is the jxl library I packaged:Code: Select all
data := FileRead(pic, "RAW") pBits := DllCall("libwebp.dll\WebPDecodeBGRA", "uptr", data.ptr, "Int", data.size, "IntP", &pw := 0, "intP", &ph := 0, "Cdecl ptr") DllCall("Gdiplus.dll\GdipCreateBitmapFromScan0", "Int", pw, "Int", ph, "Int", ((pw * 32 + 31) & ~31) >> 3, "UInt", 0x26200A, "Ptr", pBits, "PtrP", &pBitmap := 0)
Code: Select all
;pixel := jxl_pix(pic), pw := pixel.w, ph := pixel.h ;DllCall("Gdiplus.dll\GdipCreateBitmapFromScan0", "Int", pw, "Int", ph, "Int", ((pw * 32 + 31) & ~31) >> 3, "UInt", 0x26200A, "Ptr", pixel.ptr, "PtrP", &pBitmap := 0) jxl_pix(buf, opt := "") { ; https://github.com/libjxl/libjxl/releases static dll_dir := xxx "\jxl", jth_hd := DllCall("GetModuleHandle", "str", "jxl_threads.dll") || (DllCall("SetDllDirectory", "Str", dll_dir), DllCall("LoadLibrary", "str", dll_dir "\jxl.dll", "Cdecl UPtr"), DllCall("LoadLibrary", "str", dll_dir "\jxl_threads.dll", "Cdecl UPtr")), JxlResizableParallelRunner := DllCall("GetProcAddress", "Ptr", jth_hd, "AStr", "JxlResizableParallelRunner", "ptr"), JXL_DEC_FRAME := 0x400, JXL_DEC_FULL_IMAGE := 0x1000, JXL_DEC_NEED_IMAGE_OUT_BUFFER := 5, JXL_DEC_NEED_MORE_INPUT := 2, JXL_DEC_ERROR := 1, JXL_DEC_BASIC_INFO := 0x40, JXL_DEC_COLOR_ENCODING := 0x100, JXL_DEC_FRAME_PROGRESSION := 0x8000, JXL_DEC_SUCCESS := 0 if buf is String buf := FileRead(buf, "RAW") runn := DllCall("jxl_threads.dll\JxlResizableParallelRunnerCreate", "ptr", 0, "int", 8, "Ptr") dec := DllCall("jxl.dll\JxlDecoderCreate", "ptr", 0, "Ptr") DllCall("jxl.dll\JxlDecoderSubscribeEvents", "ptr", dec, "uint", JXL_DEC_BASIC_INFO | JXL_DEC_FULL_IMAGE, "int") DllCall("jxl.dll\JxlDecoderSetParallelRunner", "ptr", dec, "ptr", JxlResizableParallelRunner, "ptr", runn, "int") DllCall("jxl.dll\JxlDecoderSetInput", "ptr", dec, "ptr", buf, "uint", buf.size, "int") DllCall("jxl.dll\JxlDecoderCloseInput", "ptr", dec, "Ptr") fo := Buffer(24, 0) NumPut "int", 4, "int", 2, "int64", 0, fo loop 4 { switch status := DllCall("jxl.dll\JxlDecoderProcessInput", "ptr", dec, "Ptr") { case JXL_DEC_BASIC_INFO: ;64 info := Buffer(2048, 0) DllCall("jxl.dll\JxlDecoderGetBasicInfo", "ptr", dec, "ptr", info, "int") pw := NumGet(info, 4, "uint") ph := NumGet(info, 8, "uint") th := DllCall("jxl_threads.dll\JxlResizableParallelRunnerSuggestThreads", "uint64", pw, "uint64", ph, "int") DllCall("jxl_threads.dll\JxlResizableParallelRunnerSetThreads", "ptr", runn, "uint64", th, "Ptr") case JXL_DEC_NEED_IMAGE_OUT_BUFFER: ;5 DllCall("jxl.dll\JxlDecoderImageOutBufferSize", "ptr", dec, "ptr", fo, "uintp", &sz := 0, "int") out := Buffer(sz, 0), out.w := pw, out.h := ph DllCall("jxl.dll\JxlDecoderSetImageOutBuffer", "ptr", dec, "ptr", fo, "ptr", out, "uint64", sz, "int") case JXL_DEC_FULL_IMAGE: ;4096- One frame break default: break } } DllCall("jxl.dll\JxlDecoderDestroy", "ptr", dec, "Ptr") DllCall("jxl_threads.dll\JxlResizableParallelRunnerDestroy", "ptr", runn, "Ptr") return out }
Code: Select all
#Requires AutoHotkey v2.0
#include <wincapture>
#include <cimgui>
#DllLoad %A_ScriptDir%\libwebp.dll
wincapture.init()
pic := A_ScriptDir '\images\test.webp'
data := FileRead(pic, "RAW")
pBits := DllCall("libwebp\WebPDecodeBGRA", "uptr", data.ptr, "Int", data.size, "IntP", &pw := 0, "intP", &ph := 0, "Cdecl ptr")
bf := BitmapBuffer(pBits, ((pw * 32 + 31) & ~31) >> 3, pw, ph)
bf.show()
BMP := bf.BMP()
main()
main()
{
ui := imgui()
ui.enableviewports(true)
hwnd := ui.guicreate_unbackground('test',,, 'GetGlyphRangesDefault')
WinSetAlwaysOnTop(1, hwnd)
;使用这个方法,需要手动释放
ui.LoadTextureFromMemory(BMP, BMP.size, &out_srv := 0, &out_width := 0, &out_height := 0)
size := ui.ImageGetSize(out_srv)
is_open := true
is_open_demo := true
text := 'hi imgui'
while(ui.peekmsg())
{
ui.beginframe()
if(is_open_demo)
ui.igShowDemoWindow(&is_open_demo)
if(is_open)
{
ui.igBegin(ui.str('main'), &is_open, 0)
if(ui.igButton(ui.str('Button'), ImVec2([100, 100])))
{
MsgBox('ok')
}
ui.igImageButton(ui.str('imageButton2'), out_srv, ImVec2(size))
ui.igEnd()
}
else
{
ExitApp
}
ui.endframe()
}
ExitApp
}
Re: ahk binding library for cimgui
Thanks, but I'm terribly sorry, I originally meant to express a desire to add examples that support the RGB format, not BGRA.
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
Re: ahk binding library for cimgui
I know opencv There are existing functions ,https://github.com/thqby/opencv_ahk
Or write your own conversion function in machine code
Re: ahk binding library for cimgui
Hi, does imgui have a control similar to ListView? I'm writing a BT search script where the search results will be inserted into a specified location based on file size, which happens to utilize the ListView's automatic sorting feature. But the thing that bothers me is that ListView can only display one line of text.
Can imgui display multiple lines if it has a ListView control? Or can imgui's text control auto-sort like ListView? Very much looking forward to have an example of this.
Can imgui display multiple lines if it has a ListView control? Or can imgui's text control auto-sort like ListView? Very much looking forward to have an example of this.
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
Re: ahk binding library for cimgui
The data sorting of imgui is manually sorted by the userFeather wrote: ↑07 Oct 2023, 11:01Hi, does imgui have a control similar to ListView? I'm writing a BT search script where the search results will be inserted into a specified location based on file size, which happens to utilize the ListView's automatic sorting feature. But the thing that bothers me is that ListView can only display one line of text.
Can imgui display multiple lines if it has a ListView control? Or can imgui's text control auto-sort like ListView? Very much looking forward to have an example of this.
Multiple lines can be displayed
I added a related example, demo11
Re: ahk binding library for cimgui
Thanks, this last example impressed me and I will try to refactor my scripts using cimgui.
Is it possible for imgui to display Markdown documents? This is the feature I would most like to implement in AutoHotkey as I would like to write a note-taking software with AutoHotkey, but the current AutoHotkey is very difficult to implement. I'm really very imgui to be able to implement it!
Is it possible for imgui to display Markdown documents? This is the feature I would most like to implement in AutoHotkey as I would like to write a note-taking software with AutoHotkey, but the current AutoHotkey is very difficult to implement. I'm really very imgui to be able to implement it!
-
- Posts: 77
- Joined: 25 Dec 2018, 10:58
Re: ahk binding library for cimgui
1、Add external drawing function
Re: ahk binding library for cimgui
wow this library is great! I wish I found this a long time ago. If you have a preferred reference documentation/tutorial, Ive never heard of this lib. cimgui. And I spend a lot of time in the gui application cross-language space.
At very first glance, before reading any documentation, it looks a lot like
nicegui https://github.com/zauberzeug/nicegui or
tkinter while() frame loops in python.
do you have a quick or go-to way of setting scaling
Thanks!!
At very first glance, before reading any documentation, it looks a lot like
nicegui https://github.com/zauberzeug/nicegui or
tkinter while() frame loops in python.
do you have a quick or go-to way of setting scaling
Thanks!!
https://github.com/samfisherirl
? /Easy-Auto-GUI-for-AHK-v2 ? /Useful-AHK-v2-Libraries-and-Classes : /Pulovers-Macro-Creator-for-AHKv2 :
? /Easy-Auto-GUI-for-AHK-v2 ? /Useful-AHK-v2-Libraries-and-Classes : /Pulovers-Macro-Creator-for-AHKv2 :