JScript Posted July 27, 2014 Share Posted July 27, 2014 Hello friends!I already know how to make 8-bit grayscale using _WinAPI_CreateDIBSection() function, but unfortunately I could not understand well and I do not know if it is possible to obtain the results posted on this link:http://en.wikipedia.org/wiki/Color_depth # 8-bit_color I appreciate any help, JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
UEZ Posted July 27, 2014 Share Posted July 27, 2014 Do you want to create an empty 8-bit bitmap or convert an image to 8-bit image?1) Create an empty 8-bit bitmap -> _GDIPlus_BitmapCreateFromScan0() using $GDIP_PXF08INDEXED as the pixel format2) Check out _GDIPlus_BitmapConvertFormat() function in the help fileBr,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...
JScript Posted July 27, 2014 Author Share Posted July 27, 2014 (edited) Hello, thanks for the reply, but do not actually need to convert, note the code below:$iBitCount = 8 $hSrcDC = _WinAPI_GetDC(_WinAPI_GetDesktopWindow()) $hDestCDC = _WinAPI_CreateCompatibleDC(0) $tBMPINFO = DllStructCreate("dword Size; long Width; long Height; word Planes; word BitCount; dword Compression; dword SizeImage; long XPelsPerMeter; long YPelsPerMeter; dword ClrUsed; dword ClrImportant; dword RGBQuad[256];") DllStructSetData($tBMPINFO, "Size", 40);DllStructGetSize($tBITMAPINFO) - 4); DllStructSetData($tBMPINFO, "Planes", 1) DllStructSetData($tBMPINFO, 'Compression', 0);$BI_RGB) DllStructSetData($tBMPINFO, 'SizeImage', 0) DllStructSetData($tBMPINFO, "Width", $iWidth) DllStructSetData($tBMPINFO, "Height", -($iHeight)); minus =standard = bottomup DllStructSetData($tBMPINFO, "BitCount", $iBitCount) If $iBitCount <= 8 Then $iColorCnt = BitShift(1, -$iBitCount) DllStructSetData($tBMPINFO, 'ClrUsed', $iColorCnt) DllStructSetData($tBMPINFO, 'ClrImportant', $iColorCnt) EndIf Switch $iBitCount Case 8 For $i = 0 To $iColorCnt - 1 DllStructSetData($tBMPINFO, 'RGBQuad', BitOR(BitShift($i, -16), BitShift($i, -8), $i), $i + 1) Next Case 4 Local $aCol[16] = [8, 24, 38, 56, 72, 88, 104, 120, 136, 152, 168, 184, 210, 216, 232, 248] For $i = 0 To 15 DllStructSetData($tBMPINFO, 'RGBQuad', BitOR(BitShift($aCol[$i], -16), BitShift($aCol[$i], -8), $aCol[$i]), $i + 1) Next Case 1 DllStructSetData($tBMPINFO, 'RGBQuad', BitOR(BitShift(0xFF, -16), BitShift(0xFF, -8), 0xFF), 2) EndSwitch $hHBitmap = _WinAPI_CreateDIBSection($hDestCDC, $tBMPINFO, $DIB_RGB_COLORS, $pBits) _WinAPI_SelectObject($hDC, $hHBitmap) _WinAPI_StretchBlt($hDestCDC, $iWndX, $iWndY, $iWndW, $iWndH, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $SRCCOPY)In this way I can take a screen shot on 8 bits but unfortunately is in shades of gray! How to get a colored with only 256 colors as shown in this link http://en.wikipedia.org/wiki/Color_depth? Edit1:Sample image of 8 bit (256 colors):Edit2:After playing a bit with the "bmiColors" I got this result:But you may notice that the color white is "saturated", as well as the black color is also!Edit3:After some testing, the maximum I got was this result:But I'm not sure that is correct because I'm Colorblind...JS Edited July 27, 2014 by JScript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
UEZ Posted July 27, 2014 Share Posted July 27, 2014 (edited) It looks good (edit 3 screenshot).You need it for your RDP app, right? If yes, then GDI+ might be the wrong choice. GDI is faster.Br,UEZ Edited July 27, 2014 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...
JScript Posted July 27, 2014 Author Share Posted July 27, 2014 (edited) It looks good (edit 3 screenshot).You need it for your RDP app, right? If yes, then GDI+ might be the wrong choice. GDI is faster.Br,UEZYes is for my remote desktop program! Interesting to know that the bitmap has the same size if it is in grayscale!I use Bitmap cache that minimizes the amount of bitmap data transferred between the client and server. The client creates an compressed, temporary bitmap cache that contains bitmaps that are repeatedly sent from the server to the client.The client uses GDI calls and these cached bitmaps to draw onto the display. The cache resides in RAM and is valid for the session.When the code is complete I'll post for you to see,Edit1:Another variation. Better result?Edit2:See VNC with 256 colors to the left of the picture and my program in the right of the image:JS Edited July 27, 2014 by JScript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
UEZ Posted July 27, 2014 Share Posted July 27, 2014 Edit1 is dithered but I like more your Edit2 result.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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Solution JScript Posted July 28, 2014 Author Solution Share Posted July 28, 2014 Edit1 is dithered but I like more your Edit2 result.Br,UEZThank you friend!Based on the explanations of these two links:http://msdn.microsoft.com/en-us/library/bb250466%28VS.85%29.aspx#safety_topic2https://www.gidforums.com/t-21296.htmlI got the final conclusion, see:Capture with 8bits and SetStretchBltMode in COLORONCOLOR:Capture with 8bits and SetStretchBltMode in HALFTONE:JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! 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