Sign in to follow this  
Followers 0
Kovacic

GDIPlus PNG Manipulation - not sure how to...

3 posts in this topic

Hi all.. I am not all that good with GDIPlus, but it seems that is what I need to use to do what I need to do. 

This application will be a simple wizard type application with panels. There will be 6 panels total, and I have included a generic image for each to show the example. I am using GDIPLus to put PNGs on top of PNGs. I am stuck at 2 things

I would like to be able to create a mouse over effect for each button. I don't care much what it is, only I would like something to happen, like a 1.2 zoom, or a color shift of the button.
I would like to show, and hide panels / buttons depending on what step the user is on which will be defined by a variable, or by a simple function.
I cant get either one to work and have over 8 hours invested in designing and testing, and I can't do this for the life of me. If anyone can throw me a hint or a line of code, or even breadcrumbs to the right direction, it would make my December.

Most of the influence for the code is here: https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_GraphicsResetTransform.htm

Here is the attached code and sample images... The backgrounds contain the places where the buttons should be..

 

[ The company logos have been removed for obvious reasons ]

app.au3

BeginBackup.png

BeginRestore.png

CloseUtil.png

GoBack.png

NewComp.png

OldComp.png

OpenSD.png

RedCloseUtil.png

Slide1.PNG

Slide2.PNG

Slide3.PNG

Slide4.PNG

Slide5.PNG

Slide6.PNG


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

To get your script run properly I would suggest to put the images with its original names into one zip archive and uplaod the zip archive here.

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

Share this post


Link to post
Share on other sites

Update to the code... I can now selectively switch panels, and show images as needed.. I just need to be able to create a button for an imaged called int he following example:

 

This control somehow needs to act like a button..

Global $ddd = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $GoBack)
            Global $ddd2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicGoBack = _GDIPlus_GraphicsDrawImage($ddd2, $ddd, 7.68, 391.68)

(ignore the globals, I will clean them up later)

 

All code so far:

#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
GUISetOnEvent($GUI_EVENT_CLOSE, "Cleanup")
Global $hGUI, $hImage, $hGraphic, $TransTest, $TransTestCreate, $Hover = 0, $swap = True
Global $Test = 1
If $Test = 0 Then
    $Panel1 = "panels\Slide1.PNG"
    $Panel2 = "panels\Slide2.PNG"
    $Panel3 = "panels\Slide3.PNG"
    $Panel4 = "panels\Slide4.PNG"
    $Panel5 = "panels\Slide5.PNG"
    $Panel6 = "panels\Slide6.PNG"
    $BeginBackup = "Buttons\BeginBackup.png"
    $BeginRestore = "Buttons\BeginRestore.png"
    $CloseUtil = "Buttons\CloseUtil.png"
    $GoBack = "Buttons\GoBack.png"
    $NewComp = "Buttons\NewComp.png"
    $OldComp = "Buttons\OldComp.png"
    $OpenSD = "Buttons\OpenSD.png"
    $RedCloseUtil = "Buttons\RedCloseUtil.png"
Else
    $Panel1 = "test\Slide1.PNG"
    $Panel2 = "test\Slide2.PNG"
    $Panel3 = "test\Slide3.PNG"
    $Panel4 = "test\Slide4.PNG"
    $Panel5 = "test\Slide5.PNG"
    $Panel6 = "test\Slide6.PNG"
    $BeginBackup = "test\BeginBackup.png"
    $BeginRestore = "test\BeginRestore.png"
    $CloseUtil = "test\CloseUtil.png"
    $GoBack = "test\GoBack.png"
    $NewComp = "test\NewComp.png"
    $OldComp = "test\OldComp.png"
    $OpenSD = "test\OpenSD.png"
    $RedCloseUtil = "test\RedCloseUtil.png"
EndIf
#EndRegion Buttons
Global Const $STM_SETIMAGE = 0x0172
$hGUI = GUICreate("Backup / Restore Utility Version .5", 768, 480, -1, -1)
GUISetState()
_GDIPlus_Startup()
; TEST SWITCH PANELS
For $i = 1 To 6
    Panel($i)
    Sleep(3000)
