Link to home
Start Free TrialLog in
Avatar of MaestroDave
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(restype, 'Horship1.res', $00FF0000);
if result then Label1.Caption := 'ok' else label1.caption := 'not ok';
Image1.Picture.Assign(MyImageList);
MyImageList.Free;
end;

But it doesn't seem to work. Can anyone help?
Avatar of inthe
inthe

HI
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(rtBitmap, UpperCase(AName),Images.Width, [lrDefaultColor,lrDefaultSize, lrTransparent], BackgroundColor) then
 raise ELoadImages.Create('Unable to load '+AName+' bitmap !');
 end;

Avatar of MaestroDave

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.
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.
OK, did that. Now get a compilation error:
[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.
Ok, I can now load it, but still don't know how to display it on a form...?
ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cheers Barry & Raymond.  I should really be giving you both points, cause you both helped heaps.