procedure
TForm1
.
save1Click(Sender: TObject);
procedure
ImageGradient(bitmap: tbitmap; p:
boolean
);
type
TRGB =
record
r:
byte
;
g:
byte
;
b:
byte
;
end
;
ARGB =
array
[
0..1
]
of
TRGB;
PARGB = ^ARGB;
var
pb, ps: PARGB;
x,y,b:
integer
;
function
Min(a, b:
Longint
):
Longint
;
begin
if
a > b
then
Result := b
else
Result := a;
end
;
function
convertByte(BaseColor: TColor; i:
integer
): TColor;
begin
if
p=
true
then
b:=Y
else
b:=x;
Result := RGB(Min(GetRValue(ColorToRGB(BaseColor)) + round((
255
)*b/bitmap
.
Height),
255
),
Min(GetGValue(ColorToRGB(BaseColor))+ round(
255
*b/bitmap
.
Height),
255
),
Min(GetBValue(ColorToRGB(BaseColor))+ round(
255
*b/bitmap
.
Height),
255
));
end
;
begin
bitmap
.
Assign(bitmap);
bitmap
.
PixelFormat:=pf24bit;
for
y:=
0
to
bitmap
.
Height-
1
do
begin
pb:=bitmap
.
scanline[y];
ps:=bitmap
.
scanline[y];
for
x:=
0
to
bitmap
.
Width-
1
do
begin
ps[x].r:=convertByte(pb[x].r,x);
ps[x].g:=convertByte(pb[x].g,x);
ps[x].b:=convertByte(pb[x].b,x)
end
;
end
;
end
;
begin
ImageGradient(Image1
.
Picture
.
Bitmap,
false
);
end
;