Sign in to follow this  
Followers 0
Kalin

[Request] Invert Color UDF

21 posts in this topic

Is there any UDF or function that allows a GUI/GUI Control to have invert colors?

If not, I'm requesting someone to make one. It could be very useful for me.

;)

Share this post


Link to post
Share on other sites



Kalin,

Have you searched the forum? I seem to remember some scripts a while back that inverted images. ;)

I'm requesting someone to make one

We do not do requests. If you want code written for you, try V-Worker (used to be RentACoder). :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Kalin,

Have you searched the forum? I seem to remember some scripts a while back that inverted images. :)

We do not do requests. If you want code written for you, try V-Worker (used to be RentACoder). ;)

M23

OK, I will remember you guise don't take request.

@Topic, thanks.

;)

Share this post


Link to post
Share on other sites

Kalin,

I found this in my Snippets folder - you may find it useful: ;)

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#Include <Color.au3>
#Include <ScreenCapture.au3>
#Include <Misc.au3>

; Credit: Malkey for the basic GDI code

Global $iTolerance = 30, $iX1, $iY1, $iX2, $iY2, $fType = ""

; Create GUI
$hMain_GUI = GUICreate("Invert BMP", 240, 150)

$hLabel_1 = GUICtrlCreateLabel("First mark the area to invert or select a BMP", 10, 10, 260, 20)

$hRect_Button   = GUICtrlCreateButton("Mark Area",   10, 40, 80, 30)
$hChoose_Button = GUICtrlCreateButton("Choose BMP", 150, 40, 80, 30)

$hLabel_2 = GUICtrlCreateLabel("", 160, 90, 70, 20)

$hAction_Button = GUICtrlCreateButton("Invert",      150,  110, 80, 30)
GUICtrlSetState(-1, $GUI_DISABLE)
$hCancel_Button = GUICtrlCreateButton("Cancel",   10, 110, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $hCancel_Button
            GUIDelete($hMain_GUI)
            Exit
        Case $hRect_Button
            GUISetState(@SW_HIDE, $hMain_GUI)
            Mark_Rect()
            GUISetState(@SW_SHOW, $hMain_GUI)
            GUICtrlSetState($hAction_Button, $GUI_ENABLE)
            GUICtrlSetData($hLabel_1, "")
            GUICtrlSetData($hLabel_2, "Now Invert!")
            $fType = "Rect"
        Case $hChoose_Button
            $sBMP_Path = FileOpenDialog("Select BMP to invert", "C:\", "Bitmaps (*.bmp)", 2)
            If @error Then
                MsgBox(64, "Info", "No BMP selected")
            Else
                GUICtrlSetState($hAction_Button, $GUI_ENABLE)
                GUICtrlSetData($hLabel_1, "")
                GUICtrlSetData($hLabel_2, "Now Invert!")
                $fType = "File"
            EndIf
        Case $hAction_Button
            GUIDelete($hMain_GUI)
            ExitLoop
    EndSwitch

WEnd

; Capture selected area if needed
If $fType = "Rect" Then
    $sBMP_Path = @ScriptDir & "\TestNormal.bmp"
    GUISetState(@SW_HIDE, $hMain_GUI)
    _ScreenCapture_Capture($sBMP_Path, $iX1, $iY1, $iX2, $iY2, False)
EndIf

; Load original image
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($sBMP_Path)
If @error Then
    MsgBox(16, "Error", "Could not load BMP file")
    _GDIPlus_Shutdown()
    Exit
EndIf

Global $GuiSizeX = _GDIPlus_ImageGetWidth($hImage)
Global $GuiSizeY = _GDIPlus_ImageGetHeight($hImage)

; Display original image
$hBitmap_GUI = GUICreate("Original Bitmap", $GuiSizeX, $GuiSizeY, 100, 100)
GUISetState()

; Create Double Buffer, so the doesn't need to be repainted on PAINT-Event
$hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hBitmap_GUI)
$hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphicGUI)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff)

_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $GuiSizeX, $GuiSizeY)

GUIRegisterMsg(0xF, "MY_PAINT")
GUIRegisterMsg(0x85, "MY_PAINT")
_GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)

; Invert the image
Local $hBitmap = Image_Invert($hBMPBuff, 0, 0, $GuiSizeX, $GuiSizeY)
If _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\TestInverted.bmp") =  False Then MsgBox(16 , "Error", "Inverted image not created")

