Reputation: 1695
In VCL I had ImageList
to store images. In FireMonkey there is no ImageList
control. How do I store images in FireMonkey for later use?
Upvotes: 1
Views: 11834
Reputation: 2224
For people who are looking at this question now, since Delphi XE8 FireMonkey has TImageList component
Upvotes: 1
Reputation: 5381
Because there is no ImageList in Delphi Android you have to:
Add your Images to your Project
Project -> Resources and Images
Delcare the Images in 'Resources and Images' as ResourceType RCDATA
Add this procedure:
->
procedure TForm1.load_image_from_resource(var Im1: Timage; res_name: String);
var InStream: TResourceStream;
begin
InStream := TResourceStream.Create(HInstance, res_name, RT_RCDATA);
try
Im1.Bitmap.LoadFromStream(InStream);
finally
InStream.Free;
end;
end
Then Load your Images with e.g.:
var i : nativeint;
begin
i := 1;
load_image_from_resource(Image1, 'Bitmap_' + inttostr(i));
end;
from everywhere.
Upvotes: 5
Reputation: 1695
To add images in FireMonkey (XE4)
Project -> Resources and Images
Then to access it:
procedure TForm1.Button1Click(Sender: TObject);
var
InStream: TResourceStream;
begin
InStream := TResourceStream.Create(HInstance, 'MyPng', RT_RCDATA);
try
Image1.Bitmap.LoadFromStream(InStream);
finally
InStream.Free;
end;
end;
Thanks to Peter Vonča
Upvotes: 12
Reputation: 3586
Put a TPopupMenu on your form and add some Menu Items and assign TBitmap of each TMenuItem. Then you can access bitmaps with this expression:
PopupMenu1.Items[index].Bitmap
or
MenuItem1.Bitmap
MenuItem2.Bitmap
...
Upvotes: 0