今天做界面, 在imagelist里加载一个带有半透明通道的PNG图, 结果发现图片居然发暗, 如下:

原图: IDE里加载以后的图:

明显变暗...查询了源码, 无果

然后又用2010去测试, 发现没问题...可惜2010版本看不到ImageListEditer的源码, 所以无从比较

随后我又用代码去动态加载图片, 发现仍然会有图片变暗的问题:

var
nWIC: TWICImage;
nBmp: TBitmap;
begin
nWIC := TWICImage.Create;
nWIC.LoadFromFile('d:\542725.png'); nBmp := TBitmap.Create;
nBmp.Assign(nWIC); ImageList1.Add(nBmp, nil);
nBmp.Free;
nWIC.Free;
end;

继续查找源码, 经过1个多小时的各种郁闷, 终于发现了一个以前被忽略过的属性: nBmp.AlphaFormat

从帮助上看到其描述:

Vcl.Graphics.TAlphaFormat

From RAD Studio API Documentation
 

Delphi

TAlphaFormat = (afIgnored, afDefined, afPremultiplied);

C++

enum DECLSPEC_DENUM TAlphaFormat : unsigned char { afIgnored, afDefined, afPremultiplied };

Properties

Type Visibility Source Unit Parent
enum public
Vcl.Graphics.pas
Vcl.Graphics.hpp
Vcl.Graphics Vcl.Graphics

Description

TAlphaFormat indicates how the reserved byte of each pixel is used in a 32 bit bitmap.

TAlphaFormat has the following values:

Value Meaning

afIgnored

The Reserved byte in the TRGBQuad is ignored.

afDefined

The reserved byte in the TRGBQuad contains an alpha value.

afPremultiplied

The reserved byte in the TRGBQuad contains an alpha value. The red, green, and blue values have been premultiplied with the alpha value.

似乎应该使用afDefined值, 可以让BMP理解透明通道的值, 可是写了测试代码, 却无效果

试试其他的值, 发现使用afIgnored的时候是正常的...-_- 不知道为啥

var
nWIC: TWICImage;
nBmp: TBitmap;
begin
nWIC := TWICImage.Create;
nWIC.LoadFromFile('d:\542725.png'); nBmp := TBitmap.Create;
nBmp.Assign(nwic);
nBmp.AlphaFormat := afIgnored; ImageList1.Add(nbmp, nil);
nBmp.Free;
nWIC.Free;
end;

可惜在IDE界面里, 直接使用编辑器向ImageList添加图像仍然是灰色的, 无解....只好通过代码从资源文件中加载了.....先这么办吧

XE5 ImageList的BUG?的更多相关文章

  1. ImageList半透明,Alpha通道bug处理。

    由于ImageList的先天障碍,对alpha通道支持不好.虽然到xp有所改善,但瑕疵依然存在. 通过reflactor发现ImageList通过windows api来进行读写的.写入数据时会对原始 ...

  2. 修正 XE5 Android 键盘三个问题

    说明:XE5 在 Android 平台上存在这一些键盘操作的问题,目前发现有下列几种: 按键盘上的隐藏键后,无法按上一页(需要修改 XE5 源码「FMX.VirtualKeyboard.Android ...

  3. DevExpress VCL 13.1.4支持Delphi /C++Builder XE5

    DevExpress VCL 13.1.4支持Delphi /C++Builder XE5 重大变化 ExpressLibrary dxHalfOfPi常数声明已经从cxGeometry单元移到了cx ...

  4. ERROR (ClientException) nova image-list

    nova image-listERROR (ClientException): The server has either erred or is incapable of performi9e-6c ...

  5. 解决EnableVisualStyles Bug

    一位朋友碰到了一个WinForm的问题,在网上搜了一通,没找到能解决问题的方案, 正好我以前以碰到过,在这里把解决方案呈上,以便有遇到此问题的朋友能有帮助. 问题是这样的,当启用了虚拟样式后,设置好的 ...

  6. CnPack for delphi xe5

    CnPack Team is made up of Chinese Programmers and Delphi / C++ Builder fans across the Internet. Our ...

  7. DataSnap服务器从xe2升级到xe5报错的处理

    DataSnap服务器从xe2升级到xe5环境下,能够正常编译,但运行后会报错,如下图: 处理参考: http://blogs.embarcadero.com/pawelglowacki/2013/0 ...

  8. Delphi Compiler Bug?

    I found a Bug of Delphi XE3 Compiler,It may exists in XE4,XE5. Here is the code to show the bug proc ...

  9. 继续吐槽XE5中的boost::thread问题:找不到CC32130MT.DLL

    在XE5中,随便创建一个HelloWorld程序,加入boost::thread的功能,编译链接后,无法运行,无法调试,提示找不到CC32130MT.DLL 这个DLL名字看上去好像是跟多线程有关的, ...

随机推荐

  1. PHP历程(PHP与MYSQL数据库之间连接、创建和关闭)

    <?php define('WXLEVELS_DB_HOST','127.0.0.1'); //服务器 define('WXLEVELS_DB_USER','root'); //数据库用户名 d ...

  2. debug note-- nginx php-fpm : Error:The page you are looking for is temporarily unavailable.

    1.在ubuntu下安装配置nginx, mysql, php 安装步骤: 参考:https://www.digitalocean.com/community/tutorials/how-to-ins ...

  3. BZOJ2769 : YY的快速排序

    将数字离散化并去重,则对于一对逆序对$i<j$,$a_i>a_j$,贡献为$\frac{2}{a_i-a_j+1}$,因此只要对于每个差值统计出对应的逆序对个数即可. 将序列分块,块内平方 ...

  4. BZOJ4546(原) : 三元组

    设$f(x)=\sum_{x|d}p(d)$. 则$ans=\sum_{i=1}^n\sum_{j=1}^n\sum_{k=1}^n\mu(i)\mu(j)\mu(k)f(lcm(i,j))f(lcm ...

  5. Storm实战:在云上搭建大规模实时数据流处理系统(Storm+Kafka)

    在大数据时代,数据规模变得越来越大.由于数据的增长速度和非结构化的特性,常用的软硬件工具已无法在用户可容忍的时间内对数据进行采集.管理和处理.本文主要介绍如何在阿里云上使用Kafka和Storm搭建大 ...

  6. POJ1419 & 最大团

    题意: 求一个图的最大点独立集.SOL: 转化为补图的最大团,最大团似乎是一个NP问题,那么只好爆搜了. 补一补图论基础,代码不想打了,来自某blog #include <iostream> ...

  7. ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]的用法

    父类:public class BaseHibernateDaoSupport<T>{ private Class<T> entityClass; public BaseHib ...

  8. 【BZOJ】2212: [Poi2011]Tree Rotations

    题意 给一棵\(n(1 \le n \le 200000)\)个叶子的二叉树,可以交换每个点的左右子树,要求前序遍历叶子的逆序对最少. 分析 可以发现如果交换非叶结点的左右子树,对子树内的交换无影响, ...

  9. 【BZOJ1067】【POJ2637】降雨量

    1067: [SCOI2007]降雨量 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 3004  Solved: 767[Submit][Status] ...

  10. 【Eclipse】几个最重要的快捷键

    1几个最重要的快捷键    代码助手:Ctrl+Space(简体中文操作系统是Alt+/) 快速修正:Ctrl+1 单词补全:Alt+/ 打开外部Java文档:Shift+F2   显示搜索对话框:C ...