Jump to content

How to marge 3 image?


Recommended Posts

Hi ALL!

Sorry about my EN

I want to MERGE 3 images and save in another file By AutoIt

How I can do this?

for more info Download and see This File :

http://rapidshare.com/files/288126979/peinman-seifi.rar.html

I want to marge : aks-4.jpg + payam-3.png + TAQVIM.png

and this marge result will : sample.jpg

thanks :)

Edited by peyman1366
Link to comment
Share on other sites

I didn't download your .rar file to see exactly what you were wanting, but If you are wanting to combine all three of the images, as in making them overlap. This script might help you. I did not write it, nor can I find the original post to find the author, but don't give any credit to me for it.

#include <GDIPlus.au3>
#include <color.au3>
Global $Progress
Global $TotalIterations
_GDIPlus_Startup()
MsgBox(64, "Introduction", "This program will combine 3 images into one image, each image seperated into its own channel" & @CRLF & _
        "The first image you choose will be the template for the output image (format & size)")

Local $images[3]
For $i = 0 To 2
    $fname = FileOpenDialog("First image", "", "All images (*.jpg;*.png;*.gif;*.bmp;)")
    If $fname = "" Then close()
    $images[$i] = _GDIPlus_ImageLoadFromFile($fname)
Next

Opt("GUIOnEventMode", 1)

$hwnd = GUICreate("Working...", 300, 50)
$progressbar = GUICtrlCreateProgress(10, 5, 280, 40)
GUISetOnEvent(-3, "close")
GUISetState()
AdlibEnable("update", 50)

CombineBitmaps($images[0], $images[1], $images[2])
$fname = FileSaveDialog("Process complete!", "", "PNG image(*.png;)|JPEG image(*.jpg;*.jpeg;)|Uncompressed Bitmap(*.bmp;)",16)
If $fname = "" Then close()
_GDIPlus_ImageSaveToFile($images[0], $fname)
close()

Func update()
    GUICtrlSetData($progressbar, ($Progress / $TotalIterations) * 100)
EndFunc   ;==>update



Func close()
    For $i = 0 To 2
        If $images[$i] <> 0 Then _GDIPlus_ImageDispose($images[$i])
    Next
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>close

Func CombineBitmaps($bm1, $bm2, $bm3)
    $w = _GDIPlus_ImageGetWidth($bm1)
    $h = _GDIPlus_ImageGetHeight($bm1)
    Local $aData[$w][$h]
    $TotalIterations = ($w * $h) * 4
    
    For $i = 0 To 2 Step 1
        
        $bm = Eval("bm" & $i + 1)
        
        $w = _GDIPlus_ImageGetWidth($bm)
        $h = _GDIPlus_ImageGetHeight($bm)
        
        
        $BitmapData = _GDIPlus_BitmapLockBits($bm, 0, 0, $w, $h, $GDIP_ILMREAD, $GDIP_PXF32RGB)
        $Stride = DllStructGetData($BitmapData, "Stride")
        $Scan0 = DllStructGetData($BitmapData, "Scan0")
        For $row = 0 To $h - 1
            For $col = 0 To $w - 1
                $Progress += 1
                $pixel = DllStructCreate("dword", $Scan0 + $row * $Stride + $col * 4)
                $temp = "0x" & Hex((DllStructGetData($pixel, 1)))
                $average = Hex((_ColorGetRed($temp) + _ColorGetGreen($temp) + _ColorGetBlue($temp)) / 3, 2)
                Switch $i
                    Case 0
                        $aData[$col][$row] = BitXOR($aData[$col][$row], "0x" & $average & "0000")
                    Case 1
                        $aData[$col][$row] = BitXOR($aData[$col][$row], "0x00" & $average & "00")
                    Case 2
                        $aData[$col][$row] = BitXOR($aData[$col][$row], "0x0000" & $average)
                EndSwitch
                
                
            Next
        Next
        _GDIPlus_BitmapUnlockBits($bm, $BitmapData)
    Next

    
    
    $BitmapData = _GDIPlus_BitmapLockBits($bm1, 0, 0, $w, $h, $GDIP_ILMWRITE, $GDIP_PXF32RGB)
    $Stride = DllStructGetData($BitmapData, "Stride")
    $Scan0 = DllStructGetData($BitmapData, "Scan0")

    For $row = 0 To $h - 1
        For $col = 0 To $w - 1
            $Progress += 1
            $pixel = DllStructCreate("dword", $Scan0 + $row * $Stride + $col * 4)
            DllStructSetData($pixel, 1, $aData[$col][$row])
        Next
    Next
    _GDIPlus_BitmapUnlockBits($bm1, $BitmapData)
    
EndFunc   ;==>CombineBitmaps

"The true measure of a man is how he treats someone who can do him absolutely no good."

Link to comment
Share on other sites

  • Developers

tank you

but can you upload for me

GDIPlus.au3 and color.au3 files?

or say me how to used them?

They are included in the installer and stored in the Include subdirectory.

The shows script will find them when running your script with a standard installation of AutoIt3.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...