WinActivate($hBitmap_GUI)

; Display inverted image
$hInverted_GUI = GUICreate("Inverted Image", $GuiSizeX, $GuiSizeY, 500, 200)
$hPic = GUICtrlCreatePic(@ScriptDir & "\TestInverted.bmp", 0, 0, $GuiSizeX, $GuiSizeY)
GUISetState()

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_Shutdown()
        Exit
    EndIf
WEnd

; -------------

;Func to redraw on PAINT MSG
Func MY_PAINT($hWnd, $msg, $wParam, $lParam)

    ; Check, if the GUI with the Graphic should be repainted
    ; The sequencial order of these two commands is important.
    _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)
    _WinAPI_RedrawWindow($hBitmap_GUI, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ; , $RDW_ALLCHILDREN
    Return $GUI_RUNDEFMSG

EndFunc   ;==>MY_PAINT

; -------------

Func Image_Invert($hImage2, $iStartPosX = 0, $iStartPosY = 0, $GuiSizeX = Default, $GuiSizeY = Default)

    Local $hBitmap1, $Reslt, $width, $height, $stride, $format, $Scan0, $v_Buffer, $v_Value, $iIW, $iIH
    $iIW = _GDIPlus_ImageGetWidth($hImage2)
    $iIH = _GDIPlus_ImageGetHeight($hImage2)
    If $GuiSizeX = Default Or $GuiSizeX > $iIW - $iStartPosX Then $GuiSizeX = $iIW - $iStartPosX
    If $GuiSizeY = Default Or $GuiSizeY > $iIH - $iStartPosY Then $GuiSizeY = $iIH - $iStartPosY
    $hBitmap1 = _GDIPlus_BitmapCloneArea($hImage2, $iStartPosX, $iStartPosY, $GuiSizeX, $GuiSizeY, $GDIP_PXF32ARGB)

    ProgressOn("Inverting Image", "The image is being processed.", "0 percent", -1, -1, 16)

    $Reslt = _GDIPlus_BitmapLockBits($hBitmap1, 0, 0, $GuiSizeX, $GuiSizeY, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB)

    ;Get the returned values of _GDIPlus_BitmapLockBits ()
    $width = DllStructGetData($Reslt, "width")
    $height = DllStructGetData($Reslt, "height")
    $stride = DllStructGetData($Reslt, "stride")
    $format = DllStructGetData($Reslt, "format")
    $Scan0 = DllStructGetData($Reslt, "Scan0")
    For $i = 0 To $GuiSizeX - 1
        For $j = 0 To $GuiSizeY - 1
            $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4))
            ; Get colour value of pixel
            $v_Value = DllStructGetData($v_Buffer, 1)
            ; Invert
            If (Abs(_ColorGetBlue ($v_Value) - 0x80) <= $iTolerance And _  ; Blue
                Abs(_ColorGetGreen($v_Value) - 0x80) <= $iTolerance And _  ; Green
                Abs(_ColorGetRed  ($v_Value) - 0x80) <= $iTolerance) Then  ; Red
                DllStructSetData($v_Buffer, 1, BitAND((0x7F7F7F + $v_Value) , 0xFFFFFF))
            Else
                DllStructSetData($v_Buffer, 1, BitXOR($v_Value ,0xFFFFFF))
            EndIf
        Next
        Local $iProgress = Int(100 * $i / ($GuiSizeX))
        ProgressSet(1 + $iProgress, $iProgress & " percent")
        ProgressSet($iProgress, $iProgress & " percent")
    Next
    _GDIPlus_BitmapUnlockBits($hBitmap1, $Reslt)

    ProgressOff()
    Return $hBitmap1

EndFunc   ;==>Image_Invert

; -------------

