timage - How to insert picture in the Delphi program itself? -


i have used timage component in program.

at runtime, add image component using:

image1.picture.loadfromfile('c:\users\53941\pictures\eq1.jpg'); 

now, want run program on other computer, not have image file @ source have given in code.

so, how can store image file in program executable itself?

store image file in program's resources, using .rc script or ide's resources , images dialog. read embarcadero's documentation more details:

resources , images

you can use tresourcestream access resource data @ runtime. construct tjpegimage object, load stream it, , assign timage:

uses   ..., classes, jpeg;  var   strm: tresourcestream;   jpg: tjpegimage; begin    strm := tresourcestream.create(hinstance, '<resource identifier>', rt_rcdata);   try     jpg := tjpegimage.create;     try       jpg.loadfromstream(strm);       image1.picture.assign(jpg);           jpg.free;     end;       strm.free;   end; end; 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -