Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2002, 05:33 PM
3homer
Guest
 
Posts: n/a
Default how to read resource file ?

i made a resource file
jpegs.res
_______________
jpg1 jpeg 1.jpg
jpg2 jpeg 2.jpg
jpg3 jpeg 3.jpg
jpg4 jpeg 4.jpg
_______________
how to read them to a TIamge?

~3homer~
Thanx,very much.
Reply With Quote
  #2  
Old 07-17-2002, 08:34 PM
JJe JJe is offline
Senior Member
 
Join Date: May 2001
Posts: 120
Default RE: how to read resource file ?

I have done it this way on my application. I use .bmp picture format.

procedure TForm1.FormCreate(Sender: TObject);
begin
img1.Picture.Bitmap.LoadFromResourceName(hInstance , 'LOGO');
end;


img1 is name of the TImage-component. Resource file (.rc file) looks like this:

LOGO BITMAP "logo.bmp"

And of course I have compiled .rc file to .res file.

This works just great to me!

- JJe
Reply With Quote
  #3  
Old 07-17-2002, 11:17 PM
andyho andyho is offline
Senior Member
 
Join Date: Jul 2001
Posts: 1,446
Default RE: how to read resource file ?

It works this way only for BMP resources, however for JPEG ones it needs a little bit more work.

var
r: TStream;
i: TJpegImage;
begin
r:=NIL;
i:=NIL;
try
r:=TResourceStream.Create(hinstance, 'JPEG1', rt_rcdata);
i:=TJpegImage.Create;
i.loadfromstream(r);
image1.picture.assign(i);
finally
r.free;
i.free;
end;
end;



Bye,
Andy

If it helped please click accept...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:27 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.