Board index » delphi » example for loading picture from DLL
John
![]() Delphi Developer |
John
![]() Delphi Developer |
example for loading picture from DLL2005-10-18 12:07:13 AM delphi21 Hello, I have a lot a picture to include in a wizard. I would like to include them in a external DLL, if possible in Jpeg. Anyone have a sample of how to do this kind of stuff? thanks John |
Peter Below (TeamB)
![]() Delphi Developer |
2005-10-18 02:13:47 AM
Re:example for loading picture from DLL
In article <XXXX@XXXXX.COM>, John writes:
QuoteI have a lot a picture to include in a wizard. as, say, JPegs.RC. Add lines to it like IMAGE1 RCDATA "image1.jpg" IMAGE2 RCDATA "image2.jpg" If you use filenames only the files have to sit in the same folder the RC file is in, but you can use full pathes as well. Leave the DPR file as it is (no added code), save the project and build it. This gives you a DLL that basically contains no code (with the exception of the RTL initialization, which you cannot remove easily). To use the images in this DLL you load it first using hImageDLL := LoadLibraryEx( PChar(FullPathnameOfDLL), 0, LOAD_LIBRARY_AS_DATAFILE ); if hImageDLL = 0 then RaiseLastOSError; Loading the DLL this way executes no code in it. Having the DLLs module handle you can get at the images by using a TResourceStream: rs := TResourceStream.Create( HImageDLL, 'IMAGE1', RT_RCDATA ); try aJpegImage.LoadFromStream(rs); finally rs.Free; end; Types used are hImageDLL: THAndle; // or HMODULE rs : TResourceStream; aJpegImage: TJpegImage; The sample above assumes that aJpegImage was created elsewhere, of course. Peter Below (TeamB) Use the newsgroup archives : www.mers.com/searchsite.html www.tamaracka.com/search.htm groups.google.com www.prolix.be |
John
![]() Delphi Developer |
2005-10-18 05:01:28 PM
Re:example for loading picture from DLL
Thanks Peter.
|