TImage 丢失加载的图片

发布于 2024-08-31 21:44:38 字数 186 浏览 3 评论 0原文

运行 Turbo Delphi Pro。

我正在使用 TImage 来显示 png 图像。

当我重新启动Delphi并加载dpr文件时,TImage仍然存在,但图片丢失了, 需要在编译之前重新加载图片。

一开始我以为是路径问题,所以就从和dpr同目录加载了图片,但是没有帮助。

我还能尝试什么?

Running Turbo Delphi Pro.

I'm using TImage to display a png image.

When I restart Delphi and load the dpr file, TImage is still there, but the picture is lost,
requiring a reload of the picture before compiling.

At first I thought it's a path issue, so I loaded the picture from the same directory as the dpr, but it didn't help.

What else can I try?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

荭秂 2024-09-07 21:44:38

试试这个:

  • 打开您的项目和表单
    巴布亚新几内亚。
  • (重新)加载 PNG 图像。
  • 保存并关闭您的表单。
  • 使用文本编辑器加载您的表单
    DFM
  • 我敢打赌你没有一个大的二进制文件
    你的TImage对象
    ,因为PNG内容
    尚未保存。

最重要的是,您必须将其作为资源包含并在运行时动态加载。

Try this:

  • Open your project and your Form with
    the PNG.
  • (Re)Load the PNG image.
  • Save and close your Form.
  • With a text editor, load your Form
    DFM
  • I bet you don't have a big binary in
    your TImage object
    , because the PNG content
    has not been saved.

Bottom line, you'd have to include it as a resource and load it dynamically at runtime.

执妄 2024-09-07 21:44:38

我用D2006也遇到这个问题。我使用的解决方案与弗朗索瓦的类似。

我有一个 TPngImageCollection 组件,我在设计时收集所有图像。您需要从网上找到 PngImageList 单元。 TPngImageCollection 组件的优点是您可以拥有不同大小的 PNG 图像的集合。

在启动时的运行时,我分配来自每个集合成员的 TImage:

Image1.Picture.Assign (ImageCollection.Items [0].PNGImage) ;
Image2.Picture.Assign (ImageCollection.Items [1].PNGImage) ;
Image3.Picture.Assign (ImageCollection.Items [2].PNGImage) ;
etc

Bingo - 您可以生成具有 alpha 透明度的 PNG 原件(我使用 Serif 的 PhotoPlus 6.0 - 免费且非常强大)并在 TImage 中显示它们。

I ran into this problem as well with D2006. The solution I used is similar to François'.

I have a TPngImageCollection component that I collect all the images in at design time. You will need to find unit PngImageList off the web. The TPngImageCollection component has the advantage that you can have a collection of PNG images of differing sizes.

At run-time on startup, I assign the TImages from each of the collection members:

Image1.Picture.Assign (ImageCollection.Items [0].PNGImage) ;
Image2.Picture.Assign (ImageCollection.Items [1].PNGImage) ;
Image3.Picture.Assign (ImageCollection.Items [2].PNGImage) ;
etc

Bingo - you can produce your PNG originals with alpha transparency (I use PhotoPlus 6.0 from Serif - free and very capable) and show them in a TImage.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文