Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

Loading TImage at Runtime

Loading TImage at Runtime

How do I get my app to load up images at run-time
and not at design-time

Cos far as I know
If I add a bitmap or a jpg on my form
it tends to convert that image into binary form in one of my software binary files and then makes my software run extremely slow cos the image is classed as how sliders and dragboxes are classed in binary form
so how do I get it to load up images from my harddrive without using the opendialog feature
Im sure its something easy to figure out, but I cant find it in my help manual.
I am using TImage

Any one know how to do it?
0
Ben_iti
Asked:
Ben_iti
  • 3
  • 2
  • 2
  • +3
1 Solution
 
dentenerCommented:
Ben,

That's not to difficult, try this:

Image1.Picture.LoadFromFile('blabla.bmp');

Regards,


Paul
0
 
EpsylonCommented:
If you put 'JPEG' in the uses clause you can also load jpeg-files....
0
 
edeyCommented:
The difference here being that if your app is going to *NEED* a pix, loading it at runtime is prob a bad idea, simply because there is no way to ensure that it will be there, save compiling it in with your app (as a reasource)

Gl
Mike
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sauliteCommented:
You simpy must use a command:

     Image1.Picture.LoadFromFile(FileName);

If you want to load Bitmaps and Metafiles, you should werify that unit "graphics" is in your uses list, but if you also want to load JPEG's then you must manually add "jpeg" to your uses list.
0
 
edeyCommented:
saulite, I don't mean to be rude, but prposing an answer that is merely a "rehash" or previous comments *is* considered, well, rather rude.


GL
Mike
0
 
dentenerCommented:
edey is right!! The most important part is the Image1.Picture.LoadFromFile part, and that information was posted lang before your comment was.
0
 
EpsylonCommented:
I agree with Mike and dentener.

Very disturbing too.
0
 
AttarSoftwareCommented:
Hee hee, that is the funniest bit of answer poaching I have seen in a long time...

Should be included in the dictionary under "blatant"

hee, hee, hee...

Tim.
0
 
sauliteCommented:
But what else can i say? That's the right answer. Of course, there is one moore way, how to do that.


procedure TForm1.Button1Click(Sender: TObject);
var
  Bitmap1: TBitmap;
begin
  Bitmap1:=TBitmap.create;
  Bitmap1.LoadFromFile('bitmap1.bmp');
  Image1.Picture.Assign(Bitmap1);
  Bitmap1.Free;
end;

But it's almost the same, except you can assign Bitmap1 to moore than 1 component.
0
 
dentenerCommented:
If I was using your 'method' of answering, then I would have posted a lot of good answers....

The fact remains that you just copied fragments of our comments and posted a new comment as if you 'found' the answer...

AttarSoftware is right, maybe you should look up 'blatant' in the dictionary.
0
 
Ben_itiAuthor Commented:
Thanks Saulite but im going have to unaccept your answer

When I sent the question
Dentener was the first to reply to my question with the correct answer to my question.

When I tryed it the solution out, it worked!

The points go to your Dentener
Dentener, send me a proposed answer thingee and i'll accept it.
Thanks

Ben
0
 
Ben_itiAuthor Commented:
THanks alot

Ben
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now