Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

reading bmp file from dll

Posted on 1997-11-27
9
Medium Priority
?
175 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 100 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
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!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 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