Func Mark_Rect()

    Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp
    Local $UserDLL = DllOpen("user32.dll")

    ; Create transparent GUI with Cross cursor
    $hCross_GUI = GUICreate("Test", @DesktopWidth, @DesktopHeight - 20, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
    WinSetTrans($hCross_GUI, "", 8)
    GUISetState(@SW_SHOW, $hCross_GUI)
    GUISetCursor(3, 1, $hCross_GUI)

    Global $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
    GUISetBkColor(0x000000)

    ; Wait until mouse button pressed
    While Not _IsPressed("01", $UserDLL)
        Sleep(10)
    WEnd

    ; Get first mouse position
    $aMouse_Pos = MouseGetPos()
    $iX1 = $aMouse_Pos[0]
    $iY1 = $aMouse_Pos[1]

    ; Draw rectangle while mouse button pressed
    While _IsPressed("01", $UserDLL)

        $aMouse_Pos = MouseGetPos()

        $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, 0, 0)
        $hMask = _WinAPI_CreateRectRgn($iX1,  $aMouse_Pos[1], $aMouse_Pos[0],  $aMouse_Pos[1] + 1) ; Bottom of rectangle
        _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
        _WinAPI_DeleteObject($hMask)
        $hMask = _WinAPI_CreateRectRgn($iX1, $iY1, $iX1 + 1, $aMouse_Pos[1]) ; Left of rectangle
        _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
        _WinAPI_DeleteObject($hMask)
        $hMask = _WinAPI_CreateRectRgn($iX1 + 1, $iY1 + 1, $aMouse_Pos[0], $iY1) ; Top of rectangle
        _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
        _WinAPI_DeleteObject($hMask)
        $hMask = _WinAPI_CreateRectRgn($aMouse_Pos[0], $iY1, $aMouse_Pos[0] + 1,  $aMouse_Pos[1]) ; Right of rectangle
        _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
        _WinAPI_DeleteObject($hMask)
        ; Set overall region
        _WinAPI_SetWindowRgn($hRectangle_GUI, $hMaster_Mask)

        If WinGetState($hRectangle_GUI) < 15 Then GUISetState()
        Sleep(10)

    WEnd

    ; Get second mouse position
    $iX2 = $aMouse_Pos[0]
    $iY2 = $aMouse_Pos[1]

    ; Set in correct order if required
    If $iX2 < $iX1 Then
        $iTemp = $iX1
        $iX1 = $iX2
        $iX2 = $iTemp
    EndIf
    If $iY2 < $iY1 Then
        $iTemp = $iY1
        $iY1 = $iY2
        $iY2 = $iTemp
    EndIf

    GUIDelete($hRectangle_GUI)
    GUIDelete($hCross_GUI)
    DllClose($UserDLL)

EndFunc   ;==>Mark_Rect

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Oh thanks, I'm sure this will be useful.

And K, advice taken.

;)

Share this post


Link to post
Share on other sites

Kalin,

I try not to lecture all the time, honest! :)

I hope you find it useful - please ask if you have any questions, although this was essentially Malkey's script. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Here another example to invert an image:

;coded by UEZ
;thanks to Authenticity for GDIP.au3 and the great examples
#include <GDIPlus.au3>
#Include <Misc.au3>

$file = FileOpenDialog("Select image to load", @ScriptDir, "Images (*.jpg;*.png;*.bmp)")

If @error Then Exit

_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($file)
$scale_factor = 1.0
$iX = _GDIPlus_ImageGetWidth($hImage) * $scale_factor
$iY = _GDIPlus_ImageGetHeight($hImage) * $scale_factor

$hGUI = GUICreate("GDI+: Image to Negative Example", $iX, $iY)
GUISetState()

$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)

Global $hImageContext, $hBackImage
_Negative()

$dll = DllOpen("user32.dll")

While 1
    Switch GUIGetMsg()
        Case -3
            _GDIPlus_BitmapDispose($hImage)
            _GDIPlus_GraphicsDispose($hImageContext)
            _GDIPlus_BitmapDispose($hBackImage)
            _GDIPlus_GraphicsDispose($hGraphics)
            _GDIPlus_Shutdown()
            GUIDelete($hGUI)
            DllClose($dll)
    Exit
    EndSwitch
    If _IsPressed("4E", $dll) Then ;press n to negative image
        $hImage = _GDIPlus_BitmapCloneArea($hBackImage, 0, 0, $iX, $iY)
        _Negative()
    EndIf
    Sleep(100)
WEnd