Next
; TEST SWITCH PANELS
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3
            Exit
        Case $aaa2
            Panel(2)
            ;Case $ThePicBeginBackup
            ;   PerformBackup()
            ;   Panel(3)
            ;Case $ThePicBeginRestore
            ;   PerformRestore()
            ;   Panel(5)
            ;Case $ThePicCloseUtil
            ;   Exit
            ;Case $ThePicGoBack
            ;   Panel(1)
            ;Case $ThePicNewComp
            ;   Panel(4)
            ;Case $ThePicOldComp
            ;   Panel(2)
            ;Case $ThePicOpenSD
            ;   OpenSD()
            ;Case $ThePicRedCloseUtil
            ;   Exit
    EndSwitch
WEnd
Func Panel($Num)
    Switch $Num
        Case 1
            $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $Panel1)
            $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
            Global $aaa = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $OldComp)
            Global $aaa2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicBeginBackup = _GDIPlus_GraphicsDrawImage($aaa2, $aaa, 114, 218)
            Global $bbb = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $NewComp)
            Global $bbb2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicBeginRestore = _GDIPlus_GraphicsDrawImage($bbb2, $bbb, 381.12, 218.88)
        Case 2
            $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $Panel2)
            $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
            Global $ddd = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $GoBack)
            Global $ddd2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicGoBack = _GDIPlus_GraphicsDrawImage($ddd2, $ddd, 7.68, 391.68)
            Global $aaa = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $BeginBackup)
            Global $aaa2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicBeginBackup = _GDIPlus_GraphicsDrawImage($aaa2, $aaa, 238.08, 391.68)
        Case 3
            $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $Panel3)
            $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
            Global $ddd = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $GoBack)
            Global $ddd2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicGoBack = _GDIPlus_GraphicsDrawImage($ddd2, $ddd, 7.68, 391.68)
            Global $ccc = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $CloseUtil)
            Global $ccc2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicCloseUtil = _GDIPlus_GraphicsDrawImage($ccc2, $ccc, 238.08, 391.68)
        Case 4
            $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $Panel4)
            $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
            Global $ddd = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $GoBack)
            Global $ddd2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicGoBack = _GDIPlus_GraphicsDrawImage($ddd2, $ddd, 7.68, 391.68)
            Global $bbb = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $BeginRestore)
            Global $bbb2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicBeginRestore = _GDIPlus_GraphicsDrawImage($bbb2, $bbb, 238.08, 391.68)
        Case 5
            $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $Panel5)
            $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
            Global $ddd = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $GoBack)
            Global $ddd2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicGoBack = _GDIPlus_GraphicsDrawImage($ddd2, $ddd, 7.68, 391.68)
            Global $ccc = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $CloseUtil)
            Global $ccc2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicCloseUtil = _GDIPlus_GraphicsDrawImage($ccc2, $ccc, 238.08, 391.68)
        Case 6
            $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $Panel6)
            $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
            Global $ggg = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $OpenSD)
            Global $ggg2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicOpenSD = _GDIPlus_GraphicsDrawImage($ggg2, $ggg, 117.12, 286.08)
            Global $hhh = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\" & $RedCloseUtil)
            Global $hhh2 = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            Global $ThePicRedCloseUtil = _GDIPlus_GraphicsDrawImage($hhh2, $hhh, 398.4, 287.04)
    EndSwitch
EndFunc   ;==>Panel
Func Cleanup()
 ; Soon will cleanup all resources
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;       _GDIPlus_GraphicsDispose($hGraphic)
    ;       _GDIPlus_ImageDispose($hImage)
    ;
    _GDIPlus_Shutdown()
EndFunc   ;==>Cleanup
Func HideAll()
    ; TBD
EndFunc   ;==>HideAll
Func PerformRestore()
    ; TBD
EndFunc   ;==>PerformRestore
Func PerformBackup()
    ; TBD
EndFunc   ;==>PerformBackup
Func OpenSD()
    ; TBD
EndFunc   ;==>OpenSD

 


