Solved

reading bmp file from dll

Posted on 1997-11-27
9
171 Views
Last Modified: 2010-04-04
When trying to load a picture (800x600.bmp) into an Image field, from a dll.

var
hLib : integer;
hRes : Thandle;
begin
hLib:=loadLibrary('e:\unpack\1\empire.dll');
hREs := findREsource(hLib,'black','800x600');
Image1.Picture.LoadFromFile(string(hRes));
end;

this gives me an error message saying picture with invalid extension. However I think it is something else.
I made a simple dll, with a res file called black.res.
0
Comment
Question by:degraef
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1352220
Try this (haven't tested it! Just a guess!) :

 
    DllHandle := LoadLibrary({name.dll});

    And use this DllHandle with
   
    Image1.Picture.LoadImage(DllHandle, 'black', image_bitmap,
                             800,600, (options);


  Have fun,
  c.u.
  ZifNab;
0
 
LVL 1

Expert Comment

by:TheSwine
ID: 1352221
Is this a Dll you wrote? or someone else?
0
 
LVL 2

Accepted Solution

by:
Waldek earned 50 total points
ID: 1352222
Maybe this
procedure BitmapCaller(ModuleName, Bitmap : string;Image:TPicture);
var
  DLLPchar,              {Name of library as a null terminated string}
  Proc_Name : PChar;     {Name of procedure as a null terminated string}
  DLL_Handle : THandle;  {Handle to the DLL}
begin
  DLL_Handle := 0;
  GetMem(DLLPchar, Length(ModuleName) + 1);
  StrPCopy(DLLPchar, ModuleName);
  if not FileExists(ModuleName) then
    MessageDlg('Brak biblioteki Resource.DLL', mtWarning, [mbOk], 0)
  else
    begin
      GetMem(Proc_Name, Length(Bitmap) + 1);
      StrPCopy(Proc_Name, Bitmap);
      if DLL_Handle = 0 then
        DLL_Handle := LoadLibrary(DLLPchar);
      if DLL_Handle >= 32 then
        begin
          Image.Bitmap.Handle:=LoadBitmap(DLL_Handle,Proc_name);
          if Image.bitmap.Handle = NULL then
          MessageDlg('Error loading bitmap file',mtWarning, [mbOk], 0);
          FreeMem(Proc_Name);
          FreeLibrary(DLL_Handle);
        end
      else
        MessageDlg('Fatal Error with DLL', mtWarning, [mbOk], 0);
    end;
   FreeMem(DLLPChar);
end;


And example of call
BitmapCaller('resource.dll','logo',Load.Image1.Picture);
where 'logo' is a name of bitmap in resource and Image1 is a TImage on form load
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1352223
????

{name.dll} is dll file you want to read.

In your case it's LoadLibrary('e:\unpack\1\empire.dll');

and LoadImage is just a function of Win32. (New - Windows95)
0
 

Author Comment

by:degraef
ID: 1352224
nothing suggested here seems to work.
Here is the complete history.

created res file as follows;  black.res 'black' '800x600.bmp'
put it in a dll ($R black.res) compiled the dll = empire.dll.

in mainform of program I have an Image1 component.

The Load.Image1.Picture
or Image1.Picture.LoadImage suggested did not work.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1352225
What are the errors?
Did you make your Res -file with the image editor of delphi?
0
 

Author Comment

by:degraef
ID: 1352226
With Load.Image1.. I get 'Unknown command' as well as the LoadImage

I made the res with brcc32.exe
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1352227
Which version of Delphi are you working on?
What if you make the res with Image editor?
0
 

Author Comment

by:degraef
ID: 1352228
Delphi 3

Haven't tried the image editor yet
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question