您的位置:首页 > 其它

GDI+ 学习记录(28) 图像颜色的数据格式 - PixelFormat

2010-12-08 21:24 288 查看


//指定位图颜色
var
g,gbit:TGPGraphics;
bit1,bit2:TGPBitmap;
sb:TGPSolidBrush;
begin
g:=TGPGraphics.Create(Canvas.Handle);
g.Clear(aclWhite);
sb:=TGPSolidBrush.Create(aclBlue);{画刷为蓝色}

bit1:=TGPBitmap.Create(200,32,PixelFormat32bppARGB);{指定为 32 位颜色}
bit2:=TGPBitmap.Create(200,32,PixelFormat1bppIndexed);{只有两种颜色}

gbit:=TGPGraphics.Create(bit1);
gbit.FillRectangle(sb,0,0,200,32);
g.DrawImage(bit1,11,11,bit1.GetWidth,bit1.GetHeight);{画出来是蓝色}

gbit:=TGPGraphics.Create(bit2);
gbit.FillRectangle(sb,0,0,200,32);
g.DrawImage(bit2,11,100,bit2.GetWidth,bit2.GetHeight);{画出来是黑色, 它只有黑白两色}

sb.Free;
bit1.Free;
bit2.Free;
gbit.Free;
g.Free;
end;


PixelFormat: (指定图像中每个像素的颜色数据的格式)

Delphi微软说明
PixelAlphaAlpha像素数据包含没有进行过自左乘的 alpha 值。
PixelCanonicalCanonical默认像素格式,每像素 32 位。此格式指定 24 位颜色深度和一个 8 位 alpha 通道。
PixelDontCareDontCare没有指定像素格式。
PixelExtendedExtended保留。
PixelFormat16bppArgb1555Format16bppArgb1555像素格式为每像素 16 位。该颜色信息指定 32,768 种色调,其中 5 位为红色,5 位为绿色,5 位为蓝色,1 位为 alpha。
PixelFormat16bppGrayScale Format16bppGrayScale 像素格式为每像素 16 位。该颜色信息指定 65536 种灰色调。
PixelFormat16bppRgb555Format16bppRgb555指定格式为每像素 16 位;红色、绿色和蓝色分量各使用 5 位。剩余的 1 位未使用。
PixelFormat16bppRgb565Format16bppRgb565指定格式为每像素 16 位;红色分量使用 5 位,绿色分量使用 6 位,蓝色分量使用 5 位。
PixelFormat1bppIndexedFormat1bppIndexed指定像素格式为每像素 1 位,并指定它使用索引颜色。因此颜色表中有两种颜色。
PixelFormat24bppRgbFormat24bppRgb指定格式为每像素 24 位;红色、绿色和蓝色分量各使用 8 位。
PixelFormat32bppArgbFormat32bppArgb指定格式为每像素 32 位;alpha、红色、绿色和蓝色分量各使用 8 位。
PixelFormat32bppPArgbFormat32bppPArgb指定格式为每像素 32 位;alpha、红色、绿色和蓝色分量各使用 8 位。根据 alpha 分量,对红色、绿色和蓝色分量进行自左乘。
PixelFormat32bppRgbFormat32bppRgb指定格式为每像素 32 位;红色、绿色和蓝色分量各使用 8 位。剩余的 8 位未使用。
PixelFormat48bppRgbFormat48bppRgb指定格式为每像素 48 位;红色、绿色和蓝色分量各使用 16 位。
PixelFormat4bppIndexedFormat4bppIndexed指定格式为每像素 4 位而且已创建索引。
PixelFormat64bppArgbFormat64bppArgb指定格式为每像素 64 位;alpha、红色、绿色和蓝色分量各使用 16 位。
PixelFormat64bppPArgbFormat64bppPArgb指定格式为每像素 64 位;alpha、红色、绿色和蓝色分量各使用 16 位。根据 alpha 分量,对红色、绿色和蓝色分量进行自左乘。
PixelFormat8bppIndexedFormat8bppIndexed指定格式为每像素 8 位而且已创建索引。因此颜色表中有 256 种颜色。
PixelGdiGdi像素数据包含 GDI 颜色。
PixelIndexedIndexed该像素数据包含颜色索引值,这意味着这些值是系统颜色表中颜色的索引,而不是单个颜色值。
PixelMaxMax此枚举的最大值。
PixelPAlphaPAlpha像素格式包含自左乘的 alpha 值。
PixelUndefinedUndefined未定义像素格式。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: