Hallo,
wie kann man mit AutoIt aus 2 Bilder einen machen?
Hallo,
wie kann man mit AutoIt aus 2 Bilder einen machen?
wie meinst du das? nebeneinander? überlagern mit transparent 50/50? ...? nur auf dem gui, oder wirklich zusammenfügen?
also aus 2 Bildern soll einer werden. Wenn ich ein schwarzen Bild und ein Weißes habe sollen die zu einem werden also Grau. Ich hoffe ihr versteht was ich meine
Willst du das in einer Gui machen oder als datei?
Als Datei
Dann such erst mal nach einer Methode, die Farbwerte für jedes Pixel der beiden Bilder zu ermitteln.
Nun die beiden Werte (von jedem Pixel) subtrahieren und zurückschreiben /-zeichnen, wie auch immer.
Viel Spaß!
Kann man die Bilder auch nur Transparenz machen und übereinanderlegen?
Sry, aber du weißt nicht was du willst.
Eben gerade bestätigst du auf Nachfrage, dass es Dateien sind - und jetzt doch wieder GUI ?
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
Also es sind nur die beiden Bilder hier:
@RAPTOR-ONE: Der Link muss so sein:
http://en.wikipedia.org/wiki/Windows_Bitmap
Such mal nach _GDIPlus_BitmapLockBits, wenn du die Bilder zusammenrechnen willst...
oder im engl. Forum nach _GDIPlus_GraphicsDrawImageRectRectTrans, falls es ausreicht, wenn du das 2 Bild mit 50% Transparenz über das andere zeichnen willst...
lgE
Kann man die Bilder auch nur Transparenz machen und übereinanderlegen?
Damit:
#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
Global Const $ColorMatrixFlagsDefault = 0
Global Const $ColorMatrixFlagsSkipGrays = 1
Global Const $ColorMatrixFlagsAltGray = 2
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
; Structures and creation functions
Global Const $tagColorMatrix = "float m1[5]; float m2[5]; float m3[5]; float m4[5]; float m5[5];"
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
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)
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
; #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
; 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
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
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
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
; 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
$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]; Example
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$hImg1 = _GDIPlus_ImageLoadFromFile("HINTERGRUNDBILD.jpg")
$hImg2 = _GDIPlus_ImageLoadFromFile("TRANSPARENTER_VORDERGRUND.JPG")
$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 _
)
_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)
_GDIPlus_ImageSaveToFile($hImg1, @DesktopDir & "\test.jpg")
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageDispose($hImg1)
_GDIPlus_ImageDispose($hImg2)
$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
_GDIPlus_Shutdown()
[/autoit]Ist von progandy
[autoit]$hImg1 = _GDIPlus_ImageLoadFromFile("HINTERGRUNDBILD.jpg")
$hImg2 = _GDIPlus_ImageLoadFromFile("TRANSPARENTER_VORDERGRUND.JPG")
Dort musst du deine Bilder eintragen.
Dankeschön