ฟอรั่ม PSsix

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ฟอรั่มของบล็อก http://pssix.blogspot.com


2 posters

    Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ

    sirchet
    sirchet
    PSsix Member High Class
    PSsix Member High Class


    PSsix Program Coder
    จำนวนข้อความ : 96
    ความนิยม : 1
    เข้าร่วมเมื่อ : 21/07/2010
    อายุ : 35

    Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ Empty Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ

    ตั้งหัวข้อ by sirchet 25/09/11, 08:32 pm

    Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ ผมอยากจะให้ Rotate(กลับหัว จับนอน)ภาพ ทีละเยอะๆครับ
    มีคำสั่งไหนทำได้รึเปล่าครับ
    POS
    POS
    PSsix
    PSsix


    Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ Empty Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ Empty Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ Empty
    จำนวนข้อความ : 1152
    ความนิยม : 326
    เข้าร่วมเมื่อ : 19/07/2010

    Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ Empty Re: Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ

    ตั้งหัวข้อ by POS 26/09/11, 12:30 pm

    ดาวน์โหลดไฟล์ FreeImage library จากลิงก์
    [You must be registered and logged in to see this link.]

    ตัวอย่างสคริปต์หมุนและกลับภาพ

    Code:
    #include <FreeImage.au3>

    Global $ImageHandle=-1, $WorkingFileName, $FIF

    _FreeImage_LoadDLL(@ScriptDir&"\FreeImage.dll")
    _FreeImage_Initialise()

    Func OnAutoItExit()
        If $ImageHandle <>-1 Then _FreeImage_Unload($ImageHandle)
        _FreeImage_DeInitialise()
    EndFunc

    GUICreate("FreeImage Test GUI",800,700)
    $ShowPic = GUICtrlCreatePic("",0,0, 800,600)

    $btnOpen = GUICtrlCreateButton("Choose File", 10, 610, 100, 30)
    GUICtrlSetTip(-1,"Only a copy of the image will be used")

    $btnFlipH = GUICtrlCreateButton("Flip Horizontal", 120, 610, 100, 30)
    $btnFlipV = GUICtrlCreateButton("Flip Vertical", 230, 610, 100, 30)
    $btnRotate = GUICtrlCreateButton("Rotate ...", 340, 610, 100, 30)

    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case -3
                Exit
            Case $btnOpen
                _OpenImage()
            Case $btnFlipH
                If $ImageHandle <> -1 Then
                    _FreeImage_FlipHorizontal($ImageHandle)
                    _FreeImage_SaveU($FIF, $ImageHandle, $WorkingFileName)
                    _ShowImage()
                EndIf
            Case $btnFlipV
                If $ImageHandle <> -1 Then
                    _FreeImage_FlipVertical($ImageHandle)
                    _FreeImage_SaveU($FIF, $ImageHandle, $WorkingFileName)
                    _ShowImage()
                EndIf
            Case $btnRotate
                If $ImageHandle <> -1 Then
                    $hImageNew = _FreeImage_RotateClassic($ImageHandle, Number(InputBox("Rotate", "angle for rotation", 90)))
                    _FreeImage_SaveU($FIF, $hImageNew, $WorkingFileName)
                    _FreeImage_Unload($ImageHandle)
                    $ImageHandle = $hImageNew
                    _ShowImage()
                EndIf
        EndSwitch
    WEnd

    Func _OpenImage()
        Local $sFile = FileOpenDialog("Choose Image","", "Image Files (*.jpg;*.jpeg;*.bmp;*.gif)", 3)
        If @error Then Return
        If $ImageHandle <> -1 Then _FreeImage_Unload($ImageHandle)
        Local $dot = StringInStr($sFile,".",1,-1)
        Local $Name = StringLeft($sFile,$dot-1)
        Local $Ext = StringMid($sFile,$dot)
        $WorkingFileName = $Name &"_FI4AU3"&$Ext
        FileCopy($sFile,$WorkingFileName)
        $FIF = _FreeImage_GetFileTypeU($WorkingFileName)
        If $FIF = $FIF_UNKNOWN Then
            $FIF = _FreeImage_GetFIFFromFilenameU($WorkingFileName)
        EndIf
        $ImageHandle = _FreeImage_LoadU($FIF, $sFile)
        _ShowImage()
    EndFunc

    Func _ShowImage()
        Local $Width, $Height
        _SizeProportional($Width, $Height, 800, 600, _FreeImage_GetWidth($ImageHandle), _FreeImage_GetHeight($ImageHandle))
        GUICtrlSetPos($ShowPic,0,0,$Width, $Height)
        GUICtrlSetImage($ShowPic, $WorkingFileName)
    EndFunc






    Func _SizeProportional(ByRef $Width, ByRef $Height, $WDesired, $HDesired, $WSrc, $HSrc)
        ; Prog@ndy
        Local $RatioDes = ($WDesired / $HDesired)
        Local $CurrentRatio = ($WSrc / $HSrc)

        If $CurrentRatio > $RatioDes Then ; scale height
            $Width = $WDesired
            $Height = $WDesired / $CurrentRatio
        Else ; scale width
            $Width = $HDesired * $CurrentRatio
            $Height = $HDesired
        EndIf

    EndFunc  ;==>_SizeProportional
    sirchet
    sirchet
    PSsix Member High Class
    PSsix Member High Class


    PSsix Program Coder
    จำนวนข้อความ : 96
    ความนิยม : 1
    เข้าร่วมเมื่อ : 21/07/2010
    อายุ : 35

    Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ Empty Re: Autoit สามารถ Rotate รูปภาพได้รึเปล่าครับ

    ตั้งหัวข้อ by sirchet 28/09/11, 01:54 am

    ขอบคูณมากครับคุณ POS อุตส่าห์หามาให้จนได้ em218

      เวลาขณะนี้ 27/04/24, 11:51 pm