Jump to content

Output bitmap from DLL


Recommended Posts

Hello hello!

I've been using AutoIt for many years now but am pretty new to working with DLLs in AutoIt. I've been struggling with outputting a bitmap from a DLL to an image in my GUI.

I have the functioning code in Pascal but need to convert it to AutoIt so, two questions:

1) Does anyone know of a tool to convert Pascal to AutoIt?

2) What is the AutoIt pseudo-code for achieving this?

So far I've got

$dll = DllOpen("mydll.dll")
$dllResult = DllCall($dll,"int","LoadBitMap","none","AD0")

LoadBitMap is the DLL's function and the bitmap name is AD0. I'm unsure how to procede from here tho :)

Help would be greatly appreciated!

Link to comment
Share on other sites

There is no way that you are sending a string with a datatype of 'none'. Provide the documentation for your dll and maybe we can help you.

Right. I wan't 100% sure what "Type1" should be so I put "none" in there thinking it was probably wrong :)

LoadBitMap returns a pointer so I believe the code should be:

$dll = DllOpen("mydll.dll")
$dllResult = DllCall($dll,"ptr","LoadBitMap","int","AD0")

Please correct me if I am wrong.

The Pascal code I'm attempting to convert to AutoIt is:

procedure TMainForm.ChangeAdImage();
var
   h : THandle;
   b1: TBitmap;
//   hRes : THandle; {handle to the resource}
   buf: Array[0..255] of char;
   sBitMapName:Array[0..3] of char;
   iNum: integer;
begin

   if m_bUseDefaultImage then
      begin
         m_bUseDefaultImage:=false;
         m_iCurrentAdImage:=0;
      end;

      h := LoadLibrary('eximg.dll');
      if h >= 32 then begin
      
          b1 := TBitmap.Create;

          StrCopy(sBitMapName,'AD');
          StrCat(sBitMapName,PChar(IntToStr(m_iCurrentAdImage)));

          b1.handle := LoadBitMap(h, sBitMapName);
          if b1.handle<>0 then begin
             AdImage.Picture.Bitmap := b1;
             b1.Free;

             iNum:=LoadString(h,m_iCurrentAdImage,@buf,sizeof(buf));
             if iNum >0 then
                m_sAdWebSite:=buf
             else
                m_sAdWebSite:=CONST_DEFAULT_ADWEB;
           end;
 
        end;

        m_iCurrentAdImage:=m_iCurrentAdImage+1;
        if  m_iCurrentAdImage >= CONST_NUM_ADS then
             m_bUseDefaultImage:=true;

        if h>0 then
            FreeLibrary(h);
end;

Hopefully this helps.

Thanks!

Link to comment
Share on other sites

It seems DllCall is returning @error = 3 meaning the function "LoadBitMap" is not found in the DLL file. So part of my problem is I interpreted the Pascal snippet incorrectly. My bad.

Is there another way to "stream out" the bitmap from the DLL into memory then update an image control perhaps?

Thanks for all your help in this Zorphnoq :)

Link to comment
Share on other sites

I made it for the Newest resources.au3: http://www.autoitscript.com/forum/index.ph...st&p=522569

(With demo)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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...