IGPMatrix 矩阵 是个接口, 要通过 TGPMatrix 实例化后使用, 其内置了很多方法和属性.

TGPColorMatrix 只是一个结构体, 除了矩阵数据(5*5)外, 它只有一个方法: TGPColorMatrix.SetToIdentity.

通过 SetToIdentity 方法可初始化矩阵, 初始化后的数据是:

┏             ┓
┃1  0  0  0  0┃
┃0  1  0  0  0┃
┃0  0  1  0  0┃
┃0  0  0  1  0┃
┃0  0  0  0  1┃
┗             ┛

对角线上的 1 是比例; 应用这个数据后, 目标不会有任何变化.

其中的第 5 行和第 5 列用于辅助运算, 我们主要操作 4*4 的范围; 为便于理解可以这样表示:

┏              ┓
┃rr  gr  br  ar┃
┃rg  gg  bg  ag┃
┃rb  gb  bb  ab┃
┃ra  ga  ba  aa┃
┗              ┛

rr、gg、bb、aa 分别表示红、绿、蓝和透明度的比例; 譬如 aa = 0.5 表示半透明.

第四行的 ra、ga、ba 分别是颜色的增减量; 譬如 ra = 0.1 表示红色增加 10%.

第一列的 rr、rg、rb 分别表示: 红色应用其他颜色的比例; 譬如 rg = 0.5, 那么红色的值将是绿色成分的 50%.

第二列的 gr、gg、gb 分别表示: 绿应用其他颜色的比例.

第三列的 br、bg、bb 分别表示: 蓝色应用其他颜色的比例.

还有一个颜色旋转的概念:

//红色与绿色绕蓝色旋转(其中的 f 是弧度, 弧度 = 角度 * Pi / 180):
┏                       ┓
┃ Cos(f)  Sin(f)  br  ar┃
┃-Sin(f)  Cos(f)  bg  ag┃
┃ rb      gb      bb  ab┃
┃ ra      ga      ba  aa┃
┗                       ┛//绿色与蓝色绕红色旋转:
┏                       ┓
┃rr   gr      br      ar┃
┃rg   Cos(f)  Sin(f)  ag┃
┃rb  -Sin(f)  Cos(f)  ab┃
┃ra   ga      ba      aa┃
┗                       ┛//红色与蓝色绕绿色旋转:
┏                       ┓
┃ Cos(f)  gr  Sin(f)  ar┃
┃-Sin(f)  gg  Cos(f)  ag┃
┃ rb      gb  bb      ab┃
┃ ra      ga  ba      aa┃
┗                       ┛


这个东西可千变万化, 一时很难彻底理解, 譬如前人算出的灰度算法:

┏                      ┓
┃0.299  0.299  0.299  0┃
┃0.518  0.518  0.518  0┃
┃0.114  0.114  0.114  0┃
┃0      0      0      1┃
┗                      ┛

颜色矩阵是通过 ImageAttributes 使用的, 下面是一些简单的例子.



比例设置:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(4, 4, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 红色比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 绿色比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[1, 1] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 蓝色比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[2, 2] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 透明度比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[3, 3] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

增减量:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(4, 4, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 红色增减 }ColorMatrix.SetToIdentity;ColorMatrix.M[4, 0] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 绿色增减 }ColorMatrix.SetToIdentity;ColorMatrix.M[4, 1] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 蓝色增减 }ColorMatrix.SetToIdentity;ColorMatrix.M[4, 2] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 透明度增减 }ColorMatrix.SetToIdentity;ColorMatrix.M[4, 3] := -0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

红色使用其他颜色的比例:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(4, 4, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 红色应用红色的比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 红色应用绿色的比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 1] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 红色应用蓝色的比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 2] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

绿色使用其他颜色的比例:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(4, 4, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 绿色应用红色的比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[1, 0] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 绿色应用绿色的比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[1, 1] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 绿色应用蓝色的比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[1, 2] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

蓝色使用其他颜色的比例:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(4, 4, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 蓝色应用红色的比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[2, 0] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 蓝色应用绿色的比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[2, 1] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 蓝色应用蓝色的比例 }ColorMatrix.SetToIdentity;ColorMatrix.M[2, 2] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

查看独立的颜色通道:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(4, 4, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 只查看红色通道 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] := 1;ColorMatrix.M[1, 1] := 0;ColorMatrix.M[2, 2] := 0;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 只查看绿色通道 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] := 0;ColorMatrix.M[1, 1] := 1;ColorMatrix.M[2, 2] := 0;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 只查看蓝色通道 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] := 0;ColorMatrix.M[1, 1] := 0;ColorMatrix.M[2, 2] := 1;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 半透明查看红色通道 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] := 1;ColorMatrix.M[1, 1] := 0;ColorMatrix.M[2, 2] := 0;ColorMatrix.M[3, 3] := 0.5;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

