在Delphi中的help-example-jpeg中有
解决方案 »
- 哪个版本的EHlib里有dbGrideh1.linecolor,dbGrideh1.Selectedcolor
- dbgrideh是ehlib里的控件,如何改变选中行的颜色?
- 怎样得到一个 jpg图片的大小??
- 事物回滾后﹐界面如何回到事物開始前的界面
- 保存jpg文件的问题,在线等候!
- 这里的人们怎么这么不热情!我的贴子怎么就没人来看看
- database控件的问题?????
- 我正在做一个c/s的系统,现在已经接近尾声,我想做一个帮助,就想windows自带的哪个
- 请问如何让form有更多的颜色?
- 我在使用DELPHI数据库时错误!
- 一个难题,救救我...
- 定义自己的组件编辑器,TComponentEditor的哪些方法必须覆盖?回答全面一些,举例不给分
的每一象素是以三原色RGB的次序存放的,改变RGB的值就可调节Bitmap的色彩.
// R, G, B: -255~255
procedure RGB(var Bmp: TBitmap; R, G, B: Integer);
var
X, Y: Integer;
I: Byte;
ColorTable: array[0..255] of TRGBColor;
pRGB: PRGBColor;
begin
for I := 0 to 255 do
begin
ColorTable[I].R := Byte(I + R);
ColorTable[I].G := Byte(I + G);
ColorTable[I].B := Byte(I + B);
end; for Y := 0 to Bmp.Height - 1 do
begin
pRGB := Bmp.ScanLine[Y];
for X := 0 to Bmp.Width - 1 do
begin
pRGB.R := ColorTable[pRGB.R].R;
pRGB.G := ColorTable[pRGB.G].G;
pRGB.B := ColorTable[pRGB.B].B;
end;
Inc(pRGB);
end;
end; // 改变图像的亮度,也只需调用RGB(Bmp, X, X, X)改变三原色.
// 调节Bitmap的对比度
// 应用公式: 新颜色值 = (旧颜色值 - 128) * 系数 + 128
procedure Contrast(var Bmp: TBitmap; Amount: Integer);
// Amount: -255~255
var
X, Y: Integer;
I: Byte;
ColorTable: array[0..255] of TRGBColor;
pRGB: PRGBColor;
begin
for I := 0 to 126 do
begin
Y := (Abs(128 - I) * Amount) div 256;
ColorTable[I].r := GetRValue(Byte(I - Y));
ColorTable[I].g := GetGValue(Byte(I - Y));
ColorTable[I].b := GetBValue(Byte(I - Y));
end;
for I := 127 to 255 do
begin
Y := (Abs(128 - I) * Amount) div 256;
ColorTable[I].r := GetRValue(Byte(I + Y));
ColorTable[I].g := GetGValue(Byte(I + Y));
ColorTable[I].b := GetBValue(Byte(I + Y));
end;
for Y := 0 to Bmp.Height - 1 do
begin
pRGB := Bmp.ScanLine[Y];
for X := 0 to Bmp.Width - 1 do
begin
pRGB.R := ColorTable[pRGB.R].R;
pRGB.G := ColorTable[pRGB.G].G;
pRGB.B := ColorTable[pRGB.B].B;
Inc(pRGB);
end;
end;
end; // 改变饱和度
procedure Saturation(var Bmp: TBitmap; Amount: Integer); // Amount: 0~510
var
Grays: array[0..767] of Integer;
Alpha: array[0..255] of Word;
Gray, X, Y: Integer;
pRGB: PRGBColor;
I: Byte;
begin
for I := 0 to 255 do Alpha[I] := (I * Amount) shr 8;
x := 0;
for I := 0 to 255 do
begin
Gray := I - Alpha[I];
Grays[X] := Gray; Inc(X);
Grays[X] := Gray; Inc(X);
Grays[X] := Gray; Inc(X);
end;
for Y := 0 to Bmp.Height - 1 do
begin
pRGB := Bmp.ScanLine[Y];
for X := 0 to Bmp.Width - 1 do
begin
Gray := Grays[pRGB.R + pRGB.G + pRGB.B];
pRGB.R := Byte(Gray + Alpha[pRGB.R]);
pRGB.G := Byte(Gray + Alpha[pRGB.G]);
pRGB.B := Byte(Gray + Alpha[pRGB.B]);
Inc(pRGB);
end;
end;
end;