at most four images can be used as overlay masks怎么理解?

ooolinux 2020-11-25 08:55:57
Vcl.ImgList.TCustomImageList.Overlay方法
Description
Identifies an image in the list as an image that can be used as an overlay mask.
Use Overlay to assign an overlay index to one of the images in the list. Once an image has an overlay index, it can be used as an overlay mask. An overlay mask is an image drawn transparently over another image.
ImageIndex identifies the image that can act as an overlay mask.
Overlay is the overlay index to assign to that image. It must be a value between 0 and 3 (inclusive). Note that this means at most four images can be used as overlay masks.
If successful, Overlay returns true.
To draw an overlay mask over an image use the DrawOverlay method with the index of the overlay mask.
——————————
最多只有4张图像可以被用为覆盖遮罩,怎么理解?
...全文
396 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
ooolinux 2020-11-30
  • 打赏
  • 举报
回复
引用 15 楼 早打大打打核战争 的回复:
把设置为mask的图绘制出来就能看出它的生成mask的方法了

如果mask不是手动添加的图片,而且通过指定图像颜色自动生成的,可能无法单独绘制出来,只能随着图像叠加绘制。
  • 打赏
  • 举报
回复
把设置为mask的图绘制出来就能看出它的生成mask的方法了
  • 打赏
  • 举报
回复
我看了一下VCL中ImageList的源码(Vcl.ImgList.pas),原来这是一个Windows限制,TCustomImgList.Overlay方法内部调用了comctl32.dll中的ImageList_SetOverlayImage,而Windows中ImageList的设计对OverlayMask的数量是有限制的,参考:https://docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-imagelist_setoverlayimage
ooolinux 2020-11-29
  • 打赏
  • 举报
回复
引用 13 楼 ooolinux 的回复:
[quote=引用 12 楼 早打大打打核战争 的回复:]我看了一下VCL中ImageList的源码(Vcl.ImgList.pas),原来这是一个Windows限制,TCustomImgList.Overlay方法内部调用了comctl32.dll中的ImageList_SetOverlayImage,而Windows中ImageList的设计对OverlayMask的数量是有限制的,参考:https://docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-imagelist_setoverlayimage

看来overlay的数量限制是有道理的。我看了这个方法:
Vcl.ImgList.TCustomImageList.DrawOverlay
void __fastcall DrawOverlay(Vcl::Graphics::TCanvas* Canvas, int X, int Y, int ImageIndex, TOverlay Overlay, bool Enabled = true)/* overload */;
overlay mask不能单独绘制,只能叠加绘制,而且mask好像是单色的,要么全白,要么全黑,要么黑白,要么白黑,比如要在棋盘上透明绘制一个象棋的棋子,mask就是一张圆形的黑白图片,棋子绘制的时候,圆形外部的地方变为透明。ImageList中所有图像的尺寸必须是一致的,很适合存储象棋的所有棋子以及它们的overlay mask。如果mask不是单色的,叠加绘制上去我想不出有什么意义。[/quote]
mask一般只有黑白色一位的色深,用作overlay mask的手工PS的图像一般也是,所以一组图像最多有4张overlay mask也就够了。
Vcl.ImgList.TCustomImageList.AddMasked
int __fastcall AddMasked(Vcl::Graphics::TBitmap* Image, System::Uitypes::TColor MaskColor);
Description
Adds an image to the image list along with a color which is used to generate the transparent mask.
AddMasked is similar to Add except that a mask bitmap is not specified. Instead, a color that can be used to automatically generate the masks is specified. Each pixel of the specified color in the image bitmap is changed to black, and the corresponding bit in the mask is set to one. As a result, any pixel in the image that matches the specified color is transparent when the image is drawn. AddMasked returns -1 if it fails, 0 if it's successful.
ooolinux 2020-11-29
  • 打赏
  • 举报
回复
引用 12 楼 早打大打打核战争 的回复:
我看了一下VCL中ImageList的源码(Vcl.ImgList.pas),原来这是一个Windows限制,TCustomImgList.Overlay方法内部调用了comctl32.dll中的ImageList_SetOverlayImage,而Windows中ImageList的设计对OverlayMask的数量是有限制的,参考:https://docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-imagelist_setoverlayimage

看来overlay的数量限制是有道理的。我看了这个方法:
Vcl.ImgList.TCustomImageList.DrawOverlay
void __fastcall DrawOverlay(Vcl::Graphics::TCanvas* Canvas, int X, int Y, int ImageIndex, TOverlay Overlay, bool Enabled = true)/* overload */;
overlay mask不能单独绘制,只能叠加绘制,而且mask好像是单色的,要么全白,要么全黑,要么黑白,要么白黑,比如要在棋盘上透明绘制一个象棋的棋子,mask就是一张圆形的黑白图片,棋子绘制的时候,圆形外部的地方变为透明。ImageList中所有图像的尺寸必须是一致的,很适合存储象棋的所有棋子以及它们的overlay mask。如果mask不是单色的,叠加绘制上去我想不出有什么意义。
ooolinux 2020-11-28
  • 打赏
  • 举报
