delphi TColor格式负片 [英] delphi TColor format Negative

查看:93
本文介绍了delphi TColor格式负片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这是一个简单的问题,但我找不到答案.我正在使用Delphi TColor,并且某些颜色值是负数.有文件记录吗?我需要进行一些颜色转换,例如,转换为RGB.

例如:Label.Color = -16777188;//淡蓝色

谢谢

解决方案

负值不是实际的RGB颜色,而是Windows系统的颜色,它们是可变的.

例如,以下是实际的RGB颜色:

  clRed = $ 000000FF;{00BBGGRR}clBlue = $ 00FF0000;clWhite = $ 00FFFFFF;clBlack = $ 00000000; 

以下是一些系统颜色:

  clWindow = $ FF000005;clWindowText = $ FF000008;clHighlight = $ FF00000D;clActiveCaption = $ FF000002; 

这些不是实际的RGB值,但是代表您的系统颜色.通常, clWindow 是白色的, clWindowText 是黑色的, clHighlight 是某种蓝色等,但是-再次-这些设置可以是在Windows中已更改.

当这些32位整数被解释为 signed 32位整数时,它们将变为负数.那就是您所看到的:

  clWindow = -16777211;clWindowText = -16777208;clHighlight = -16777203;clActiveCaption = -16777214; 

因此,在您的情况下,不能保证-16777188为浅蓝色".以十六进制表示,该值为 $ FF00001C ,我将其识别为 clGradientInactiveCaption ,即非活动的非主题(Windows 9x样式)窗口标题栏的第二个渐变颜色./p>

您知道,在VCL中,您可以像使用实际颜色一样使用这些系统颜色.但是-当然-您获得的实际颜色可能因用户而异.

您可以使用 ColorToRGB 函数从这种系统颜色中获取实际的RGB颜色.在我的系统上, ColorToRGB(clGradientInactiveCaption)产生 $ 00F2E4D7 (实际上是淡蓝色).

hopefully an easy question, but I could not find an answer. I am using Delphi TColor and some color values are negative. Is this documented? I need to do some color conversions, for example, to RGB.

for example: Label.Color=-16777188; //light bluish

Thanks

解决方案

The negative values are not actual RGB colours, but Windows system colours, which are variable.

For instance, the following are actual RGB colours:

clRed   = $000000FF; {00BBGGRR}
clBlue  = $00FF0000;
clWhite = $00FFFFFF;
clBlack = $00000000;

Here are some system colours:

clWindow        = $FF000005;
clWindowText    = $FF000008;
clHighlight     = $FF00000D;
clActiveCaption = $FF000002;

These are not actual RGB values, but represent your system colours. Often, clWindow is white, clWindowText is black, clHighlight is some kind of blue etc., but -- again -- these settings can be changed in Windows.

When these 32-bit integers are interpreted as signed 32-bit integers, they become negative. That's what you are seeing:

clWindow        = -16777211;
clWindowText    = -16777208;
clHighlight     = -16777203;
clActiveCaption = -16777214;

So in your case, -16777188 is not guaranteed to be "light bluish". In hex, this value is $FF00001C and I recognize this as clGradientInactiveCaption, that is, the second gradient colour of an inactive unthemed (Windows 9x-styled) window titlebar.

As you know, in the VCL you can use these system colours as if they were actual colours. But -- of course -- the actual colours you get might vary from user to user.

You can obtain an actual RGB colour from such a system colour by using the ColorToRGB function. On my system, ColorToRGB(clGradientInactiveCaption) yields $00F2E4D7 (indeed light bluish).

这篇关于delphi TColor格式负片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