- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在使用 32 位 TBitmap 时,我从 Canvas.Pixels 切换到 ScanLine。
然后我将值设置为红色,却发现它显示为蓝色。
知道为什么吗?
以下是代码摘录:
procedure TForm1.FormPaint(Sender: TObject);
var
varBitmap: TBitmap;
pLock: PIntegerArray;
iColor: integer;
begin
varBitmap := TBitmap.Create;
varBitmap.PixelFormat := pf32bit;
varBitmap.Width := 800;
varBitmap.Height := 600;
// Set Pixels to Red
varBitmap.Canvas.Pixels[0, 0] := $0000FF;
// Shows $FF0000 (blue)
pLock := varBitmap.ScanLine[0];
iColor := pLock[0];
ShowMessageFmt('%x', [iColor]);
// Set ScanLine to Red
pLock[0] := $0000FF;
// Displays a blue pixel
Canvas.Draw(0, 0, varBitmap);
end;
似乎 TColor 与内存中的不一样,但这没有意义。
欢迎任何建议。 ;)
最佳答案
VCL 位图类,TBitmap
是 Windows native 设备独立位图 (DIB) 的包装器。这些位图对象可以存储多种不同像素格式的位图。它们可以是单色的,每像素一位,最多每像素 32 位,这是您正在使用的格式。它们还可以用于存储基于调色板的位图,其中每个像素都保存颜色表的索引。
访问您引用的像素数据的两种方法是 Pixels
TCanvas
的属性(property)和 ScanLine
TBitmap
的属性(property)。
Pixels
TCanvas
的属性(property)是 GDI GetPixel
的包装器和 SetPixel
功能。这些是在 COLORREF
上运行的高级函数。值(value)观。 COLORREF
的文档说:
The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.
换句话说,一个 COLORREF
value 有固定的像素颜色编码方式。 GetPixel
和SetPixel
函数主要处理固定 COLORREF
之间的转换形式和底层原始位图像素数据。另请注意 COLORREF
不能代表alpha值。 COLORREF
值的格式为 $00BBGGRR。
另一方面,ScanLine
TBitmap
的属性(property)返回一个指向底层 DIB 对象的原始像素数据的指针。您此处使用的数据是 32bpp 像素数据,该数据的约定是以 $AARRGGBB 格式存储。 Windows documentation对于 32bpp 数据说:
The bitmap has a maximum of 2^32 colors. If the biCompression member of the BITMAPINFOHEADER is BI_RGB, the bmiColors member of BITMAPINFO is NULL. Each DWORD in the bitmap array represents the relative intensities of blue, green, and red for a pixel. The value for blue is in the least significant 8 bits, followed by 8 bits each for green and red. The high byte in each DWORD is not used.
所以事实上这段文字是不正确的并且已经过时了。每个 DWORD
中的高字节事实上,如果使用的话,就是 Alpha channel 。
关于Delphi TBitmap - 为什么 Pixels 和 ScanLine 不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22291162/
我正在编写一个 cordova 应用程序,需要隔离这些谷歌手机以调整样式 鉴于此: 我很难区分任何一款 Google Pixel 手机。 @media only screen and (min-wid
在 Web 布局中为像素和百分比定义距离的用例是什么? 在多个分辨率方面使用像素有什么缺点吗?它们会正确缩放吗? 最佳答案 百分比布局 这通常称为流体布局。您的元素将占用它们可用总空间的定义百分比。这
我正在处理使用 pixel.getGreen() 方法的作业。我的问题是,当我尝试使用 pixel.getGreen (不带括号)时,我得到的结果与使用带括号的方法时得到的结果不同。两者有什么区别?
我正在寻找 Pixel 2 虚拟设备。我已经更新到最新的 Android Studio RC2 版本,但似乎 Pixel 设备是列表中的最后一个。 我知道我可以创建具有 Pixel 2 分辨率的自定义
我需要降低图片的实际分辨率,使 4 像素矩形中的每个像素都是这 4 个像素的平均值。 即 p1 p2 p6 p7 a1 a1 a2 a2 p3 p4 p8 p9 ... -> a1
我正在尝试使用 Electron 在桌面应用程序中创建一个简单的 javascript Canvas 游戏。我正在使用像素艺术,所以为了让我的像素艺术图像在缩放时保持良好的质量,我使用了以下 CSS:
我想对 ee.Image 逐个像素地执行一些计算,但是,计算的结果必须服从概率高斯分布,因此一些像素将被修改,而另一些则不会。我已经编写了一个概率函数,但我不知道如何将它应用于 GEE 中的每个像素。
这是我的代码: int columns 3; int columnWidth = self.layer.bounds.size.width / 3; for (int c = 1; c < colum
1.将image.jpg加载到数组中2.从数组中随机选择坐标并显示该像素及其所有属性3. 从数组中使用弹出坐标。4. 重复#2 直到数组为空 这将显示一个填充了随机像素的图像。 最终结果始终是原始图像
我正在开发一个从 Wi-Fi 摄像头接收 UPD 广播数据包的应用程序。 在我发现在 Google Pixel 2/Pixel 2 XL 接收 UPD 广播数据包的问题之前,它曾经很好。 为了找出原因
我想将新的 Google 手机添加到 Chrome 开发工具中的模拟设备中。 有人知道 Pixel 3 和 Pixel 3 XL 的正确自定义设备设置吗? 最佳答案 您必须输入 视口(viewport
我在我的 React Native 应用程序中使用 0.5px 边框。这在大多数设备上效果很好,但在 iPhone 6 plus 上,这些边框显得模糊。在阅读了像素比率之后here我决定使用类似下面的
我正在开发一个网站,想看看它在 Google Pixel 和 Google Pixel XL 设备上的运行情况。由于我无权访问这些设备,因此我需要知道这些设备的视口(viewport)宽度、高度和设备
我知道我们是在点而不是像素上操作,在大多数情况下这很方便,但我需要使 UIView 的高度为 1 像素而不是 2 像素。因此,如果您在 Interaface 构建器中拖放一些 UIView(分隔线),
摘要和目标: 我正在尝试制作一个着色器来为游戏编辑器执行简单的窗口效果。该效果将绘制一个具有低值边框颜色和高值突出显示的框架。我尝试了很多方法,但总的来说,我只提出了一种可能的解决方案来使用 GPU
我的代码目前包含加载图像,这是成功的,我认为与问题无关。 然后我继续将彩色图像转换为名为 rgb 的 np.array # convert image into array rgb =
我对使用 Visual C++ 进行图像处理相当陌生,我正在寻找一种方法来读取黑白 TIFF 文件并将图像写入表示 0 或 1 的十六进制值数组,然后获取 0 的位置信息(黑色)或 1(白色)。 经过
WebKit 引入了 -webkit-device-pixel-ratio 媒体功能和 window.devicePixelRatio JavaScript 属性,以允许网络作者检测他们的页面是否正在
我正在执行一项任务,将每个像素有 8 位 (uint8_t) 且每个像素只能为 0 或 1(或 255)的大型二进制标签图像转换为数组uint64_t 数字和 uint64_t 数字中的每一位代表一个
需要能够为不同的设备像素比值指定不同的 css。如何做到这一点 例如, 0 @media (-webkit-max-device-pixel-ratio:1.0) { > .
我是一名优秀的程序员,十分优秀!