added skipping non-hex characters in color-data - allows users to paste parameters with line breaks (from emails, etc)

This commit is contained in:
zueuk 2006-01-07 17:53:47 +00:00
parent da82735e8a
commit 023b72b70f

View File

@ -3942,7 +3942,7 @@ begin
end;
end;
procedure ParseCompactcolors(cp: TControlPoint; count: integer; data: string);
procedure ParseCompactcolors(cp: TControlPoint; count: integer; in_data: string);
function HexChar(c: Char): Byte;
begin
case c of
@ -3955,13 +3955,21 @@ procedure ParseCompactcolors(cp: TControlPoint; count: integer; data: string);
end;
var
i: integer;
c: char;
data: string;
begin
// diable generating pallete
if Parsecp.cmapindex = -2 then
Parsecp.cmapindex := -1;
Assert(Count = 256,'only 256 color Colormaps are supported at the moment');
Assert((Count * 8) = Length(data),'Data size MisMatch');
Assert(Count = 256, 'only 256 color Colormaps are supported at the moment');
data := '';
for i := 0 to Length(in_data) do
begin
c := in_data[i];
if c in ['0'..'9']+['A'..'F']+['a'..'f'] then data := data + c;
end;
Assert((Count * 8) = Length(data), 'Color-data size mismatch');
for i := 0 to Count -1 do begin
Parsecp.cmap[i][0] := 16 * HexChar(Data[i*8 + 3]) + HexChar(Data[i*8 + 4]);
Parsecp.cmap[i][1] := 16 * HexChar(Data[i*8 + 5]) + HexChar(Data[i*8 + 6]);