Jump to content
Sign in to follow this  
nobbe

Image tool using Nconvert activeX Control

Recommended Posts

nobbe

i found nconvert to be alot better in conversion of files than cximage so i changed the sample code to work with

GFLAx (ActiveX/ASP component) v2.70, which is free for private use

Its a Free grafik Manipulation Library supporting a large number of file Formats

please check the developers page for more information

http://perso.orange.fr/pierre.g/xnview/de_downloadgfl.html

New 13.06

- i added some object checking

- color codes are now directly used from RGB

;
;
; light image converter
; using nconvert ACTIVEx now
;
; http://perso.orange.fr/pierre.g/xnview/de_downloadgfl.html
;
; all api functions can be taken from the help CHM file, which is extensive
;

;
; to register the active X control do this :
;  copy GflAx.dll c:\winnt\system32
;  regsvr32.exe GflAx.dll
;
; author nobbe, june 2007
;
;
#include <GUIConstants.au3>

$Form1 = GUICreate("nconvert sample", 633, 454, 193, 115, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPCHILDREN)

Dim $filemenu = GUICtrlCreateMenu("&File")
Dim $fileitem = GUICtrlCreateMenuitem("Open", $filemenu)
Dim $widthTh, $heightTh
$Height1 = 150
$Width1 = 150
$Obj1_ctrl = GUICtrlCreatePic("", 120, 32, $Width1, $Height1)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $fileitem
            ;MsgBox(0,"","msg")
            $file = FileOpenDialog("Choose file...", @ScriptDir, "Picture Files (*.*)")
            If @error <> 1 Then pic_Open($file)
            
    EndSwitch
WEnd

Func pic_Open($file)
    GUICtrlDelete($Obj1_ctrl)
    $newFile = resample($file, $Width1, $Height1)
    $Obj1_ctrl = GUICtrlCreatePic(@ScriptDir & "\100_a.jpg", 120, 32, $widthTh, $heightTh)
    ;   MsgBox(0,"",$file)
EndFunc   ;==>pic_Open



;
; just resample the picture 1/4 of its orig size and save with diff qualities
;
Func resample($file, $Width1, $Height)
    
    ; the nconvert GFX api - if this fails you need to register the control first
    $imgObject = ObjCreate("GflAx.GflAx")
    If $imgObject <> 0 Then

        $imgObject.LoadBitmap ($file);
        
        $widthOrig = $imgObject.Width ()
        $heightOrig = $imgObject.Height ()

        ;MsgBox(0, "", $widthOrig & "x" & $heightOrig)

        $widthTh = Int($widthOrig / 4) ; 1/4 of original
        $heightTh = Int($heightOrig / 4)
        
        ;var olecolor = red + (green * 256) + (blue * 65536);
        ; original RGB colors
        $r = 255;
        $g = 0;
        $b = 255;
        $olecolor = $r + ($g * 256) + ($b * 65536);
        $imgObject.TextOut ("Test2 ", 50, 500, $olecolor) ; OLE_COLOR

        ;       $imgObject.Sharpen(90)
        
        ; resize object
        $imgObject.Resize ($widthTh, $heightTh)
        $imgObject.SaveFormat = 1 ; jpeg

        $imgObject.SaveJPEGQuality = 100 ; 100 % quality
        $imgObject.SaveBitmap (@ScriptDir & "\100_a.jpg")

        $imgObject.SaveJPEGQuality = 70 ;  % quality
        $imgObject.SaveBitmap (@ScriptDir & "\70_a.jpg")

        $imgObject.SaveJPEGQuality = 40 ;  % quality
        $imgObject.SaveBitmap (@ScriptDir & "\40_a.jpg")

        $imgObject.SaveJPEGQuality = 10 ;  % quality
        $imgObject.SaveBitmap (@ScriptDir & "\10_a.jpg")

    EndIf ; imgobj ==0

EndFunc   ;==>resample
Edited by nobbe

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  

×