问题描述
我有一个Delphi应用程序,使用TImage显示图像。
I have a Delphi application which displays an image using a TImage.
图像的位置存储在数据库中,并在加载时检索并直接使用代码类似如下:
The location of the image is stored in a database and retrieved on load and set directly using code similar to below:
Image1.Picture.LoadFromFile(Query1.FieldByName('image').AsString);
我想要能够显示和编辑在上面加载的文件名,我是对的没有办法直接从TImage组件访问,我需要分开存储文件。
I want to be able to display and edit the Filename being loaded during the above, am I right that there is no way to access that directly from the TImage component and that I will need to store the filename separately?
推荐答案
不,没有。您可以自己存储它。
No, there isn't. You can store it yourself, though.
var
ImageFileName: string;
begin
ImageFileName := Query1.FieldByName('image').AsString;
Image1.Picture.LoadFromFile(ImageFileName);
end;
在需要访问文件名称的地方可以看到ImageFileName变量。
Declare the ImageFileName variable at a place where it will be visible everywhere you need access to the file name.
这篇关于可以直接检索TPicture的文件名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!