MaestroDave
asked on
view image in .res file
Hi, I've got some .res files that I'd like to read / view with delphi, but I don't know how. Each .res file contains a number of bitmaps.
So far, I have something like:
var
MyImageList : TImageList;
restype: TResType;
result : boolean;
begin
restype := rtBitmap;
MyImageList := TImageList.CreateSize( 1000,1000 );
result := MyImageList.ResourceLoad(r estype, 'Horship1.res', $00FF0000);
if result then Label1.Caption := 'ok' else label1.caption := 'not ok';
Image1.Picture.Assign(MyIm ageList);
MyImageList.Free;
end;
But it doesn't seem to work. Can anyone help?
So far, I have something like:
var
MyImageList : TImageList;
restype: TResType;
result : boolean;
begin
restype := rtBitmap;
MyImageList := TImageList.CreateSize( 1000,1000 );
result := MyImageList.ResourceLoad(r
if result then Label1.Caption := 'ok' else label1.caption := 'not ok';
Image1.Picture.Assign(MyIm
MyImageList.Free;
end;
But it doesn't seem to work. Can anyone help?
ASKER
hmmm - that didn't work. I'm not saying your code is bad though - maybe there's some reason I cannot open the file. I got the exception 'Unable to load...'.
I know nothing about .res files. All I know is that I can open it using MS C++ builder.
I know nothing about .res files. All I know is that I can open it using MS C++ builder.
Don't the resources have to be compiled into the exe for this to work?
ie: add
{$R horship1.res}
to the .DPR file.
And call your code/barry's code with the name of a resource in the res file (you can see the names in C++ builder...)
Cheers,
Raymond.
ie: add
{$R horship1.res}
to the .DPR file.
And call your code/barry's code with the name of a resource in the res file (you can see the names in C++ builder...)
Cheers,
Raymond.
ASKER
OK, did that. Now get a compilation error:
[Error] RLINK32: Unsupported 16bit resource in file "C:\Steph\horship1.res"
[Error] RLINK32: Unsupported 16bit resource in file "C:\Steph\horship1.res"
That would explain a lot!
The easiest thing is probably to create a new 32 bit resource file in VC++ and copy the resources from the 16 bit res file to the 32 bit one (either that or locate the original .RC file and images and recompile the res file)
Once you have done that give it another
go...
Cheers,
Raymond.
The easiest thing is probably to create a new 32 bit resource file in VC++ and copy the resources from the 16 bit res file to the 32 bit one (either that or locate the original .RC file and images and recompile the res file)
Once you have done that give it another
go...
Cheers,
Raymond.
ASKER
Ok, I can now load it, but still don't know how to display it on a form...?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers Barry & Raymond. I should really be giving you both points, cause you both helped heaps.
try this to se if helps:
Regards Barry
type
ELoadImages = class(Exception)
end;
procedure LoadBitMapResource(Images : TImageList; const AName : string; BackgroundColor : TColor);
begin
if not Images.GetResource(rtBitma
raise ELoadImages.Create('Unable
end;