2 Bilder fusionieren

  • wie meinst du das? nebeneinander? überlagern mit transparent 50/50? ...? nur auf dem gui, oder wirklich zusammenfügen?

  • Hi, du musst für die RGB-Werte jedes Pixels jeweils folgende berechnung durchführen.
    (R1+R2)/2 = neues rot
    (G1+G2)/2 = neues grün
    (B1+B2)/2 = neues blau

    Am einfachsten kommst du an die Farbwerte wenn es Bitmaps sind (Aufbau BMP-Datei).

    Sind es Farb- oder Schwarzweißbilder?

    MFG. RAPTOR-ONE

  • Kann man die Bilder auch nur Transparenz machen und übereinanderlegen?

    Damit:

    Spoiler anzeigen
    [autoit]

    #include<GDIplus.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ; Constants
    Global Const $ColorAdjustTypeDefault = 0
    Global Const $ColorAdjustTypeBitmap = 1
    Global Const $ColorAdjustTypeBrush = 2
    Global Const $ColorAdjustTypePen = 3
    Global Const $ColorAdjustTypeText = 4
    Global Const $ColorAdjustTypeCount = 5
    Global Const $ColorAdjustTypeAny = 6

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $ColorMatrixFlagsDefault = 0
    Global Const $ColorMatrixFlagsSkipGrays = 1
    Global Const $ColorMatrixFlagsAltGray = 2

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $UnitWorld = 0
    Global Const $UnitDisplay = 1
    Global Const $UnitPixel = 2
    Global Const $UnitPoint = 3
    Global Const $UnitInch = 4
    Global Const $UnitDocument = 5
    Global Const $UnitMillimeter = 6

    [/autoit] [autoit][/autoit] [autoit]

    ; Structures and creation functions
    Global Const $tagColorMatrix = "float m1[5]; float m2[5]; float m3[5]; float m4[5]; float m5[5];"

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_ColorMatrix( $m1_1, $m1_2, $m1_3, $m1_4, $m1_5, _
    $m2_1, $m2_2, $m2_3, $m2_4, $m2_5, _
    $m3_1, $m3_2, $m3_3, $m3_4, $m3_5, _
    $m4_1, $m4_2, $m4_3, $m4_4, $m4_5, _
    $m5_1, $m5_2, $m5_3, $m5_4, $m5_5 )
    ; Prog@ndy
    ; creates a GDIplus color Matrix
    Local $ColorMatrix = DllStructCreate($tagColorMatrix)
    For $r = 1 To 5
    For $c = 1 To 5
    DllStructSetData($ColorMatrix, $r, Eval("m" & $r & "_" & $c),$c)
    Next
    Next
    Return $ColorMatrix
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $tagPointF = "float x; float y;"

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GDIPlus_PointFParallelogramm
    ; Description ...:
    ; Syntax.........: _GDIPlus_PointFParallelogramm($nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY)
    ; Parameters ....: $nULX - The X coordinate of the upper left corner of the source image
    ; $nULY - The Y coordinate of the upper left corner of the source image
    ; $nURX - The X coordinate of the upper right corner of the source image
    ; $nURY - The Y coordinate of the upper right corner of the source image
    ; $nLLX - The X coordinate of the lower left corner of the source image
    ; $nLLY - The Y coordinate of the lower left corner of the source image
    ; Return values .: Success -
    ; Failure - 0
    ; Author ........: Malkey
    ; Modified ......: Prog@ndy
    ; Remarks .......:
    ; Related .......:
    ; Link ..........; @@MsdnLink@@
    ; Example .......;
    ; ===============================================================================================================================
    Func _GDIPlus_PointFParallelogramm($nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tPoint = DllStructCreate("float X;float Y;float X2;float Y2;float X3;float Y3")
    DllStructSetData($tPoint, "X", $nULX)
    DllStructSetData($tPoint, "Y", $nULY)
    DllStructSetData($tPoint, "X2", $nURX)
    DllStructSetData($tPoint, "Y2", $nURY)
    DllStructSetData($tPoint, "X3", $nLLX)
    DllStructSetData($tPoint, "Y3", $nLLY)
    Return $tPoint
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GDIPlus_PointLParallelogramm
    ; Description ...:
    ; Syntax.........: _GDIPlus_PointLParallelogramm($nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY)
    ; Parameters ....: $nULX - The X coordinate of the upper left corner of the source image
    ; $nULY - The Y coordinate of the upper left corner of the source image
    ; $nURX - The X coordinate of the upper right corner of the source image
    ; $nURY - The Y coordinate of the upper right corner of the source image
    ; $nLLX - The X coordinate of the lower left corner of the source image
    ; $nLLY - The Y coordinate of the lower left corner of the source image
    ; $count - Specifies the number of points (x,y)'s in the structure.
    ; Return values .: Success -
    ; Failure - 0
    ; Author ........: Malkey
    ; Modified ......: Prog@ndy
    ; Remarks .......:
    ; Related .......:
    ; Link ..........; @@MsdnLink@@
    ; Example .......;
    ; ===============================================================================================================================
    Func _GDIPlus_PointLParallelogramm($nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY)
    Local $tPoint = DllStructCreate("int X;int Y;int X2;int Y2;int X3;int Y3")
    DllStructSetData($tPoint, "X", $nULX)
    DllStructSetData($tPoint, "Y", $nULY)
    DllStructSetData($tPoint, "X2", $nURX)
    DllStructSetData($tPoint, "Y2", $nURY)
    DllStructSetData($tPoint, "X3", $nLLX)
    DllStructSetData($tPoint, "Y3", $nLLY)
    Return $tPoint
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ; Functions
    Func _GDIPlus_ImageAttributesCreate()
    ; Prog@ndy
    Local $aResult = DllCall($ghGDIpDLL, "int", "GdipCreateImageAttributes", "ptr*", 0)
    If @error Then Return SetError(1,@error,0)
    Return SetError($aResult[0],0,$aResult[1])
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_ImageAttributesDispose($pImageAttributes)
    ; Prog@ndy
    Local $aResult = DllCall($ghGDIpDLL, "int", "GdipDisposeImageAttributes", "ptr", $pImageAttributes)
    If @error Then Return SetError(1,@error,0)
    Return SetError($aResult[0],0,$aResult[0]=0)
    EndFunc
    Func _GDIPlus_ImageAttributesSetColorMatrix($pImageAttributes, $type, $enableFlag, $colorMatrix, $grayMatrix, $flags)
    ; Prog@ndy
    Local $aResult = DllCall($ghGDIpDLL, "int", "GdipSetImageAttributesColorMatrix", "ptr", $pImageAttributes, "int", $type, "int", $enableFlag, "ptr", $colorMatrix, "ptr", $grayMatrix,"int", $flags)
    If @error Then Return SetError(1,@error,0)
    Return SetError($aResult[0],0,$aResult[0]=0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_DrawImagePointsRect($graphics, $image, $points, $count, $srcx, $srcy, $srcwidth, $srcheight, $srcUnit, $imageAttributes, $callback=0, $callbackData=0)
    ; Prog@ndy
    Local $aResult = DllCall($ghGDIpDLL, "int", "GdipDrawImagePointsRect", "ptr", $graphics, "ptr", $image,"ptr", $points, "INT", $count, _
    "float", $srcx, "float", $srcy, "float", $srcwidth, "float", $srcheight, "int", $srcUnit, "ptr", $imageAttributes, "ptr", $callback, "ptr", $callbackData)
    If @error Then Return SetError(1,@error,0)
    Return SetError($aResult[0],0,$aResult[0]=0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_DrawImagePointsRectI($graphics, $image, $points, $count, $srcx, $srcy, $srcwidth, $srcheight, $srcUnit, $imageAttributes, $callback=0, $callbackData=0)
    ; Prog@ndy
    Local $aResult = DllCall($ghGDIpDLL, "int", "GdipDrawImagePointsRectI", "ptr", $graphics, "ptr", $image,"ptr", $points, "INT", $count, _
    "int", $srcx, "int", $srcy, "int", $srcwidth, "int", $srcheight, "int", $srcUnit, "ptr", $imageAttributes, "ptr", $callback, "ptr", $callbackData)
    If @error Then Return SetError(1,@error,0)
    Return SetError($aResult[0],0,$aResult[0]=0)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ; Author ........: Paul Campbell (PaulIA)
    ; Modified.......: Gary Frost, Prog@ndy
    Func _GDIPlus_GraphicsDrawImageRectRectAttr($hGraphics, $hImage, $iSrcX, $iSrcY, $iSrcWidth, $iSrcHeight, $iDstX, $iDstY, $iDstWidth, $iDstHeight, $iUnit = 2, $pImageAttributes=0)
    Local $aResult

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "ptr", $hGraphics, "ptr", $hImage, "int", $iDstX, "int", _
    $iDstY, "int", $iDstWidth, "int", $iDstHeight, "int", $iSrcX, "int", $iSrcY, "int", $iSrcWidth, "int", _
    $iSrcHeight, "int", $iUnit, "ptr", $pImageAttributes, "ptr", 0, "ptr", 0)
    If @error Then Return SetError(@error, @extended, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc ;==>_GDIPlus_GraphicsDrawImageRectRectAttr

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    ; Example

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $hImg1 = _GDIPlus_ImageLoadFromFile("HINTERGRUNDBILD.jpg")
    $hImg2 = _GDIPlus_ImageLoadFromFile("TRANSPARENTER_VORDERGRUND.JPG")

    [/autoit] [autoit][/autoit] [autoit]

    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImg1)

    [/autoit] [autoit][/autoit] [autoit]

    $ImageAttributes = _GDIPlus_ImageAttributesCreate()

    [/autoit] [autoit][/autoit] [autoit]

    $ColorMatrix = _GDIPlus_ColorMatrix( _
    1.0, 0.0, 0.0, 0.0, 0.0, _
    0.0, 1.0, 0.0, 0.0, 0.0, _
    0.0, 0.0, 1.0, 0.0, 0.0, _
    0.0, 0.0, 0.0, 0.5, 0.0, _ ; --> die 0.5 gibt die Transparenz an (0.5 = 50% sichtbar, 0.3= 30% sichtbar ...)
    0.0, 0.0, 0.0, 0.0, 1.0 _
    )

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_ImageAttributesSetColorMatrix($ImageAttributes, $ColorAdjustTypeBitmap, 1, DllStructGetPtr($ColorMatrix), 0, $ColorMatrixFlagsDefault)

    [/autoit] [autoit][/autoit] [autoit]

    _DrawImage($hGraphics, $hImg2, 10,10,$ImageAttributes)
    ;~ _DrawImage($hGraphics, $hImg2, 0,0,0)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_ImageSaveToFile($hImg1, @DesktopDir & "\test.jpg")

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_ImageDispose($hImg1)
    _GDIPlus_ImageDispose($hImg2)

    [/autoit] [autoit][/autoit] [autoit]

    $x2 = _GDIPlus_ImageAttributesDispose($ImageAttributes)

    [/autoit] [autoit][/autoit] [autoit]

    Func _DrawImage($hGraphics, $hImage, $X, $Y, $pImageAttributes)
    ; Prog@ndy
    Local $H = _GDIPlus_ImageGetHeight($hImage)
    Local $W = _GDIPlus_ImageGetWidth($hImage)
    ;~ Local $tPoint = _GDIPlus_PointFParallelogramm($X, $Y, $X+$W, $Y, $X, $Y+$H)
    ;~ Local $Result = _GDIPlus_DrawImagePointsRect($hGraphics, $hImage, DllStructGetPtr($tPoint), 3, 0, 0, $W, $H, 2, $pImageAttributes)
    Local $Result = _GDIPlus_GraphicsDrawImageRectRectAttr($hGraphics, $hImage, 0, 0, $W, $H, $X, $Y, $W, $H, 2, $pImageAttributes)
    Return SetError(@error,0,$Result)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Shutdown()

    [/autoit]

    Ist von progandy

    [autoit]

    $hImg1 = _GDIPlus_ImageLoadFromFile("HINTERGRUNDBILD.jpg")
    $hImg2 = _GDIPlus_ImageLoadFromFile("TRANSPARENTER_VORDERGRUND.JPG")

    [/autoit]

    Dort musst du deine Bilder eintragen.