BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

example for loading picture from DLL

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
John
Guest





PostPosted: Mon Oct 17, 2005 4:07 pm    Post subject: example for loading picture from DLL Reply with quote



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


Back to top
Peter Below (TeamB)
Guest





PostPosted: Mon Oct 17, 2005 6:13 pm    Post subject: Re: example for loading picture from DLL Reply with quote



In article <4353cb8e (AT) newsgroups (DOT) borland.com>, John wrote:
Quote:
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?

You can put any kind of files into RCDATA resources. Start by creating
a new DLL project in the IDE. Add new textfile to the project, save it
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 :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.