Func _Negative()
    Local $tNegMatrix, $pNegMatrix
    If $hImage Then
        $hBackImage = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY)
        $hImageContext = _GDIPlus_ImageGetGraphicsContext($hBackImage)
    $tNegMatrix = _GDIPlus_ColorMatrixCreateNegative()
    $pNegMatrix = DllStructGetPtr($tNegMatrix)
        $hIA = _GDIPlus_ImageAttributesCreate()
    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $pNegMatrix)
    _GDIPlus_GraphicsDrawImageRectRectIA($hImageContext, $hImage, 0, 0, $iX, $iY, 0, 0, $iX, $iY, $hIA)
        _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBackImage, 0, 0, $iX, $iY, 0, 0, $iX, $iY)
        $tNegMatrix = 0
    EndIf
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ColorMatrixCreateNegative
; Description ...: Creates and initializes a negative color matrix
; Syntax.........: _GDIPlus_ColorMatrixCreateNegative()
; Parameters ....: None
; Return values .: Success  - $tagGDIPCOLORMATRIX structure
;   Failure     - 0
; Remarks .......: None
; Related .......: $tagGDIPCOLORMATRIX
; Link ..........; @@MsdnLink@@ ColorMatrix
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_ColorMatrixCreateNegative()
    Local $iI, $tCM
    $tCM = _GDIPlus_ColorMatrixCreateScale(-1, -1, -1, 1)
    For $iI = 1 To 4
        DllStructSetData($tCM, "m", 1, 20 + $iI)
    Next
    Return $tCM
EndFunc ;==>_GDIPlus_ColorMatrixCreateNegative

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ColorMatrixCreateScale
; Description ...: Creates and initializes a scaling color matrix
; Syntax.........: _GDIPlus_ColorMatrixCreateScale($nRed, $nGreen, $nBlue[, $nAlpha = 1])
; Parameters ....: $nRed - Red component scaling factor
;   $nGreen - Green component scaling factor
;   $nBlue - Blue component scaling factor
;   $nAlpha - Alpha component scaling factor
; Return values .: Success  - $tagGDIPCOLORMATRIX structure that contains a scaling color matrix
;   Failure     - 0
; Remarks .......: A scaling color matrix is used to multiply components of a color by multiplier factors
; Related .......: $tagGDIPCOLORMATRIX
; Link ..........; @@MsdnLink@@ ColorMatrix
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_ColorMatrixCreateScale($nRed, $nGreen, $nBlue, $nAlpha = 1)
    Local $tCM
    Local Const $tagGDIPCOLORMATRIX = "float m[25]"
    $tCM = DllStructCreate($tagGDIPCOLORMATRIX)
    DllStructSetData($tCM, "m", $nRed, 1)
    DllStructSetData($tCM, "m", $nGreen, 7)
    DllStructSetData($tCM, "m", $nBlue, 13)
    DllStructSetData($tCM, "m", $nAlpha, 19)
    DllStructSetData($tCM, "m", 1, 25)
    Return $tCM
