Jump to content

Create 4bpp image


Recommended Posts

Hi, first time here.

I'm trying to convert a 24bpp image for 4 bpp following the information contained in the AutoIt help but I'm not progressing ... this is my code:

#include <GDIPlus.au3>
Opt('MustDeclareVars', 1)
Func _Main()
    Local  $hClone, $hImage, $iX, $iY
    ; Initialize GDI+ library
    _GDIPlus_StartUp ()
    $hImage = _GDIPlus_ImageLoadFromFile (@ScriptDir & "logo.bmp")
    ; Create 4 bit bitmap clone
    $iX = _GDIPlus_ImageGetWidth ($hImage)
    $iY = _GDIPlus_ImageGetHeight ($hImage)
    $hClone = _GDIPlus_BitmapCloneArea ($hImage, 0, 0, $iX, $iY, $GDIP_PXF04INDEXED )
    ; Save bitmap to file
    _GDIPlus_ImageSaveToFile ($hClone, @ScriptDir & "logo2.bmp")
    ; Clean up resources
    _GDIPlus_ImageDispose ($hClone)
    _GDIPlus_ImageDispose ($hImage)

    ; Shut down GDI+ library
    _GDIPlus_ShutDown ()
EndFunc   ;==>_Main

Note: I tried without success the following ways:

$GDIP_PXF01INDEXED = 1 bit per pixel, indexed

$GDIP_PXF04INDEXED = 4 bits per pixel, indexed

$GDIP_PXF08INDEXED = 8 bits per pixel, indexed

$GDIP_PXF16GRAYSCALE = 16 bits per pixel, grayscale

None of them creates the final image in the specified format.

However, any RGB mode works correctly.

This is a bug? I'm forgetting some info? or GDI+ does not work with indexed images?

Please, any help is welcome...

Edit: I using WinXp Sp3 machine...

Edited by au3Fan
Link to comment
Share on other sites

Try this:

#include <ScreenCapture.au3>
$hScreencapture_bmp = _ScreenCapture_Capture("", 0, 0, 320, 256, False)
$hBITMAP = _GDIPlus_BitmapCreateFromHBITMAP($hScreencapture_bmp)
$hBmpClone = _GDIPlus_BitmapCloneArea($hBITMAP, 0, 0, 320, 256, $GDIP_PXF04INDEXED) ;save bitmap in 2^4 = 16 colors
_GDIPlus_ImageSaveToFile($hBmpClone, @ScriptDir & "Test.png")



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

Link to comment
Share on other sites

It's not working on XP sp3/32. On Windows 7 it's ok. I had the same problem. Returned @error = 0 and @extended = 3.

[edit] one workaround would be this...

Edited by taietel
Link to comment
Share on other sites

  • 1 year later...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...