Sign in to follow this  
Followers 0
MrKris1224

How to convert image

4 posts in this topic

Hi. I know I ask a lot of questions. This is very important. How to convert 256-color image to 16-color image?? Of course, using autoit.

Share this post


Link to post
Share on other sites

This example is taken from the _GDIPlus_BitmapCloneArea function in the help file of AutoIt version 3.3.10.2 or greater.

However, the $iFormat parameter is changed to $GDIP_PXF16RGB565, and the file extension in the ShellExecute command is corrected.

#include <GDIPlus.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBitmap, $hClone, $hImage, $iX, $iY

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Create 24 bit bitmap clone
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)
    $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $GDIP_PXF16RGB565) ; $GDIP_PXF24RGB)

    ; Save bitmap to file
    _GDIPlus_ImageSaveToFile($hClone, @MyDocumentsDir & "\GDIPlus_Image.bmp")

    ; Clean up resources
    _GDIPlus_ImageDispose($hClone)
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.bmp")
EndFunc   ;==>Example

Share this post


Link to post
Share on other sites

Unfortunately does not work :( The picture is the same as our original

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try $GDIP_PXF04INDEXED instead.

 

Or look to the _GDIPlus_BitmapConvertFormat function in the help file (runs properly on 3.3.11.3+).

 

Br,

UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0