jvds Posted May 4, 2020 Share Posted May 4, 2020 I want to take some images and bring their bits down from 32 bits to 8bits(256 colors) and 4 bits (16 colors) searching around for color data, it was easy to get the 4 bits color data and to add it to an array and use the color table $aColorTable= stringsplit('0-8388608-16711680-16711935-32896-32768-65280-65535-128-8388736-255-12632256-8421504-8421376-16776960-16777215','-',3) ; Create color table from an array of colors Local $tColorTable = _WinAPI_CreateDIBColorTable($aColorTable) ; Create 8 bits-per-pixel device-independent bitmap (DIB) and retrieve a pointer to the location of its bit values $hBitmap = _WinAPI_CreateDIB($iWidth, $iHeight, 4, $tColorTable, 16) the result is the same as if i take mspaint load any image and save as 16 colors(4bits) however with the 256 color or 8 bit the data i found are not the same, there are multiple color tables i tested, the colors are off, i even found some scripts in the forum that generate 8 bit color tables but the colors are also off, they are not the same as if i take mspaint and save an image as 256 colors, if done with mspaint the colors are very acculturate, i thought well maybe get the color table from an 8 bit image i have that was done with mspaint, but im not sure how to do that, below i tried something but not sure if it gets the table and i don't know how to get the table to an array #include <WinAPIGdi.au3> #include <WinAPIRes.au3> Global $hBitmap = _WinAPI_LoadImage(0, 'D:\spectrum256.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE+$LR_CREATEDIBSECTION ) Local $tSIZE = _WinAPI_GetBitmapDimension($hBitmap) Local $iWidth = DllStructGetData($tSIZE, 'X') Local $iHeight = DllStructGetData($tSIZE, 'Y') ConsoleWrite('size= '&$iWidth&' '&$iHeight&@CRLF) $table = _WinAPI_GetDIBColorTable ( $hBitmap) ConsoleWrite(' Error '&@error & @CRLF) ConsoleWrite(' Extended '&@extended & @CRLF) ;_WinAPI_GetDIBits? Link to comment Share on other sites More sharing options...
UEZ Posted May 4, 2020 Share Posted May 4, 2020 (edited) Try _GDIPlus_BitmapConvertFormat from help file. Manual color quantization with Autoit is too slow. Edited May 4, 2020 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now