Solved

reading a gif file from .res resource

Posted on 1998-07-09
4
319 Views
Last Modified: 2010-04-04
hi,

I made a res file as follows using brcc32
gif.rc =>
gif gif 0.gif

But I cannot get it to load, I always get a read of adress error. So I must be doing something wrong.
Can anyone show me how to load it.

Procedure Tform1.FormCreate(Sender: TObject);
var
?
begin
?
GifImage1.FileName := ?
end;

Thanks
0
Comment
Question by:hellfire052497
  • 2
4 Comments
 
LVL 3

Expert Comment

by:vladika
ID: 1357466
What is GifImage?
If it is nonstandart component, where can I find it?

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357467
Vladika, If you go to Torrys page (http://bes.trendline.co.il/torry/), you can find dozens of components that read GIF and all sorts of graphics. I thought that at leas some of them can read files from resources, but I didn't find aything...
0
 
LVL 3

Accepted Solution

by:
vladika earned 100 total points
ID: 1357468
I think you use TGifImage from Torrys page

1) create gif.rc as you write
gif.rc =>
gif gif 0.gif

2) compile it with brcc32 -> you get gif.res
Now gif.res include gif file as resource (type='GIF', name='GIF')

3) create new project and set GifImage on Form1

4) in your program

{$R gif.res}  // include resource into exe - do not forget !!!

procedure TForm1.FormCreate(Sender: TObject);
begin
  GifImage1.LoadFromResourceName(hInstance, 'GIF'); // 'GIF' - resource name
end;

5) also you can use TResourceStream

{$R gif.res}  // include resource into exe - do not forget !!!

procedure TForm1.FormCreate(Sender: TObject);
var RS: TResourceStream;
begin
  RS := TResourceStream.Create(hInstance, 'GIF', 'GIF'); // Name - 'GIF', Type - 'GIF'
  try
    GifImage1.LoadFromStream(RS); // load from resource stream RS
  finally
    RS.Free;
  end;
end;

0
 

Author Comment

by:hellfire052497
ID: 1357469
The first option works. It is easier then I thought. Thanks.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

786 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