Sign in to follow this  
Followers 0
au3Fan

Create 4bpp image

6 posts in this topic

#1 ·  Posted (edited)

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)
_Main()
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

Share this post


Link to post
Share on other sites



Try this:

#include <ScreenCapture.au3>
_GDIPlus_Startup()
$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")
_WinAPI_DeleteObject($hScreencapture_bmp)
_GDIPlus_BitmapDispose($hBITMAP)
_GDIPlus_BitmapDispose($hBmpClone)
_GDIPlus_ShutDown()

Br,

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

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thanks UEZ...but is like taitel says, it don´t work on XP.

I´ll try in Win7.

Share this post


Link to post
Share on other sites

Ok ....is a problem with WinXP...... on Win7 it works perfect.

Share this post


Link to post
Share on other sites

after two years, there is a solution for this. you need gdiplus.dll v1.1 on win xp. described


[color=rgb(255,0,0);][font="'comic sans ms', cursive;"]FukuLeaks[/color][/font]

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