回复
引用 6 楼 早打大打打核战争的回复:
这功能我还没用过,不过看意思就是最多同时指定4个ImageList中的图像作为透明mask,另外我看10.2.1中的定义是TOverlay: 0..14; 最多同时15个
我原来猜测的是,对于一张图像,它的overlay mask最多有4张,画时依次透明叠加上去。不过从Help里看不出这个意思。
  • 打赏
  • 举报
回复
这功能我还没用过,不过看意思就是最多同时指定4个ImageList中的图像作为透明mask,另外我看10.2.1中的定义是TOverlay: 0..14; 最多同时15个
ooolinux 2020-11-28
  • 打赏
  • 举报
回复
引用 10 楼 早打大打打核战争 的回复:
因为它内部可能有某种数据结构存储相关信息,使用了固定大小数组存储,而没有使用动态数组

这个是实现,应该不是这么做的原因。
  • 打赏
  • 举报
回复
因为它内部可能有某种数据结构存储相关信息,使用了固定大小数组存储,而没有使用动态数组
ooolinux 2020-11-28
  • 打赏
  • 举报
回复
引用 8 楼 早打大打打核战争的回复:
[quote=引用 7 楼 ooolinux 的回复:][quote=引用 6 楼 早打大打打核战争的回复:]这功能我还没用过,不过看意思就是最多同时指定4个ImageList中的图像作为透明mask,另外我看10.2.1中的定义是TOverlay: 0..14; 最多同时15个

我原来猜测的是,对于一张图像,它的overlay mask最多有4张,画时依次透明叠加上去。不过从Help里看不出这个意思。[/quote]

应该是每个ImageList中最多可以有4或者15个图像指定为透明MASK,每个图像可以透明绘制于其上的MASK是没有限制的
[/quote] 假如ImageList中有几百张图像,不知道为什么要限制其中可作为overlay mask的图片数量?
  • 打赏
  • 举报
回复
引用 7 楼 ooolinux 的回复:
[quote=引用 6 楼 早打大打打核战争的回复:]这功能我还没用过,不过看意思就是最多同时指定4个ImageList中的图像作为透明mask,另外我看10.2.1中的定义是TOverlay: 0..14; 最多同时15个

我原来猜测的是,对于一张图像,它的overlay mask最多有4张,画时依次透明叠加上去。不过从Help里看不出这个意思。[/quote]

应该是每个ImageList中最多可以有4或者15个图像指定为透明MASK,每个图像可以透明绘制于其上的MASK是没有限制的
woniugongzuoshi 2020-11-26
  • 打赏
  • 举报
回复
哈哈哈,我认为就是这个意思,如果实在不够用,你可以动态调整啊
ooolinux 2020-11-26
  • 打赏
  • 举报
回复
引用 3 楼 woniugongzuoshi 的回复:
我感觉就是把index中的图片镜像出一部分作为overlay mask,用overlay管理,用来实现图片叠加的功能。overlay的取值范围限定了overlay mask最多只能有4张,可能是为了管控资源,不能无限制增加。overlay类应该是overlay mask图片的索引,但是他不象一般的索引是个整型,而类似一个子界型,D7是定义的[0..3],XE是定义的[0..15],啊,是16张,哈,我真是个傻逼。

Overlay方法是把ImageList中的一张图像赋值一个Overlay索引,使它可以用作覆盖遮罩。
难道说ImageList中的所有图像,最多只有4张图像可以被用为覆盖遮罩?应该不是这个意思吧?
woniugongzuoshi 2020-11-26
  • 打赏
  • 举报
回复
我感觉就是把index中的图片镜像出一部分作为overlay mask,用overlay管理,用来实现图片叠加的功能。overlay的取值范围限定了overlay mask最多只能有4张,可能是为了管控资源,不能无限制增加。overlay类应该是overlay mask图片的索引,但是他不象一般的索引是个整型,而类似一个子界型,D7是定义的[0..3],XE是定义的[0..15],啊,是16张,哈,我真是个傻逼。
ooolinux 2020-11-26
  • 打赏
  • 举报
回复
引用 1 楼 woniugongzuoshi 的回复:
d7吧,XE可以有15张。相当于在index外,另外建了一个overlay的索引,用drawoverlay方法以这个overlay索引号为参数可以把一张图覆盖在另一张图上,因为是自动去掉了背景色,所以他说透明地覆盖在另一张图上(drawn transparently over another image),效果很酷炫。

这个4张是对于什么来说的?
woniugongzuoshi 2020-11-26
  • 打赏
  • 举报
回复
d7吧,XE可以有15张。相当于在index外,另外建了一个overlay的索引,用drawoverlay方法以这个overlay索引号为参数可以把一张图覆盖在另一张图上,因为是自动去掉了背景色,所以他说透明地覆盖在另一张图上(drawn transparently over another image),效果很酷炫。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