Thema: Delphi High Color --> TrueColor

Einzelnen Beitrag anzeigen

shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#7

Re: High Color --> TrueColor

  Alt 19. Feb 2008, 15:47
Zitat von Neutral General:
Wenn RRRRR = 11111 dann wäre der Rot-Farbanteil 100%. 31/31
RRRRR000 11111000. das wäre 248/255 (97,25%)
Ja, das stimmt natürlich.
Man könnte aber 2 Lookuptabellen mit 64 und mit 32 Byte bereithalten und sich damit die Multiplikation und Division sparen.
Delphi-Quellcode:

function HighColorToTrueColor(AColor: Word): TRGBQuad;
const LU_rot_blau:array[0..31] of Byte = (0,8,16,25,33,41,49,58,66,74,82,90,99,107,
115,123,132,140,148,156,165,173,181,
189,197,206,214,222,230,239,247,255);
const LU_gruen:array[0..63] of Byte =
(0,4,8,12,16,20,24,28,32,36,40,45,49,53,57,61,65,69,73,77,81,85,89,93,97,
101,105,109,113,117,121,125,130,134,138,142,146,150,
154,158,162,166,170,174,178,182,186,190,194,198,202,
206,210,215,219,223,227,231,235,239,243,247,251,255);
begin
  Result.rgbRed := LU_rot_blau[(AColor and $F800) shr 11];
  Result.rgbGreen := LU_gruen[(AColor and $07E0) shr 5];
  Result.rgbBlue := LU_rot_blau[(AColor and $001F)];
end;
Andreas
  Mit Zitat antworten Zitat