转灰度:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(4, 4, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 灰度 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] := 0.299;ColorMatrix.M[0, 1] := 0.299;ColorMatrix.M[0, 2] := 0.299;ColorMatrix.M[1, 0] := 0.518;ColorMatrix.M[1, 1] := 0.518;ColorMatrix.M[1, 2] := 0.518;ColorMatrix.M[2, 0] := 0.114;ColorMatrix.M[2, 1] := 0.114;ColorMatrix.M[2, 2] := 0.114;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

加亮、变暗:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(4, 4, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 加亮 }ColorMatrix.SetToIdentity;ColorMatrix.M[3, 0] := 0.2;ColorMatrix.M[3, 1] := 0.2;ColorMatrix.M[3, 2] := 0.2;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 变暗 }ColorMatrix.SetToIdentity;ColorMatrix.M[3, 0] := -0.2;ColorMatrix.M[3, 1] := -0.2;ColorMatrix.M[3, 2] := -0.2;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

颜色旋转:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;f: Single;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(4, 4, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;f := 30 * Pi / 180; { 准备旋转 30 度角 }{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 红色与绿色绕蓝色旋转 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] :=  Cos(f); ColorMatrix.M[0, 1] := Sin(f);ColorMatrix.M[1, 0] := -Sin(f); ColorMatrix.M[1, 1] := Cos(f);Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 绿色与蓝色绕红色旋转 }ColorMatrix.SetToIdentity;ColorMatrix.M[1, 1] :=  Cos(f); ColorMatrix.M[1, 2] := Sin(f);ColorMatrix.M[2, 1] := -Sin(f); ColorMatrix.M[2, 2] := Cos(f);Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);{ 红色与蓝色绕绿色旋转 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] :=  Cos(f); ColorMatrix.M[0, 2] := Sin(f);ColorMatrix.M[1, 0] := -Sin(f); ColorMatrix.M[1, 2] := Cos(f);Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

对比度:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');Rect.Initialize(10, 10, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 对比度 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] := 1.1;ColorMatrix.M[1, 1] := 1.1;ColorMatrix.M[2, 2] := 1.1;ColorMatrix.M[3, 0] := 0.001;ColorMatrix.M[3, 1] := 0.001;ColorMatrix.M[3, 2] := 0.001;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

反色:


uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);
varGraphics: IGPGraphics;Img: IGPImage;Attr: IGPImageAttributes;ColorMatrix: TGPColorMatrix;Rect: TGPRectF;Brush: IGPHatchBrush;
beginGraphics := TGPGraphics.Create(Handle);Brush := TGPHatchBrush.Create(HatchStyleDiagonalCross, $FFD0D0D0, $FFFFFFFF);Graphics.FillRectangle(Brush, TGPRect.Create(ClientRect));Img := TGPImage.Create('C:\GdiPlusImg\ImageFileSmall.jpg');Rect.Initialize(10, 10, Img.Width * 0.75, Img.Height * 0.75);Attr := TGPImageAttributes.Create;{ 原始图片 }Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, nil);{ 反色(或叫负片、底片)效果 }ColorMatrix.SetToIdentity;ColorMatrix.M[0, 0] := -1;ColorMatrix.M[1, 1] := -1;ColorMatrix.M[2, 2] := -1;ColorMatrix.M[3, 0] := 0.999;ColorMatrix.M[3, 1] := 0.999;ColorMatrix.M[3, 2] := 0.999;Attr.SetColorMatrix(ColorMatrix);Graphics.TranslateTransform(Rect.Width + Rect.X, 0);Graphics.DrawImage(Img, Rect, 0, 0, Img.Width, Img.Height, UnitPixel, Attr);
end;

