Jump to content
Sign in to follow this  
komalo

GraphicalDLL.dll in autoit

Recommended Posts

komalo

hi

is there is a way to use This DLL ( GraphicalDLL ) in autoit

it is written to be used with vb6 but i am trying to use it in an autoit gui

i only need the GPX_BLUR Function so i am trying to convert it to autoit

but i am having lots problems

also , if you know any other Image processing Library ( Not Image Magick nor ProSpeed )

please tell me

that's the GPX_BLUR Source Code

HRESULT __stdcall GPX_Blur (HDC     PicDestDC, 
                            HDC     PicSrcDC,
                            int     *Response)
{
    int BitCount    = 0;
    int Result      = 0;
    int Width       = 0; 
    int Height      = 0;
    BITMAPINFO info;
    HBITMAP PicSrcHwnd = GetBitmapHandle (PicSrcDC, &info, &Width, &Height);

    if (! PicSrcHwnd)
    {
        *Response = (int)Result;
        return (E_FAIL);
    }

    int LineWidth = Width * 3;
    if (LineWidth % 4)
        LineWidth += (4 - LineWidth % 4);

    BitCount = LineWidth * Height;
    LPBYTE Bits = new BYTE[BitCount];

    Result = GetDIBits (PicSrcDC, PicSrcHwnd, 0, Height, Bits, &info, DIB_RGB_COLORS);
    if (Result)
    {
        int i = 0, j = 0, k = 0;
        for (int h = 1; h < Height - 1; h++)
            for (int w = 1; w < Width - 1; w++)
            {
                i = h * LineWidth + 3 * w;
                j = (h + 1) * LineWidth + 3 * w;
                k = (h - 1) * LineWidth + 3 * w;

                Bits[i+2] = (Bits[i-1] + Bits[j-1] + Bits[k-1] +
                             Bits[i+2] + Bits[j+2] + Bits[k+2] +
                             Bits[i+5] + Bits[j+5] + Bits[k+5]) / 9;
                Bits[i+1] = (Bits[i-2] + Bits[j-2] + Bits[k-2] +
                             Bits[i+1] + Bits[j+1] + Bits[k+1] +
                             Bits[i+4] + Bits[j+4] + Bits[k+4]) / 9;
                Bits[ i ] = (Bits[i-3] + Bits[j-3] + Bits[k-3] +
                             Bits[ i ] + Bits[ j ] + Bits[ k ] +
                             Bits[i+3] + Bits[j+3] + Bits[k+3]) / 9;
            }

        ::SetDIBitsToDevice (PicDestDC, 0, 0, Width, Height, 0, 0, 0, Height, Bits, &info, 0);
        
        ::DeleteObject (PicSrcHwnd);
        delete [] Bits;

        *Response = (int)Result;
        return (S_OK);
    }

    return (E_FAIL);
}

and here's my code trying to call the dll ( doesn't work )

#include <WinApi.au3>

Dim $Response
GUICreate("aaa")
$Graphic1 = GUICtrlCreatePic("a.bmp",0,0,100,100)
$Graphic2 = GUICtrlCreatePic("a.bmp",200,0,100,100)
GUISetState()

$hwndG1=GUICtrlGetHandle($Graphic1)
$hwndG2=GUICtrlGetHandle($Graphic2)

$SourceDc = _WinAPI_GetDC($hwndG1)
$DestDc = _WinAPI_GetDC($hwndG2)

$Dll = DllCall("GraphicalDLL.dll","Long","GPX_Blur","hwnd",$DestDc,"hwnd",$SourceDc,"int",$Response)

MsgBox("","",$SourceDc&" "& $DestDc)
MsgBox("","",$Response)

_WinAPI_ReleaseDC($hwndG1,$SourceDc)
_WinAPI_ReleaseDC($hwndG2,$DestDc)
Edited by komalo

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites
martin

hi

is there is a way to use This DLL ( GraphicalDLL ) in autoit

it is written to be used with vb6 but i am trying to use it in an autoit gui

