Jump to content

Recommended Posts

Posted (edited)

@UEZ very nice !
In your example1, I tried to save the WebP in a jpg format, just after the WebP image was displayed inside the GUI. To do so, I added 3 lines to the script (they're commented below)

...
GUISetState()

; Global $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
; _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & "\WebP_to_jpg.jpg")
; _GDIPlus_ImageDispose($hImage)

_WinAPI_DeleteObject($hBitmap)
...

If you think something is wrong with these 3 lines, please be kind to indicate what needs to be changed.
Thank you :)

Edit: any idea why the content of these 2 functions is exactly the same ?
_GDIPlus_BitmapDispose()
_GDIPlus_ImageDispose()

Edited by pixelsearch
Posted

@pixelsearchthere is a problem with GDIPlus image which will be created inside the DLL and returned from the function. Oddly enough, I can create a GDI bitmap from this bitmap inside the DLL, but the bitmap doesn't work with the GDIPlus functions outside - I'm working on it.

 

2 hours ago, pixelsearch said:

_GDIPlus_BitmapDispose()
_GDIPlus_ImageDispose()

There is no difference, just the function name. GdipDisposeImage is for both - bitmaps and images.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • UEZ changed the title to WebP v0.2.0 build 2022-04-21 beta
Posted (edited)

I fixed the issue inside the DLL - there was an issue with GdipCreateBitmapFromScan0 referring to the pointer of an array of bytes that contains the pixel data.

I updated the DLLs -> download the 7Z archive from post #1

Thanks for testing.

You can use also

Global Const $hImage = WebP_BitmapCreateGDIp($sFile)

to get the GDI+ image which you can save using _GDIPlus_ImageSaveToFile.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • UEZ changed the title to WebP v0.2.5 build 2022-04-30 beta
Posted

New version: added "simple" compression functions for lossless and lossy encoding -> see post #1. Advanced version will come later...

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • UEZ changed the title to WebP v0.3.0 build 2022-05-07 beta
Posted

New version: added advanced compression functions for lossless and lossy encoding and WebP Advanced Encoder GUI -> see post #1

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • UEZ changed the title to WebP v0.3.1 build 2022-06-15 beta
Posted (edited)

Updated DLL and WebP Advanced Encoder GUI code.

If you are interested, have a look to the post #1 for download link. 

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • UEZ changed the title to WebP v0.3.1 build 2022-06-18 beta
  • 2 years later...
Posted

Try this:

Example1.au3

;Coded by UEZ
#AutoIt3Wrapper_UseX64=y
#include <GUIConstantsEx.au3>
#include "WebP.au3"

;~ Global $sFile
Global $sFile = FileOpenDialog("Select an image", "", "Images (*.webp)")
If @error Then Exit

Global Const $STM_SETIMAGE = 0x0172
_GDIPlus_Startup()
Global Const $hImage = WebP_BitmapCreateGDIp($sFile)    ;load webp image as gdiplus
Global Const $hImage_Scaled = _GDIPlus_ImageScale($hImage, 0.5, 0.5) ;shrink image to 50%
Global Const $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Scaled) ;convert gdiplus image to gdi image
_GDIPlus_ImageDispose($hImage_Scaled) ;dispose gdiplus image
_GDIPlus_ImageDispose($hImage) ;dispose gdiplus image

;get image dimension from gdi image
Global $tDim = DllStructCreate($tagBITMAP)
DllCall("gdi32.dll", "int", "GetObject", "int", $hBitmap, "int", DllStructGetSize($tDim), "ptr", DllStructGetPtr($tDim))
Global Const $iW = DllStructGetData($tDim, "bmWidth"), $iH = DllStructGetData($tDim, "bmHeight")
;display shrinked image in GUI
Global Const $hGUI = GUICreate("WebP Image Viewer", $iW, $iH)
GUISetBkColor(0xFFFFFF)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1)
_WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap))
GUISetState()
_WinAPI_DeleteObject($hBitmap) ;dispose gdi image
_GDIPlus_Shutdown()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted
3 minutes ago, UEZ said:

Try this:

Example1.au3

;Coded by UEZ
#AutoIt3Wrapper_UseX64=y
#include <GUIConstantsEx.au3>
#include "WebP.au3"

;~ Global $sFile
Global $sFile = FileOpenDialog("Select an image", "", "Images (*.webp)")
If @error Then Exit

Global Const $STM_SETIMAGE = 0x0172
_GDIPlus_Startup()
Global Const $hImage = WebP_BitmapCreateGDIp($sFile)    ;load webp image as gdiplus
Global Const $hImage_Scaled = _GDIPlus_ImageScale($hImage, 0.5, 0.5) ;shrink image to 50%
Global Const $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage_Scaled) ;convert gdiplus image to gdi image
_GDIPlus_ImageDispose($hImage_Scaled) ;dispose gdiplus image
_GDIPlus_ImageDispose($hImage) ;dispose gdiplus image

;get image dimension from gdi image
Global $tDim = DllStructCreate($tagBITMAP)
DllCall("gdi32.dll", "int", "GetObject", "int", $hBitmap, "int", DllStructGetSize($tDim), "ptr", DllStructGetPtr($tDim))
Global Const $iW = DllStructGetData($tDim, "bmWidth"), $iH = DllStructGetData($tDim, "bmHeight")
;display shrinked image in GUI
Global Const $hGUI = GUICreate("WebP Image Viewer", $iW, $iH)
GUISetBkColor(0xFFFFFF)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1)
_WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap))
GUISetState()
_WinAPI_DeleteObject($hBitmap) ;dispose gdi image
_GDIPlus_Shutdown()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

 

Thanks but also showing full screen i want to change the image size to fit in gui width 1000 and 562. I will try _GDIPlus_ImageScale Function. Thanks a lot.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...