你搞个Timer,在里面处理图形变换使图形抖动,然后能过设置可能调参数(0---100)改变Interval 的值就可以了吧。
解决方案 »
- 怎样更改EXE的主图标?
- 第一次开贴,就是散分,大家来接过个好年吧!呵呵
- delphi 2005 eco的问题
- 非常菜的问题,用最短的时间判断字符串......
- 高分求教:如何将pardox表导出为access表,和将access导入为pardox?
- 有没有人知道Winapi函数实现的代码啊,举个例子啊!
- 有谁做过一个软件的试用期?
- 如何屏蔽MDI子窗体在主窗体菜单栏上的三个系统按钮(最小化,最大化 。。)!
- 倾其所有!
- 请问如何调用页面设置并将其结果留待Tprintdialog.execute中使用。
- DBGrid 中有没有哪个属性可以知道DBGrid中有多少 列 的字段?
- 怎么做IE网页的链接的拖放窗口?
----------------------------------------------------------
procedure FSDither(Source, Dest: TBitmap);
type
TRgb = packed record
Blue: Byte;
Green: Byte;
Red: Byte;
Filler: Byte;
end; TIntegerArray = array[0..(MaxLongInt div 4) - 1] of Integer;
TpIntegerArray = ^TIntegerArray;var
RErr1: TpIntegerArray; { red errors }
RErr2: TpIntegerArray;
GErr1: TpIntegerArray; { green errors }
GErr2: TpIntegerArray;
BErr1: TpIntegerArray; { blue errors }
BErr2: TpIntegerArray; function RGB2Color(RGB: TRGB): TColor;
begin
with rgb do
begin
Result := Blue shl 16 or
Green shl 8 or
Red;
end; // with
end;function BoundInteger(const Value: LongInt;
const MinValue: LongInt;
const MaxValue: LongInt): LongInt;
begin
Result := Value; if Result < MinValue then
Result := MinValue; if Result > MaxValue then
Result := MaxValue;
end;function color2rgb(color: TColor): TRGB;
begin
with result do
begin
Red := Color and $FF;
Green := (Color and $FF00) shr 8;
Blue := (Color and $FF0000) shr 16;
end;
end; procedure AllocateErrors;
var
Size: LongInt;
begin
Size := Source.Width * SizeOf(Integer);
GetMem(RErr1, Size);
GetMem(RErr2, Size);
GetMem(GErr1, Size);
GetMem(GErr2, Size);
GetMem(BErr1, Size);
GetMem(BErr2, Size); FillChar(RErr1^, Size, 0);
FillChar(RErr2^, Size, 0);
FillChar(GErr1^, Size, 0);
FillChar(GErr2^, Size, 0);
FillChar(BErr1^, Size, 0);
FillChar(BErr2^, Size, 0);
end; procedure ReleaseErrors;
var
Size: LongInt;
begin
Size := Source.Width * SizeOf(Integer);
FreeMem(RErr1, Size);
FreeMem(RErr2, Size);
FreeMem(GErr1, Size);
FreeMem(GErr2, Size);
FreeMem(BErr1, Size);
FreeMem(BErr2, Size);
end; procedure DitherScanLine(const LineNo: LongInt);
var
X: LongInt;
Rgb: TRgb;
RErr: Integer;
GErr: Integer;
BErr: Integer;
begin
for X := 0 to (Source.Width - 1) do
begin
Rgb := color2rgb(Source.Canvas.Pixels[X, LineNo]); RErr1^[X] := BoundInteger(RErr2^[X] + Rgb.Red, 0, 255);
RErr2^[X] := 0;
GErr1^[X] := BoundInteger(GErr2^[X] + Rgb.Green, 0, 255);
GErr2^[X] := 0;
BErr1^[X] := BoundInteger(BErr2^[X] + Rgb.Blue, 0, 255);
BErr2^[X] := 0;
end; Rgb.Red := RErr1^[0];
Rgb.Green := GErr1^[0];
Rgb.Blue := BErr1^[0];
Dest.Canvas.Pixels[0, LineNo] := Rgb2color(Rgb); for X := 1 to (Source.Width - 2) do
begin
Rgb.Red := RErr1^[X];
Rgb.Green := GErr1^[X];
Rgb.Blue := BErr1^[X]; { Using the Rgb property will perform the Color matching }
Dest.Canvas.Pixels[X, LineNo] := RGB2Color(Rgb); { get the actual Rgb value after Color matching to compute
the error }
Rgb := color2rgb(Dest.Canvas.Pixels[X, LineNo]); { compute errors }
RErr := RErr1^[X];
RErr := RErr - Rgb.Red; GErr := GErr1^[X];
GErr := GErr - Rgb.Green; BErr := BErr1^[X];
BErr := BErr - Rgb.Blue; RErr1^[X + 1] := BoundInteger((RErr1^[X + 1] + ((RErr * 7)) div 16), 0, 255);
RErr2^[X - 1] := BoundInteger((RErr2^[X - 1] + ((RErr * 3)) div 16), 0, 255);
RErr2^[X] := BoundInteger((RErr2^[X] + ((RErr * 5)) div 16), 0, 255);
RErr2^[X + 1] := BoundInteger((RErr2^[X + 1] + ((RErr * 1)) div 16), 0, 255); GErr1^[X + 1] := BoundInteger((GErr1^[X + 1] + ((GErr * 7)) div 16), 0, 255);
GErr2^[X - 1] := BoundInteger((GErr2^[X - 1] + ((GErr * 3)) div 16), 0, 255);
GErr2^[X] := BoundInteger((GErr2^[X] + ((GErr * 5)) div 16), 0, 255);
GErr2^[X + 1] := BoundInteger((GErr2^[X + 1] + ((GErr * 1)) div 16), 0, 255); BErr1^[X + 1] := BoundInteger((BErr1^[X + 1] + ((BErr * 7)) div 16), 0, 255);
BErr2^[X - 1] := BoundInteger((BErr2^[X - 1] + ((BErr * 3)) div 16), 0, 255);
BErr2^[X] := BoundInteger((BErr2^[X] + ((BErr * 5)) div 16), 0, 255);
BErr2^[X + 1] := BoundInteger((BErr2^[X + 1] + ((BErr * 1)) div 16), 0, 255);
end; Rgb.Red := RErr1^[Source.Width - 1];
Rgb.Green := GErr1^[Source.Width - 1];
Rgb.Blue := BErr1^[Source.Width - 1]; Dest.Canvas.Pixels[Source.Width - 1, LineNo] := RGB2Color(Rgb);
end;var
Y: LongInt;
HeightMinusOne: LongInt;
begin
AllocateErrors;
try
HeightMinusOne := Source.Height - 1;
for Y := 0 to HeightMinusOne do
begin
DitherScanLine(Y);
end;
finally
ReleaseErrors;
end;
end;
{-------------------fd---------------------}
用法:
var tmp: TBitmap;
begin
tmp := TBitmap.Create;
try
tmp.Width := Bitmap.Width;
tmp.Height := Bitmap.Height;
tmp.pixelformat := pf8bit; //256色
FSDither(Bitmap, tmp);//Bitmap是真彩色图像
image1.picture.Bitmap.Assign(tmp);
end;
finally
tmp.Free;
end;-------------------------------------------------------但是我现在要的是可调整(0-100, 0表示不抖动)的抖动算法,不管是什么类型的Understand?
灰度计算公式:
Gray := (R*30 + G*59 + B*11) Div 256;
然后计算概率:
P := Random(Gray+1);
确定画点:
If P=0 Then Canvas.Pixels[X, Y] := clBlack Else Canvas.Pixels[X,Y] := clWhite;
抖动并不是黑白的,是有颜色的,你没有看过PHOTOSHOP中的那个吗?
Firework MX中也有
你这鸟人,把我一年前写给别人做二值误差分散抖动的帖子翻出来,什么意思?你连我的代码是什么类型的抖动都没看懂,就一子不改的帖出来,你要不要脸啊?
说明:这里说的抖动一般称为误差扩散抖动。
说的没错,灰度和RGB是一个样,
问题是你那一块是一色的,好办,
如果是一缕头发,
你还怎么抖??
所以楼主的想法只用一个抖动,实现起来不好弄呀