Solved

reading bmp file from dll

Posted on 1997-11-27
9
162 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
9 Comments
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
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
Comment Utility
Is this a Dll you wrote? or someone else?
0
 
LVL 2

Accepted Solution

by:
Waldek earned 50 total points
Comment Utility
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
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
????

{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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:degraef
Comment Utility
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
Comment Utility
What are the errors?
Did you make your Res -file with the image editor of delphi?
0
 

Author Comment

by:degraef
Comment Utility
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
Comment Utility
Which version of Delphi are you working on?
What if you make the res with Image editor?
0
 

Author Comment

by:degraef
Comment Utility
Delphi 3

Haven't tried the image editor yet
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now