Solved

reading bmp file from dll

Posted on 1997-11-27
9
172 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 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