关于图像亮度/对比度/饱和度?(300分)

  • 主题发起人 主题发起人 cAkk
  • 开始时间 开始时间
Big_Z:这个算法是不是太慢?

o*o: 我是过不行呀! 我用的是windows目录下面的"安装程序.bmp"
 
用 ScanLine 可以快很多!!!
 
是呀,但是为什么我用scanline会出错?
 
我用"安装程序.bmp"试了一下,仍然可以。
不知你哪儿出了问题。:-(

var bmp:TBitmap;
begin
bmp:=TBitmap.create;
image1.Picture.Bitmap.PixelFormat:=pf24bit;
bmp:=Image1.picture.bitmap;
Saturation(bmp,500);
end;
 
>那就 Bitmap.PixelFormat:=pf24Bit;
>就可以用这几个函数处理了。
o*o 是对的。
我看了其他一些 Libs ,
他们在使用 ScanLine 之前,
先确保
Bitmap.PixelFormat:=pf24Bit;

cAkk:你在每一个使用 ScanLine 的过程或函数前面
加上这样一句,应该是可以的。

 
请帮我测试这个程序,在窗口上放一个image和一个按钮, image调入
c:/windows/安装程序.bmp

unit Unit1;

interface

uses
Classes, Graphics, Controls, Forms, StdCtrls, ExtCtrls ;

type
TRGBcolor=packed record
R,G,B:integer;
end;
PRGBColor = ^TRGBcolor;

TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation

{$R *.DFM}
procedure Bitmap_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.R := Byte(I + R);
ColorTable.G := Byte(I + G);
ColorTable.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;
Inc(pRGB);
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var bmp:tbitmap;
begin
bmp:=tbitmap.create;
bmp.PixelFormat:=pf24bit;
bmp.width:=image1.width;
bmp.height:=image1.height;
try
bmp.Canvas.Draw(0,0,image1.picture.bitmap);
Bitmap_RGB(bmp, 10,10,100);
image1.Canvas.draw(0,0,bmp);
finally
bmp.free;
end;
end;
end.

我无论怎么做也通不过!!!
 
type
<Font Color=#FF0000> TRGBcolor= record
R,G,B:Byte;</Font>
end;
 
哎呀呀! 我真糊涂! 的确应该是byte,我不知什么时候抄成了integer!!!!!

现在程序不会出错了,但是最后结果好像不对?
 
终于搞定了. 我发现xWolf的代码效果不太好,不知道为什么.
我后来借鉴FastBMP的方法,取得了非常好的图像效果.其实两种方法
原理是一样的,但是FastBMP的效果就是要好一些,真奇怪!
 
cAkk:
您好,能把您做的关于图象色彩调节的代码给我参考一下吗,我现在也着急写这样的
一个程序用,谢谢您了!
 

Similar threads

回复
0
查看
1K
不得闲
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部