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.
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
}