//Produces the Image (with hair color etc...)
procedure TCharacter.ProduceImage;
var x,y:integer;
abmp:TBitmap;
col,ncol:TColor;
r,g,b:byte;
//Makes a color daker
function DarkColor(acolor:TColor;value:integer):TColor;
var r,g,b:byte;
begin
r := cut(getrvalue(acolor)-value);
g := cut(getgvalue(acolor)-value);
b := cut(getbvalue(acolor)-value);
result :=
rgb(r,g,b);
end;
begin
//Create Bitmap
abmp := TBitmap.Create;
abmp.PixelFormat := pf24Bit;
//Get the Oringinals Bitmap (TFigurImage)
original.GetAsBitmap(abmp);
{ TODO -oAll -cCode : Scanline }
for x := 0
to abmp.Width-1
do
begin
for y := 0
to abmp.Height-1
do
begin
col := abmp.Canvas.Pixels[x,y];
r := getrvalue(col);
g := getgvalue(col);
b := getbvalue(col);
//Skin color. In the originals Bitmap the skin colors RGB Values are all the same --> gray/white
if (r=g)
and (r=b)
then
begin
ncol := darkcolor(skincolor,255-r);
abmp.Canvas.Pixels[x,y] := ncol;
end;
//Cloths color. In the originals Bitmap the clothes color is red (GB are not set)
if (g=0)
and (b=0)
then
begin
ncol := darkcolor(clothescolor,255-r);
abmp.Canvas.Pixels[x,y] := ncol;
end;
//Hair color. In the originals Bitmap the clothes color is yellow (B is not set) R and B is the same.
if (b=0)
and (r=g)
then
begin
ncol := darkcolor(haircolor,255-r);
abmp.Canvas.Pixels[x,y] := ncol;
end;
end;
end;
//Assing the new bitmap to the buffer
figurimage.Assign(abmp);
figurimage.transparentcolor := clFuchsia;
figurimage.transparent := true;
//Free all things
abmp.Free;
end;