GdiPlus[59]: 图像(十一) IGPImageAttributes 之颜色矩阵(TGPColorMatrix)变换相关推荐

  1. 【Android 应用开发】Paint 滤镜原理 之 颜色矩阵 ( 颜色模式 | 颜色通道 | 颜色矩阵 | 矩阵运算 | 矩阵乘法 | 矩阵加法 | 颜色矩阵深入解析 )

    文章目录 颜色模式 颜色通道 Android 中的颜色矩阵 矩阵乘法运算 滤镜中的矩阵乘法运算 矩阵加法运算 滤镜中的矩阵乘法运算 滤镜运算原理 ( 总结 ) 实际滤镜理论示例 颜色模式 颜色模式 : ...

  2. python 图像快速替换某种颜色

    文章目录 一.通过遍历替换 二.通过矩阵操作加快替换 三.结果对比 四.程序解释 五.完整的测试程序 最近的对图像数据进行处理的时候需要将图像中的某个颜色替换为另一个颜色,但是网络上找到的方法都是通过 ...

  3. matlab_颜色矩阵三原色

    matlab绘图时,通过plottools调出的面板可以可视化选择曲线散点等图像的颜色,但这种方法只是人工肉眼识别,其实我们可以用三原色矩阵来控制图像颜色: 其中,纯红是[1 0 0],纯绿是[0 1 ...

  4. ColorMatrix颜色矩阵让图片千变万化

    在自定义控件中最熟悉的就是Paint,Canvas,path,Matrix等,要想炫酷效果这几个类必不可少.Paint.setColorFilter(ColorFilter filter):设置颜色过 ...

  5. Egret中颜色矩阵和滤镜的使用与介绍

    一:颜色矩阵 颜色矩阵说明 颜色矩阵数据说明: 实际的颜色值由下面的公式决定: redResult = (a[0] * srcR) + (a[1] * srcG) + (a[2] * srcB) + ...

  6. [AS3][Matrix][利用颜色矩阵进行颜色变换]

    import  flash.filter.ColorMatrixFilter; 颜色矩阵:var arr:Array ; R   G   B   A  Off R   1    0   0   0   ...

  7. python怎么设置颜色深浅变化_机器学习中减弱不同图像数据色调及颜色深浅差异...

    关键词:消除不同图像数据色调差异/消除颜色深浅差异/病理/机器学习/深度学习/人工智能 机器学习训练图像数据时可能会因为图像数据之间的颜色深浅,色调等影响训练和预测结果,本方法可以减弱颜色深浅/色调不 ...

  8. 图像视频滤镜算法---颜色滤镜

    承接上一篇滤镜初识,本文将介绍第一种滤镜:颜色滤镜. 颜色滤镜 颜色滤镜即调色滤镜,也是最常见的滤镜,任何通过调节图像像素值的亮度.对比度.饱和度.色相等等方法,得到的不同于原图像颜色的效果,都统称为 ...

  9. Android-Q颜色矩阵

    0 前言 颜色反转[2].夜间模式[3].显示白平衡[4].色彩校正[5].模拟颜色空间[6].强调色[7].护眼模式[8].色温调节[9]等显示效果都是通过颜色矩阵实现的,因此本文重点对其进行分析. ...

最新文章

  1. 小程序海外也能做吗?小程序海外主体公司开发的案例
  2. 「Jupyter」ubuntu下安装jupyterlab后jupyterlab:未找到命令
  3. chrome开发总结(交互/权限/存储)-爬虫
  4. 【转】线段树题目 汇总 讲解(by not only success)
  5. 快速附加没有日志文件的 SQL Server 数据库文件!
  6. 数字基带传输学习笔记00引言
  7. python cursor游标_python tuble、lambda及cursor游标相关
  8. 对“才鸟”——动态显示扩展数据的改写
  9. 原生Android开发自学过程(二)之TextView基础属性
  10. 【自监督】何凯明新作MAE略读
  11. 微服务数据库分库设计解决方案(跨库关联查询、分布式事务处理)
  12. 简单 PS CS6蒙版抠图技巧
  13. 数字电路基础:如何提高电路工作频率
  14. 项目部署到服务器显示 网页无法访问500 错误的解决办法
  15. CUDA进阶资料专题(一)pinned memory 和 unified memory
  16. 基于android手机实时监控ipcam视频之一:RTSP
  17. 镜像电流源特点_镜像电流源原理及其应用电路.pdf
  18. 我看技术人的成长路径
  19. 名帖82 苏轼 行楷《前赤壁赋诗卷》
  20. centos6/7 vault源使用

热门文章

  1. 【JavaScript框架封装】公共框架的封装
  2. 我的 Atom 插件,有图
  3. javascript—事件冒泡
  4. 前端工程化工具Fekit分析
  5. HTML5 body设置全屏背景图片 如何让body的背景图片自适应整个屏----实战经验
  6. 为什么要继承Serializable类?
  7. IDEA里运行代码时出现Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger的解决办法(图文详解)...
  8. 十分钟了解分布式计算:GraphX
  9. 用户界面线程AfxBeginThread的使用
  10. 成都2018年GDP超1.5万亿元 比上年增长8.0%