Solved

reading bmp file from dll

Posted on 1997-11-27
9
167 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
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

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…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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