EndFunc ;==>_GDIPlus_ColorMatrixCreateScale

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ImageAttributesSetColorMatrix
; Description ...: Sets or clears the color- and grayscale-adjustment matrices for a specified category
; Syntax.........: _GDIPlus_ImageAttributesSetColorMatrix($hImageAttributes[, $iColorAdjustType = 0[, $fEnable = False,[ $pClrMatrix = 0[, $pGrayMatrix = 0[, $iColorMatrixFlags = 0]]]]])
; Parameters ....: $hImageAttributes - Pointer to an ImageAttribute object
;   $iColorAdjustType - The category for which the color- and grayscale-adjustment matrices are set or cleared:
;   |0 - Color or grayscale adjustment applies to all categories that do not have adjustment settings of their own
;   |1 - Color or grayscale adjustment applies to bitmapped images
;   |2 - Color or grayscale adjustment applies to brush operations in metafiles
;   |3 - Color or grayscale adjustment applies to pen operations in metafiles
;   |4 - Color or grayscale adjustment applies to text drawn in metafiles
;   $fEnable            - If True, the specified matrices (color, grayscale or both) adjustments for the specified
;   +category are applied; otherwise the category is cleared
;   $pClrMatrix      - Pointer to a $tagGDIPCOLORMATRIX structure that specifies a color-adjustment matrix
;   $pGrayMatrix         - Pointer to a $tagGDIPCOLORMATRIX structure that specifies a grayscale-adjustment matrix
;   $iColorMatrixFlags - Type of image and color that will be affected by the adjustment matrices:
;   |0 - All color values (including grays) are adjusted by the same color-adjustment matrix
;   |1 - Colors are adjusted but gray shades are not adjusted.
;   +A gray shade is any color that has the same value for its red, green, and blue components
;   |2 - Colors are adjusted by one matrix and gray shades are adjusted by another matrix
; Return values .: Success  - True
;   Failure     - False and either:
;   |@error and @extended are set if DllCall failed
;   |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: None
; Related .......: _GDIPlus_ColorMatrixCreate, $tagGDIPCOLORMATRIX
; Link ..........; @@MsdnLink@@ GdipSetImageAttributesColorMatrix
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_ImageAttributesSetColorMatrix($hImageAttributes, $iColorAdjustType = 0, $fEnable = False, $pClrMatrix = 0, $pGrayMatrix = 0, $iColorMatrixFlags = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetImageAttributesColorMatrix", "hwnd", $hImageAttributes, "int", $iColorAdjustType, "int", $fEnable, "ptr", $pClrMatrix, "ptr", $pGrayMatrix, "int", $iColorMatrixFlags)

    If @error Then Return SetError(@error, @extended, False)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_ImageAttributesSetColorMatrix

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_GraphicsDrawImageRectRectIA
; Description ...: Draws an image
; Syntax.........: _GDIPlus_GraphicsDrawImageRectRectIA($hGraphics, $hImage, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight, $nDstX, $nDstY, $nDstWidth, $nDstHeight[, $hImageAttributes = 0[, $iUnit = 2]])
; Parameters ....: $hGraphics - Pointer to a Graphics object
;   $hImage     - Pointer to an Image object
;   $iSrcX  - The X coordinate of the upper left corner of the source image
;   $iSrcY  - The Y coordinate of the upper left corner of the source image
;   $iSrcWidth - Width of the source image
;   $iSrcHeight - Height of the source image
;   $iDstX  - The X coordinate of the upper left corner of the destination image
;   $iDstY  - The Y coordinate of the upper left corner of the destination image
;   $iDstWidth - Width of the destination image
;   $iDstHeight - Height of the destination image
;   $hImageAttributes - Pointer to an ImageAttributes object that specifies the color and size attributes of the image to be drawn
;   $iUnit   - Unit of measurement:
;   |0 - World coordinates, a nonphysical unit
;   |1 - Display units
;   |2 - A unit is 1 pixel
;   |3 - A unit is 1 point or 1/72 inch
;   |4 - A unit is 1 inch
;   |5 - A unit is 1/300 inch
;   |6 - A unit is 1 millimeter
; Return values .: Success  - True
;   Failure     - False and either:
;   |@error and @extended are set if DllCall failed
;   |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: None
; Related .......: None
; Link ..........; @@MsdnLink@@ GdipDrawImageRectRect
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_GraphicsDrawImageRectRectIA($hGraphics, $hImage, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight, $nDstX, $nDstY, $nDstWidth, $nDstHeight, $hImageAttributes = 0, $iUnit = 2)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectRect", "hwnd", $hGraphics, "hwnd", $hImage, "float", $nDstX, "float", _
            $nDstY, "float", $nDstWidth, "float", $nDstHeight, "float", $nSrcX, "float", $nSrcY, "float", $nSrcWidth, "float", _
            $nSrcHeight, "int", $iUnit, "hwnd", $hImageAttributes, "int", 0, "int", 0)

    If @error Then Return SetError(@error, @extended, False)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_GraphicsDrawImageRectRectIA

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ImageAttributesCreate
; Description ...: Creates an ImageAttributes object
; Syntax.........: _GDIPlus_ImageAttributesCreate()
; Parameters ....: None
; Return values .: Success  - Pointer to a new ImageAttribute object
;   Failure     - 0 and either:
;   |@error and @extended are set if DllCall failed
;   |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: After you are done with the object, call _GDIPlus_ImageAttributesDispose to release the object resources
; Related .......: _GDIPlus_ImageAttributesDispose
; Link ..........; @@MsdnLink@@ GdipCreateImageAttributes
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_ImageAttributesCreate()
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateImageAttributes", "int*", 0)

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[1]
EndFunc ;==>_GDIPlus_ImageAttributesCreate

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

@UEZ

Superb negative effect ! Posted Image

Thanks !


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Here another example to invert an image:

NICE!

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