C0d3 is P0etry( ͡° ͜ʖ ͡°)

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

  • Similar Content

    • c.haslam
      By c.haslam
      UEZ has kindly provided me with code that rotates an image per a line: see here
      Because I want to trim a photograph after rotation, I need to crop the photo. I wrote code which calls _GDIPlus_GraphicsSetClipRect() to do this, but it places spurious stuff in the corners: see 2.jpg attached.
      I want only the trimmed photo to show.
      The original jpeg is also attached.
      The arguments to _GDIPlus_GraphicsSetClipRect() come from solving 2 simultaneous equations: if a and b are the width and height of the original photo, find x and y, the width and height of the rotated and cropped rectangle;
      a = x cos(ang) + y sin(ang)
      b = x sin(ang) + y cos(ang)
      My solution is:
      x = (b * sin(ang) - a*cos(ang)) / (sin(ang)^2 - (cos(ang)^2)
      y = (b * cos(ang) - a * sin(ang)) / (cos(ang)^2 - sin(ang)^2)
      To try to get a handle on the problem, I have temporarily added in several lines in Case $btn. In 2.jpg, you can see that the rectangle bounding the area to be retained is in the wrong place.
      The code is:
      #include <ButtonConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars',1) Global Const $MK_SHIFT = 0x4 Global Const $MK_CONTROL = 0x8 Global Const $fPi = ACos(-1), $fPi2 = $fPi / 2, $fRad = 180 / $fPi GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") GUIRegisterMsg($WM_PAINT,'WM_PAINT') Global $gX0=10,$gX1=580,$gY0,$gY1,$gForm1,$glblPic,$iLW,$iLH,$iW,$iH Global $ghCanvas,$ghImage,$ghPen,$gGraphicPic,$ghBitmap,$ghMatrix,$ghImageClone,$ghGfxClone Global Const $kDegToRads = 3.14159/180 main() Func main() $gForm1 = GUICreate("Form1", 623, 601, 192, 114) $iLW = 589 $iLH = 500 $glblPic = GUICtrlCreateLabel("", 8, 8, $iLW, $iLH) Local $btn = GUICtrlCreateButton("Rotate", 472, 560, 65, 25) GUISetState(@SW_SHOW) Local $oldY0,$oldY1,$fAngle _GDIPlus_Startup() $ghPen = _GDIPlus_PenCreate(0xFF999999,2) $ghImage = _GDIPlus_ImageLoadFromFile('H:\b\pergola.jpg') Local $h = GUICtrlGetHandle($glblPic) $gGraphicPic = _GDIPlus_GraphicsCreateFromHWND($h) $gY0 = 400 $gY1 = 400 $iW = _GDIPlus_ImageGetWidth($ghImage) $iH = _GDIPlus_ImageGetHeight($ghImage) $ghBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) $ghCanvas = _GDIPlus_ImageGetGraphicsContext($ghBitmap) $ghMatrix = _GDIPlus_MatrixCreate() ; Loop until the user exits. While True If $gY0<>$oldY0 Or $gY1<>$oldY1 Then Paint() $oldY0 = $gY0 $oldY1 = $gY1 Else Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btn $ghImageClone=_GDIPlus_BitmapCreateFromScan0($iW, $iH) $ghGfxClone=_GDIPlus_ImageGetGraphicsContext($ghImageClone) _GDIPlus_MatrixTranslate($ghMatrix, $iW/2, $iH/2) $gY1 = 300 ; temp Local $ang = -Angle($gY1-$gY0, $gX1-$gX0) _GDIPlus_MatrixRotate($ghMatrix, $ang) ;~ _GDIPlus_MatrixRotate($ghMatrix, -Angle($gY1-$gY0, $gX1-$gX0)) _GDIPlus_MatrixTranslate($ghMatrix, -$iW/2, -$iH/2) _GDIPlus_GraphicsSetTransform($ghGfxClone, $ghMatrix) _GDIPlus_GraphicsDrawImageRect($ghGfxClone,$ghImage,0,0,$iW,$iH) Local $angRads = $ang*$kDegToRads Local $sinAng = Sin($angRads) Local $cosAng = Cos($angRads) Local $wid = ($iLH*$sinAng-$iLW*$cosAng)/($sinAng^2-$cosAng^2) Local $left = ($iLW-$wid)/2 Local $ht = ($iLH*$cosAng-$iLW*$sinAng)/($cosAng^2-$sinAng^2) Local $top = ($iLH-$ht)/2 _GDIPlus_GraphicsDrawRect($ghGfxClone,$left,$top,$wid,$ht,$ghPen) ; temp _GDIPlus_GraphicsSetClipRect($ghGfxClone,$left,$top,$wid,$ht,0) _GDIPlus_GraphicsDispose($ghGfxClone) $ghGfxClone=_GDIPlus_ImageGetGraphicsContext($ghImage) _GDIPlus_GraphicsClear($ghImage) _GDIPlus_GraphicsDrawImageRect($ghGfxClone,$ghImageClone,0,0,$iW,$iH) _GDIPlus_GraphicsDispose($ghGfxClone) _GDIPlus_ImageDispose($ghImageClone) $gy0 = 400 $gy1 = 400 Paint() _GDIPlus_ImageSaveToFile($ghImage,'H:\b\2.jpg') ; added - is rotated, with same size as original file EndSwitch EndIf WEnd ; Clean up resources _GDIPlus_MatrixDispose($ghMatrix) _GDIPlus_ImageDispose($ghCanvas) _GDIPlus_ImageDispose($ghImage) _GDIPlus_ImageDispose($ghBitmap) _GDIPlus_PenDispose($ghPen) _GDIPlus_GraphicsDispose($gGraphicPic) _GDIPlus_Shutdown() EndFunc Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local Const $kYmax=$iLH-1,$kDelta=2 Local $vec = GUIGetCursorInfo($gForm1) If $vec[4] = $vec[4]=$glblPic Then Local $iDelta = BitShift($wParam, 16) ; positive = up Local $iKeys = _WinAPI_LoWord($wParam) If BitAND($iKeys,$MK_CONTROL)=$MK_CONTROL Then If BitAND($iKeys,$MK_SHIFT)=$MK_SHIFT Then ; do nothing Else If $iDelta > 0 And $gY0>3 Then $gY0 -= $kDelta If $iDelta < 0 And $gY0<$kYmax Then $gY0 += $kDelta EndIf Else If BitAND($iKeys,$MK_SHIFT)=$MK_SHIFT Then If $iDelta > 0 And $gY1>3 Then $gY1 -= $kDelta If $iDelta < 0 And $gY1<$kYmax Then $gY1 += $kDelta Else If $iDelta > 0 And $gY0>3 Then $gY0 -= $kDelta If $iDelta < 0 And $gY0<$kYmax Then $gY0 += $kDelta If $iDelta > 0 And $gY1>3 Then $gY1 -= $kDelta If $iDelta < 0 And $gY1<$kYmax Then $gY1 += $kDelta EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSEWHEEL Func Paint() _GDIPlus_GraphicsClear($ghCanvas,0) _GDIPlus_GraphicsDrawImageRect($ghCanvas, $ghImage, 0,0, $iLW, $iLH) _GDIPlus_GraphicsDrawLine($ghCanvas, $gX0, $gY0, $gX1, $gY1, $ghPen) _GDIPlus_GraphicsDrawImageRect($gGraphicPic, $ghBitmap, 0, 0, $iW, $iH) EndFunc Func WM_PAINT() _WinAPI_RedrawWindow($gForm1, 0, 0, $RDW_UPDATENOW) Paint() _WinAPI_RedrawWindow($gForm1, 0, 0, $RDW_VALIDATE) EndFunc Func Angle($y, $x) ;return value is in degree Local Const $fPi = ACos(-1), $fPi2 = ACos(-1) / 2, $fRad = 180 / $fPi Switch True Case ($x > 0) Return ATan($y / $x) * $fRad Case ($x < 0 And $y >= 0) Return ATan($y / $x + $fPi) * $fRad Case ($x < 0 And $y < 0) Return ATan($y / $x - $fPi) * $fRad Case ($x = 0 And $y > 0) Return $fPi2 * $fRad Case ($x = 0 And $y < 0) Return -$fPi2 * $fRad Case ($x = 0 And $y = 0) Return 0 EndSwitch EndFunc I also don't understand how the rotated picture gets displayed. There are graphics objects, graphics contexts and PDI+ bitmaps. How are they related?
      Help would be much appreciated.


    • SimTheNo1
      By SimTheNo1
      I am busy with building a solution for change monitoring of VOIP call program and to be properly automated means among others need for some limited OCR functionality. Current works of others are way too much overkill for this case what makes the need to build it myself. But to do it properly I significantly have to increase my knowledge about digital graphics management.
      For now I already have discovered here and there some mind blowing  Autoit miracles what can be achieved with Windows own possibilities to manipulate that what is output to the monitor. And as far I can judge there are 2 options to process graphics without use of any external libraries like ImageMagick, FreeImage and so on. These are:
       WinAPI  GDIPlus It is for me quite obvious to have various holes in general understanding of graphics and it is once more very clear what advantages gives consistent general study in 1 or another official institutions like University.  Cause there you are introduced into certain domain of knowledge in a way which usually has been perfected over long period of time. So you are not overloaded by stuff which requires a certain amount of information to be initially clear for you. For example, before starting to solve physics you first learn to read, count and so on and then move to subjects like physics.
      Though in my case opportunity to study in such educational system I had only for 8 years, from my 7th to 15th year of age in the country that was falling apart now Ukraine but used to be USSR, was all what it was. After have immigrated to Netherlands possibilities to study further haven't occur. And this therefor causes often various implications when going deep in that or another field of practical knowledge acquiring for any needed physical result, like programming to perform enormous amount of tasks. In this particular case automating VOIP call program.
      Anyway, right now I think the best direction to move is to concentrate on as basic as possible image management and if someone would maybe explain in general what is a pixel will definitely help. Particularly I am very curious about how to do picture manipulations in Autoit. Especially would help a lot to produce eventually following functions:
      createImage($imageFileName, $width, $height, $color) readImagePixel($imageFileName, $x, $y)  writeImagePixel($imageFileName, $x, $y) I do not know exactly how image is handled in computer but preferably above mentioned functions should deal with so far possible origin of graphics creation on computer. But nevertheless I definitely would love to hear any proposition for solution.
      The problem with explaining screenshots:
       VOIPConnect full Window  Part of Window with control to monitor for changes  Exact location of area where actual changes occur and have to be processed  It comes down to a rectangle of approximately 51 pixel wide and 7 pixel high. In fact if I get to learn as far as to be able exactly read, write and compare 2 images consistently across different computers I could narrow down then even further the area to watch as little as a square of 2-5 pixels wide. 
      To finish here is last detail about particularly no need for ultra fast solution at all. This because it is needed only once when it is first run on a new computer and to have to wait few minutes while it is being set instead of just a few seconds make no sence.
      This is it and what I too think to do beside this very particular case is to purify out beautiful generic Autoit functions for core image manipulation by using WinAPI or/and GDIPlus. 
    • corgano
      By corgano
      What I am trying to accomplish is to simplify a .PNG image and convert it to use only a specified pallet of colors. Eg if I have a pallet of 0xFF0000, 0x00FF00, 0x0000FF, it would change every pixel in the image to one of those three colors by whichever color is closest.
       
      The simplest method I have tried is simply converting the image to a 16 bit bitmap, and that does simplify the pallet of the image, but I want to be able to specify what colors it specifies to. The other problem is the resulting saved .BMP file is much larger (file size) than the original, and I don't know if it's possible to make a 16 bit jpg.
       
      It looks like _GDIPlus_BitmapConvertFormat is the solution but the help file doesn't go into how to use the pallet and I couldn't find an example that did what I needed. Can anyone help me?
    • timmalos
      By timmalos
      Hello all . i'm trying to build a tool to generate some pictures/graphs automatically based on some variables. I have completed the first part and I'm struggling now on what I thought would be the easiest part :
      In my tool there is a "preview" button, which helps to display on a new children GUI the generated picture. What I do in simplified :
      Global $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;Then, I'll add multiple objects to this graphic, for example $Temp = _GDIPlus_ImageLoadFromFile($temp[1]) _GDIPlus_GraphicsDrawImage($g_hGraphics,$temp)  
      I'm then able to have a preview GUI showing all my elements perfectly. This works but now I want to be able to really generate it and have a ".png" file written to disk.
      What I tried without success:
      $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($previewWidth, $previewHeight, $g_hGraphics) _GDIPlus_ImageSaveToFile($g_hBitmap,$OUTPUTDIR & "\generated\test-"&@HOUR&@MIN&@SEC&".png") But what I write to file is a transparent PNG without anything.
      I'm pretty sure I'm missing something obvious there, I need your help
       
       
      NB : If this change your answer, my goal will be to generate transparent png, meaning I'll add multiple objects/pictures/texts on a transparent png background and if there are some "transparent holes" I need them to be transparent in the generated png.
       
      Thanks a lot for any help !
      Tim
    • timmalos
      By timmalos
      Hello all.
      I'm trying to do something simple, but I can't manage to find where to start since I can have multiple possibilities and not sure what is the best one :
      Taking screen capture (I can do that) On this capture, I'll look for 10 particular regions that will give me 10 images of 40px * 40px (I can do that) Then what I want is for each of these regions, find on my library of ~140 images which one is the closest one to my region (= the match)  
      What do you think is the best approach ? Ican easily do step 1 and 2, however for the third step :
      I can't use memcmp because they won't be exactly the same (original library can differ a very little bit from what I'll get from my screen capture) There is no text, only drawing Should I do a pixelSum of what I get on screen and do the same via GDIPlus for each of my images in the library?  
      Thanks a lot,
      Tim