Xandy Posted May 31, 2011 Share Posted May 31, 2011 Hi, I'm getting started using _GDIPlus. I think I have learned that a graphic is area of gui that can be drawn to, and an image is pixel data to fill a graphic. I would like to be able to check image pixel data for color values. I understand I can read colors being written to my monitor, but I am not interested in that. I am trying to write an interface for editing graphics, and I want to be able to replace colors. (I could write this in C and have autoit call the C program, but I am trying to minimize user shock) So I need to read pixel data in my images and on color to replace, replace with new color. Anyone able to point me in the direction of how to read pixel colors from an image object? I did not see the function in the help, however I often miss what is directly in front of me. Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
UEZ Posted May 31, 2011 Share Posted May 31, 2011 Try this: expandcollapse popup#include <GDIPlus.au3> _GDIPlus_Startup() $sRegPath = "HKLM\SOFTWARE\AutoIt v3\AutoIt" If StringInStr("X64IA64", @OSArch) Then $sRegPath = StringReplace($sRegPath, "SOFTWARE", "SOFTWARE\Wow6432Node") $hImage = _GDIPlus_ImageLoadFromFile(RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif") $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $BitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) $Stride = DllStructGetData($BitmapData, "Stride") $Scan0 = DllStructGetData($BitmapData, "Scan0") $seach_pixel = 0xFF000080 $replace_pixel = 0xFF008000 For $iX = 0 To $iW - 1 For $iY = 0 To $iH - 1 $tPixel = DllStructCreate("int", $Scan0 + ($iY * $Stride) + ($iX * 4)) $iPixel = DllStructGetData($tPixel, 1) If $iPixel = $seach_pixel Then DllStructSetData($tPixel, 1, $replace_pixel) Next Next _GDIPlus_BitmapUnlockBits($hImage, $BitmapData) $PixelData = 0 $hGUI = GUICreate("Test", $iW, $iH) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $iW, $iH) Do $msg = GUIGetMsg() Until $msg =-3 _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit 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...
Xandy Posted May 31, 2011 Author Share Posted May 31, 2011 Try this:Yes, this is what I want. Now I also have some examples to help me understand dllstruct.Thank you, UEZ Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
monoscout999 Posted May 31, 2011 Share Posted May 31, 2011 (edited) HiI have a related doubt about bitmaplockbits.. i was tring to use to get the rawdata of a bitmap.. i read the documentation and i get the structure data but never understand how to get the pixels i guess this is the way to do it$Scan0 + ($iY * $Stride) + ($iX * 4) but if someone explain me this to understand it i will apreciateAt the end i use GetBitmapBits function to retrive the rawdata..@songersoft If you think this post is Not belong here PM and i remove it. Thanks Edited May 31, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
UEZ Posted June 1, 2011 Share Posted June 1, 2011 Here is a good explanation of LockBits: http://www.bobpowell.net/lockingbits.htm 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...
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