The mathematics behind inversion is simple. It's just the highest color value (usually 255) minus the current color value.

Red = 255 - red; green = 255 - green; blue = 255 - blue

Share this post


Link to post
Share on other sites

The mathematics behind inversion is simple. It's just the highest color value (usually 255) minus the current color value.

Red = 255 - red; green = 255 - green; blue = 255 - blue

makes sense, i've never really thought about it

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

You all do realize that I wasn't asking for image invert colour, right?

Read my first post more closely.

Share this post


Link to post
Share on other sites

Kalin,

Read my first post more closely

I think it is more a case of you explaining yourself more clearly! :)

What exactly do you want to do? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I think he wants to skin his GUI with inverted colors, but with the scripts he's given here, and all the topics on the forum on changing the look of gui's, i think he can figure it out

***edit***

took out the quote, i know how much you love those ;)

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Try

Global $_Invert=True, $_InvertTimerInit=TimerInit ( )

$_Gui                      = GUICreate ( 400,300 )
$_RandomButton   = GUICtrlCreateButton ( "Button", 102, 20, 120, 20 )   
GUISetState ( @SW_SHOW )

while 1
    If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton )

WEnd


Func _InvertColorButton ( $_GuiCtrl )
    If $_Invert Then
        GUICtrlSetBkColor ( $_GuiCtrl, 0xFF0000 )  
        GUICtrlSetColor ( $_GuiCtrl, 0xFFFF00 ) 
        $_Invert=False
    Else
        GUICtrlSetBkColor ( $_GuiCtrl, 0xFFFF00 )  
        GUICtrlSetColor ( $_GuiCtrl, 0xFF0000 )     
        $_Invert=True
    EndIf
EndFunc ;==> _InvertColorButton ( )

Func _EachXseconds ( $_Interval )
    $_TimerDiff = Round ( TimerDiff ( $_InvertTimerInit )/ 1000 )
    If $_TimerDiff >= $_Interval Then
        $_InvertTimerInit = TimerInit ( )
        Return 1
    Else
        Return 0
    EndIf
EndFunc ;==> _EachXseconds ( )

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

or you can combine Wakillon's color changing button with Richard Robertson's insight and achieve your own goal and you won't even have to search the forums.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Try

Global $_Invert=True, $_InvertTimerInit=TimerInit ( )

$_Gui                      = GUICreate ( 400,300 )
$_RandomButton   = GUICtrlCreateButton ( "Button", 102, 20, 120, 20 )   
GUISetState ( @SW_SHOW )

while 1
    If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton )

WEnd

Func _InvertColorButton ( $_GuiCtrl )
    If $_Invert Then
        GUICtrlSetBkColor ( $_GuiCtrl, 0xFF0000 )  
        GUICtrlSetColor ( $_GuiCtrl, 0xFFFF00 ) 
        $_Invert=False
    Else
        GUICtrlSetBkColor ( $_GuiCtrl, 0xFFFF00 )  
        GUICtrlSetColor ( $_GuiCtrl, 0xFF0000 )     
        $_Invert=True
    EndIf
EndFunc ;==> _InvertColorButton ( )

Func _EachXseconds ( $_Interval )
    $_TimerDiff = Round ( TimerDiff ( $_InvertTimerInit )/ 1000 )
    If $_TimerDiff >= $_Interval Then
        $_InvertTimerInit = TimerInit ( )
        Return 1
    Else
        Return 0
    EndIf
EndFunc ;==> _EachXseconds ( )

Oh baby.... I think I love you...

With everything you guise gave me I will try to make an invert colour.

;)

***Edit***

I don't think your code works...

n_n

Look's like it is just changing the button color the red, then yellow.

Edited by Kalin

Share this post


Link to post
Share on other sites

I don't think your code works...

Look's like it is just changing the button color the red, then yellow.

That was what his code was designed to do... now look at how he did it, and use the normal color of the button, and Richard Robertson's tip on how negative colors are figured, and you may be able to solve your problem

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Oh baby.... I think I love you...

With everything you guise gave me I will try to make an invert colour.

;)

***Edit***

I don't think your code works...

n_n

Look's like it is just changing the button color the red, then yellow.

When i post , i always try before...

It works fine !


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

When i post , i always try before...

It works fine !

you gave him enough to accomplish his goal, but he wanted you to actually do it for him

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

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