i only need the GPX_BLUR Function so i am trying to convert it to autoit

but i am having lots problems

also , if you know any other Image processing Library ( Not Image Magick nor ProSpeed )

please tell me

that's the GPX_BLUR Source Code

HRESULT __stdcall GPX_Blur (HDC     PicDestDC, 
                            HDC     PicSrcDC,
                            int     *Response)
{
    int BitCount    = 0;
    int Result      = 0;
    int Width       = 0; 
    int Height      = 0;
    BITMAPINFO info;
    HBITMAP PicSrcHwnd = GetBitmapHandle (PicSrcDC, &info, &Width, &Height);

    if (! PicSrcHwnd)
    {
        *Response = (int)Result;
        return (E_FAIL);
    }

    int LineWidth = Width * 3;
    if (LineWidth % 4)
        LineWidth += (4 - LineWidth % 4);

    BitCount = LineWidth * Height;
    LPBYTE Bits = new BYTE[BitCount];

    Result = GetDIBits (PicSrcDC, PicSrcHwnd, 0, Height, Bits, &info, DIB_RGB_COLORS);
    if (Result)
    {
        int i = 0, j = 0, k = 0;
        for (int h = 1; h < Height - 1; h++)
            for (int w = 1; w < Width - 1; w++)
            {
                i = h * LineWidth + 3 * w;
                j = (h + 1) * LineWidth + 3 * w;
                k = (h - 1) * LineWidth + 3 * w;

                Bits[i+2] = (Bits[i-1] + Bits[j-1] + Bits[k-1] +
                             Bits[i+2] + Bits[j+2] + Bits[k+2] +
                             Bits[i+5] + Bits[j+5] + Bits[k+5]) / 9;
                Bits[i+1] = (Bits[i-2] + Bits[j-2] + Bits[k-2] +
                             Bits[i+1] + Bits[j+1] + Bits[k+1] +
                             Bits[i+4] + Bits[j+4] + Bits[k+4]) / 9;
                Bits[ i ] = (Bits[i-3] + Bits[j-3] + Bits[k-3] +
                             Bits[ i ] + Bits[ j ] + Bits[ k ] +
                             Bits[i+3] + Bits[j+3] + Bits[k+3]) / 9;
            }

        ::SetDIBitsToDevice (PicDestDC, 0, 0, Width, Height, 0, 0, 0, Height, Bits, &info, 0);
        
        ::DeleteObject (PicSrcHwnd);
        delete [] Bits;

        *Response = (int)Result;
        return (S_OK);
    }

    return (E_FAIL);
}

and here's my code trying to call the dll ( doesn't work )

#include <WinApi.au3>

Dim $Response
GUICreate("aaa")
$Graphic1 = GUICtrlCreatePic("a.bmp",0,0,100,100)
$Graphic2 = GUICtrlCreatePic("a.bmp",200,0,100,100)
GUISetState()

$hwndG1=GUICtrlGetHandle($Graphic1)
$hwndG2=GUICtrlGetHandle($Graphic2)

$SourceDc = _WinAPI_GetDC($hwndG1)
$DestDc = _WinAPI_GetDC($hwndG2)

$Dll = DllCall("GraphicalDLL.dll","Long","GPX_Blur","hwnd",$DestDc,"hwnd",$SourceDc,"int",$Response)

MsgBox("","",$SourceDc&" "& $DestDc)
MsgBox("","",$Response)

_WinAPI_ReleaseDC($hwndG1,$SourceDc)
_WinAPI_ReleaseDC($hwndG2,$DestDc)
You don't say what the error is that you get, but I think

,"int",$Response)

should be

,"int*",$Response)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
komalo

changed to int_ptr and still got the error

$Dll = DllCall("GraphicalDLL.dll", "Long", "GPX_Blur", "hwnd", $DestDc, "hwnd", $SourceDc, "int_ptr", $Response)

and here's the error message

The instruction at "0x019d6f04" referenced memory at "0x00000000". The memory could not be "written".

Click on OK to terminate the program

Click on CANCEL to debug the program


[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

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  

×