以 png 格式剪辑幻灯片 (Delphi 2010)

发布于 2024-11-16 03:38:34 字数 216 浏览 9 评论 0原文

我有一个 png 格式的图像幻灯片,如下所示: filmstrip

我想知道如何剪辑每个图像并将这些图像放入 TImageList 控件中,始终保留透明度。

[编辑]

是的,在设计时,RRUZ 提到的技巧工作得很好,但我想在运行时剪辑图像,即通过从资源或文件加载幻灯片

I have a filmstrip of images in png format like this:
filmstrip

I'd like to know how to clip each of the images and put these images in a TImageList control, always preserving the transparency.

[EDIT]

Yes, at designtime the trick mentioned by RRUZ works fine, but I wanted to clip the images at runtime, i.e. by loading the filmstrip from resource or file

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

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

发布评论

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

评论(3

回梦 2024-11-23 03:38:34

您必须按照以下步骤操作:

  • ColorDepth 属性设置为 cd32Bit

  • DrawingStyledsTransparent

  • 高度= 48,

  • 宽度=48,

然后加载图像,结果将是

在此处输入图像描述

You must follow these steps:

  • set ColorDepth property to cd32Bit,

  • DrawingStyle to dsTransparent,

  • Height= 48,

  • Width=48,

then load the image and the result will be

enter image description here

陌上青苔 2024-11-23 03:38:34

Just import into the imagelist. It'll complain that it's too big and offer to break it into pieces for you. Works fine for me on D2005.

Another cool tip: I use AWIcons Pro http://www.awicons.com/icon-editor/ to edit icons (nice editor!). It has a feature that can export an icon as an imagelist (.bmp or .png format), thus making the filmstrip out of an icon. This makes it really handy to edit these things in .ico format, with a series of cells all the same size and depth, with each cell varying slightly. Then you export as an imagelist (I use .png) and then Delphi can break them back out into individual cells. Very slick. AWIcons isn't free, but features like this really make it productive.

海风掠过北极光 2024-11-23 03:38:34

在运行时,您必须调用 TImageList.FileLoad。除非它不起作用。

这又调用 ImageList_LoadImage,uFlags 参数值包括位 LR_LOADFROMFILE,这会导致 Windows 从磁盘上的文件加载。此底层功能仅支持 TBitmap (BMP) 格式。

请参阅几乎重复的问题。 PNG 支持是一项设计时功能,可将 PNG 数据转换为内部非 PNG 格式且不完全是 BMP 格式,由 MS 通用控件库内部使用。以文本形式查看您的 DFM,您将看到您的 PNG 输入已变成什么。其他答案表明,使用基于位图颜色的透明度保留了透明度。

如果您想以 PNG 格式保存数据,则不应使用 VCL TImageList 来存储它,因为您必须将 PNG 转换为 TBitmap 才能实际使用 TImageList。

At runtime, you would have to call TImageList.FileLoad. Except it won't work.

This in turn calls ImageList_LoadImage, with uFlags parameter value including the bit LR_LOADFROMFILE, which causes Windows to load from a file on disk. This underlying functionality only supports TBitmap (BMP) format.

See the nearly-duplicate question. PNG support is a designtime feature that is converting the PNG data into an internal non-PNG and not-exactly-a-BMP-either format, used internally by MS Common Controls library. View your DFM as text, and you will see what your PNG inputs have been turned into. The other answers show you that transparency is preserved, using bitmap-color based transparency.

If you want to keep your data in PNG format, you shouldn't be using a VCL TImageList to store it, because you're going to have to do a conversion from PNG to TBitmap to actually use TImageList.

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