Mega Code Archive

 
Categories / Delphi / Graphic
 

Include jpeg as a resource in .exe

Title: Include jpeg as a resource in *.exe For including jpeg as a resource in *.?? the construction {$R MyRes.RES} is necessary. For causing from a resource jpeg is necessary to create an object of TResorceStream type and to load jpeg with LoadFromStream procedure. There is a 'HELP' section which contents a jpeg file in the resource file. {$R MyRes.RES} {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var MyRS: TResourceStream; begin try MyRS:=TResourceStream.Create(HInstance, 'HELP', RT_RCDATA); Image1.Picture.LoadFromFile('example.jpg'); if Image1.Picture.Graphic is TJPEGImage then TJPEGImage(Image1.Picture.Graphic).LoadFromStream(MyRS); finally MyRS.Free; end; end;