Ignore:
Timestamp:
Apr 17, 2019, 12:58:41 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Propagate project build mode options to used packages.
  • Added: Check memory leaks using heaptrc.
  • Modified: Update BGRABitmap package.
Location:
GraphicTest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest

    • Property svn:ignore
      •  

        old new  
        88GraphicTest.lps
        99GraphicTest.dbg
         10heaptrclog.trc
  • GraphicTest/Packages/bgrabitmap/basiccolorspace.inc

    r494 r521  
    1313
    1414  // TExpandedPixel -> TBGRAPixel
    15   GammaCompressionTab: packed array[0..65535] of byte;
     15  GammaCompressionTab : packed array[0..65535] of byte;          //rounded value
     16  GammaCompressionTabFrac : packed array[0..65535] of shortint;  //fractional part of value from -0.5 to +0.5
    1617
    1718procedure BGRASetGamma(AGamma: single = 1.7);
     
    4243  {** Returns the lightness of an gamma-expanded pixel. The lightness is the
    4344     perceived brightness, 0 being black and 65535 being white }
    44   function GetLightness(const c: TExpandedPixel): word; inline;
     45  function GetLightness(const c: TExpandedPixel): word; inline; overload;
    4546  {** Sets the lightness of a gamma-expanded pixel }
    46   function SetLightness(const c: TExpandedPixel; lightness: word): TExpandedPixel;
     47  function SetLightness(const c: TExpandedPixel; lightness: word): TExpandedPixel; overload;
    4748  {** Sets the lightness of a gamma expanded pixel, provided you already know the current
    4849     value of lightness ''curLightness''. It is a bit faster than the previous function }
    49   function SetLightness(const c: TExpandedPixel; lightness: word; curLightness: word): TExpandedPixel;
     50  function SetLightness(const c: TExpandedPixel; lightness: word; curLightness: word): TExpandedPixel; overload;
    5051  {** Returns the importance of the color. It is similar to saturation
    5152      in HSL colorspace, except it is gamma corrected. A value of zero indicates
     
    8889    {** Hue of the pixel. Extremum values 0 and 65535 are red }
    8990    hue: word;
    90     {** Saturation of the color. 0 is gray and 65535 is the brightest color }
     91    {** Saturation of the color. 0 is gray and 65535 is the brightest color (including white) }
    9192    saturation: word;
    9293    {** Lightness of the color. 0 is black, 32768 is normal, and 65535 is white }
     
    116117  {* Pixel color defined in corrected HSL colorspace. G stands for corrected hue
    117118     and B stands for actual brightness. Values range from 0 to 65535 }
    118   TGSBAPixel = THSLAPixel;
     119  TGSBAPixel = packed record
     120    {** Hue of the pixel. Extremum values 0 and 65535 are red }
     121    hue: word;
     122    {** Saturation of the color. 0 is gray and 65535 is the brightest color (excluding white) }
     123    saturation: word;
     124    {** Actual perceived brightness. 0 is black, 32768 is normal, and 65535 is white }
     125    lightness: word;
     126    {** Opacity of the pixel. 0 is transparent and 65535 is opaque }
     127    alpha: word;
     128  end;
    119129
    120130  {** Converts a pixel from sRGB to correct HSL color space }
     
    127137  function HtoG(hue: word): word;
    128138  {** Converts a pixel from corrected HSL to sRGB }
    129   function GSBAToBGRA(c: TGSBAPixel): TBGRAPixel;
     139  function GSBAToBGRA(c: TGSBAPixel): TBGRAPixel; overload;
     140  function GSBAToBGRA(const c: THSLAPixel): TBGRAPixel; overload;
    130141  {** Converts a pixel from correct HSL to gamma expanded RGB }
    131   function GSBAToExpanded(c: TGSBAPixel): TExpandedPixel;
     142  function GSBAToExpanded(c: TGSBAPixel): TExpandedPixel; overload;
     143  function GSBAToExpanded(const c: THSLAPixel): TExpandedPixel; overload;
    132144  {** Converts a pixel from correct HSL to usual HSL }
    133   function GSBAToHSLA(c: TGSBAPixel): THSLAPixel;
     145  function GSBAToHSLA(const c: TGSBAPixel): THSLAPixel; overload;
     146  function GSBAToHSLA(const c: THSLAPixel): THSLAPixel; overload;
     147  function HSLAToGSBA(const c: THSLAPixel): TGSBAPixel;
    134148
    135149type
    136   { TBGRAPixelHelper }
    137 
    138   TBGRAPixelHelper = record helper for TBGRAPixel
     150  { TBGRAPixelBasicHelper }
     151
     152  TBGRAPixelBasicHelper = record helper for TBGRAPixel
    139153    function ToExpanded: TExpandedPixel;
    140154    procedure FromExpanded(const AValue: TExpandedPixel);
     
    142156    procedure FromHSLAPixel(const AValue: THSLAPixel);
    143157    function ToGSBAPixel: TGSBAPixel;
    144     procedure FromGSBAPixel(const AValue: TGSBAPixel);
     158    procedure FromGSBAPixel(const AValue: TGSBAPixel); overload;
     159    procedure FromGSBAPixel(const AValue: THSLAPixel); overload;
    145160    function ToColorF(AGammaExpansion: boolean): TColorF;
    146161    procedure FromColorF(const AValue: TColorF; AGammaCompression: boolean);
    147162  end;
    148163
    149   { TExpandedPixelHelper }
    150 
    151   TExpandedPixelHelper = record helper for TExpandedPixel
     164  { TExpandedPixelBasicHelper }
     165
     166  TExpandedPixelBasicHelper = record helper for TExpandedPixel
     167    function ToFPColor(AGammaCompression: boolean = true): TFPColor;
     168    procedure FromFPColor(const AValue: TFPColor; AGammaExpansion: boolean = true);
     169    function ToColor: TColor;
     170    procedure FromColor(const AValue: TColor);
     171    function ToBGRAPixel: TBGRAPixel;
     172    procedure FromBGRAPixel(AValue: TBGRAPixel);
     173    function ToHSLAPixel: THSLAPixel;
     174    procedure FromHSLAPixel(const AValue: THSLAPixel);
     175    function ToGSBAPixel: TGSBAPixel;
     176    procedure FromGSBAPixel(const AValue: TGSBAPixel); overload;
     177    procedure FromGSBAPixel(const AValue: THSLAPixel); overload;
     178  end;
     179
     180operator := (const AValue: TExpandedPixel): TColor;
     181operator := (const AValue: TColor): TExpandedPixel;
     182Operator := (const Source: TExpandedPixel): TBGRAPixel;
     183Operator := (const Source: TBGRAPixel): TExpandedPixel;
     184
     185type
     186  { TFPColorBasicHelper }
     187
     188  TFPColorBasicHelper = record helper for TFPColor
     189    function ToColor: TColor;
     190    procedure FromColor(const AValue: TColor);
     191    function ToBGRAPixel: TBGRAPixel;
     192    procedure FromBGRAPixel(AValue: TBGRAPixel);
     193    function ToExpanded(AGammaExpansion: boolean = true): TExpandedPixel;
     194    procedure FromExpanded(const AValue: TExpandedPixel; AGammaCompression: boolean = true);
     195  end;
     196
     197  { THSLAPixelBasicHelper }
     198
     199  THSLAPixelBasicHelper = record helper for THSLAPixel
     200    function ToColor: TColor;
     201    procedure FromColor(const AValue: TColor);
     202    function ToBGRAPixel: TBGRAPixel;
     203    procedure FromBGRAPixel(AValue: TBGRAPixel);
     204    function ToGSBAPixel: TGSBAPixel;
     205    procedure FromGSBAPixel(AValue: TGSBAPixel);
     206    function ToExpanded: TExpandedPixel;
     207    procedure FromExpanded(AValue: TExpandedPixel);
     208  end;
     209
     210Operator := (const Source: THSLAPixel): TBGRAPixel;
     211Operator := (const Source: TBGRAPixel): THSLAPixel;
     212Operator := (const Source: THSLAPixel): TExpandedPixel;
     213Operator := (const Source: TExpandedPixel): THSLAPixel;
     214operator := (const AValue: TColor): THSLAPixel;
     215operator := (const AValue: THSLAPixel): TColor;
     216
     217type
     218  { TGSBAPixelBasicHelper }
     219
     220  TGSBAPixelBasicHelper = record helper for TGSBAPixel
     221    function ToColor: TColor;
     222    procedure FromColor(const AValue: TColor);
    152223    function ToBGRAPixel: TBGRAPixel;
    153224    procedure FromBGRAPixel(AValue: TBGRAPixel);
    154225    function ToHSLAPixel: THSLAPixel;
    155226    procedure FromHSLAPixel(AValue: THSLAPixel);
    156   end;
    157 
    158   { THSLAPixelHelper }
    159 
    160   THSLAPixelHelper = record helper for THSLAPixel
    161     function ToBGRAPixel: TBGRAPixel;
    162     procedure FromBGRAPixel(AValue: TBGRAPixel);
    163227    function ToExpanded: TExpandedPixel;
    164228    procedure FromExpanded(AValue: TExpandedPixel);
    165229  end;
    166230
    167 Operator := (Source: TExpandedPixel): TBGRAPixel;
     231Operator := (const Source: TGSBAPixel): TBGRAPixel;
     232Operator := (const Source: TBGRAPixel): TGSBAPixel;
     233Operator := (const Source: TGSBAPixel): TExpandedPixel;
     234Operator := (const Source: TExpandedPixel): TGSBAPixel;
     235operator := (const AValue: TColor): TGSBAPixel;
     236operator := (const AValue: TGSBAPixel): TColor;
     237Operator := (const Source: TGSBAPixel): THSLAPixel; //no conversion, just copying for backward compatibility (use ToHSLAPixel instead for conversion)
     238Operator := (const Source: THSLAPixel): TGSBAPixel; //no conversion, just copying for backward compatibility (use ToGSBAPixel instead for conversion)
    168239{$ENDIF}
    169240
     
    317388      nextpos := round(power(i+0.5, GammaExpFactor) * GammaLinearFactor);
    318389    GammaExpansionTab[i] := midpos;
    319     for j := prevpos to nextpos-1 do
     390    for j := prevpos to midpos-1 do
     391    begin
    320392      GammaCompressionTab[j] := i;
     393      GammaCompressionTabFrac[j] := -128 + (j-prevpos)*128 div (midpos-prevpos);
     394    end;
     395    for j := midpos to nextpos-1 do
     396    begin
     397      GammaCompressionTab[j] := i;
     398      GammaCompressionTabFrac[j] := (j-midpos)*128 div (nextpos-midpos);
     399    end;
    321400  end;
    322401  GammaCompressionTab[0] := 0;
     
    358437  Result.blue  := GammaCompressionTab[blue];
    359438  Result.alpha := alpha shr 8;
     439end;
     440
     441function GammaExpansionW(ACompressed: word): word;
     442var
     443  intPart: Integer;
     444  f,fracPart: Single;
     445begin
     446  if ACompressed = 0 then
     447    result := 0
     448  else if ACompressed = $ffff then
     449    result := $ffff
     450  else
     451  begin
     452    f := ACompressed/$101;
     453    intPart := trunc(f);
     454    fracPart := f - intPart;
     455    if fracPart = 0 then
     456      result := GammaExpansionTab[intPart]
     457    else
     458      result := round(GammaExpansionTab[intPart]*(1-fracPart)+GammaExpansionTab[intPart+1]*fracPart);
     459  end;
     460end;
     461
     462function GammaCompressionW(AExpanded: word): word;
     463begin
     464  if AExpanded = 0 then
     465    result := 0
     466  else if AExpanded = $ffff then
     467    result := $ffff
     468  else
     469  begin
     470    result := GammaCompressionTab[AExpanded];
     471    result := (result shl 8) + result;
     472    result += GammaCompressionTabFrac[AExpanded];
     473  end;
    360474end;
    361475
     
    871985var lightness: UInt32Or64;
    872986    red,green,blue: Int32or64;
     987    hsla: THSLAPixel;
    873988begin
    874989  red   := GammaExpansionTab[c.red];
    875990  green := GammaExpansionTab[c.green];
    876991  blue  := GammaExpansionTab[c.blue];
    877   result.alpha := c.alpha shl 8 + c.alpha;
     992  hsla.alpha := c.alpha shl 8 + c.alpha;
    878993
    879994  lightness := (red * redWeightShl10 + green * greenWeightShl10 +
    880995    blue * blueWeightShl10 + 512) shr 10;
    881996
    882   ExpandedToHSLAInline(red,green,blue,result);
     997  ExpandedToHSLAInline(red,green,blue,hsla);
     998  result := TGSBAPixel(hsla);
     999
    8831000  if result.lightness > 32768 then
    8841001    result.saturation := result.saturation* UInt32or64(not result.lightness) div 32767;
     
    8901007var lightness: UInt32Or64;
    8911008    red,green,blue: Int32or64;
     1009    hsla: THSLAPixel;
    8921010begin
    8931011  red   := ec.red;
    8941012  green := ec.green;
    8951013  blue  := ec.blue;
    896   result.alpha := ec.alpha;
     1014  hsla.alpha := ec.alpha;
    8971015
    8981016  lightness := (red * redWeightShl10 + green * greenWeightShl10 +
    8991017    blue * blueWeightShl10 + 512) shr 10;
    9001018
    901   ExpandedToHSLAInline(red,green,blue,result);
     1019  ExpandedToHSLAInline(red,green,blue,hsla);
     1020  result := TGSBAPixel(hsla);
     1021
    9021022  if result.lightness > 32768 then
    9031023    result.saturation := result.saturation* UInt32or64(not result.lightness) div 32767;
     
    10021122  lightness := c.lightness;
    10031123  c.lightness := 32768;
    1004   ec := HSLAToExpanded(c);
     1124  ec := HSLAToExpanded(THSLAPixel(c));
    10051125  result := GammaCompression(SetLightness(ec, lightness));
     1126end;
     1127
     1128function GSBAToBGRA(const c: THSLAPixel): TBGRAPixel;
     1129begin
     1130  result := GSBAToBGRA(TGSBAPixel(c));
    10061131end;
    10071132
     
    10121137  lightness := c.lightness;
    10131138  c.lightness := 32768;
    1014   result := SetLightness(HSLAToExpanded(c),lightness);
    1015 end;
    1016 
    1017 function GSBAToHSLA(c: TGSBAPixel): THSLAPixel;
    1018 begin
    1019   result := BGRAToHSLA(GSBAToBGRA(c));
    1020 end;
    1021 
    1022 { TBGRAPixelHelper }
    1023 
    1024 function TBGRAPixelHelper.ToExpanded: TExpandedPixel;
     1139  result := SetLightness(HSLAToExpanded(THSLAPixel(c)),lightness);
     1140end;
     1141
     1142function GSBAToExpanded(const c: THSLAPixel): TExpandedPixel;
     1143begin
     1144  result := GSBAToExpanded(TGSBAPixel(c));
     1145end;
     1146
     1147function GSBAToHSLA(const c: TGSBAPixel): THSLAPixel;
     1148begin
     1149  result := ExpandedToHSLA(GSBAToExpanded(c));
     1150end;
     1151
     1152function GSBAToHSLA(const c: THSLAPixel): THSLAPixel;
     1153begin
     1154  result := ExpandedToHSLA(GSBAToExpanded(TGSBAPixel(c)));
     1155end;
     1156
     1157function HSLAToGSBA(const c: THSLAPixel): TGSBAPixel;
     1158begin
     1159  result := ExpandedToGSBA(HSLAToExpanded(c));
     1160end;
     1161
     1162{ TBGRAPixelBasicHelper }
     1163
     1164function TBGRAPixelBasicHelper.ToExpanded: TExpandedPixel;
    10251165begin
    10261166  result := GammaExpansion(self);
    10271167end;
    10281168
    1029 procedure TBGRAPixelHelper.FromExpanded(const AValue: TExpandedPixel);
     1169procedure TBGRAPixelBasicHelper.FromExpanded(const AValue: TExpandedPixel);
    10301170begin
    10311171  Self := GammaCompression(AValue);
    10321172end;
    10331173
    1034 function TBGRAPixelHelper.ToHSLAPixel: THSLAPixel;
     1174function TBGRAPixelBasicHelper.ToHSLAPixel: THSLAPixel;
    10351175begin
    10361176  result := BGRAToHSLA(Self);
    10371177end;
    10381178
    1039 procedure TBGRAPixelHelper.FromHSLAPixel(const AValue: THSLAPixel);
     1179procedure TBGRAPixelBasicHelper.FromHSLAPixel(const AValue: THSLAPixel);
    10401180begin
    10411181  Self := HSLAToBGRA(AValue);
    10421182end;
    10431183
    1044 function TBGRAPixelHelper.ToGSBAPixel: TGSBAPixel;
     1184function TBGRAPixelBasicHelper.ToGSBAPixel: TGSBAPixel;
    10451185begin
    10461186  result := BGRAToGSBA(Self);
    10471187end;
    10481188
    1049 procedure TBGRAPixelHelper.FromGSBAPixel(const AValue: TGSBAPixel);
     1189procedure TBGRAPixelBasicHelper.FromGSBAPixel(const AValue: TGSBAPixel);
    10501190begin
    10511191  Self := GSBAToBGRA(AValue);
    10521192end;
    10531193
    1054 function TBGRAPixelHelper.ToColorF(AGammaExpansion: boolean): TColorF;
     1194procedure TBGRAPixelBasicHelper.FromGSBAPixel(const AValue: THSLAPixel);
     1195begin
     1196  Self := GSBAToBGRA(AValue);
     1197end;
     1198
     1199function TBGRAPixelBasicHelper.ToColorF(AGammaExpansion: boolean): TColorF;
    10551200begin
    10561201  result := BGRAToColorF(Self,AGammaExpansion);
    10571202end;
    10581203
    1059 procedure TBGRAPixelHelper.FromColorF(const AValue: TColorF;
     1204procedure TBGRAPixelBasicHelper.FromColorF(const AValue: TColorF;
    10601205    AGammaCompression: boolean);
    10611206begin
     
    10631208end;
    10641209
    1065 { TExpandedPixelHelper }
    1066 
    1067 function TExpandedPixelHelper.ToBGRAPixel: TBGRAPixel;
     1210{ TExpandedPixelBasicHelper }
     1211
     1212function TExpandedPixelBasicHelper.ToFPColor(AGammaCompression: boolean): TFPColor;
     1213begin
     1214  if AGammaCompression then
     1215  begin
     1216    result.red := GammaCompressionW(self.red);
     1217    result.green := GammaCompressionW(self.green);
     1218    result.blue := GammaCompressionW(self.blue);
     1219  end else
     1220  begin
     1221    result.red := self.red;
     1222    result.green := self.green;
     1223    result.blue := self.blue;
     1224  end;
     1225  result.alpha := self.alpha;
     1226end;
     1227
     1228procedure TExpandedPixelBasicHelper.FromFPColor(const AValue: TFPColor;
     1229  AGammaExpansion: boolean);
     1230begin
     1231  if AGammaExpansion then
     1232  begin
     1233    self.red := GammaExpansionW(AValue.red);
     1234    self.green := GammaExpansionW(AValue.green);
     1235    self.blue := GammaExpansionW(AValue.blue);
     1236  end else
     1237  begin
     1238    self.red := AValue.red;
     1239    self.green := AValue.green;
     1240    self.blue := AValue.blue;
     1241  end;
     1242  self.alpha := AValue.alpha;
     1243end;
     1244
     1245function TExpandedPixelBasicHelper.ToColor: TColor;
     1246begin
     1247  result := BGRAToColor(GammaCompression(self));
     1248end;
     1249
     1250procedure TExpandedPixelBasicHelper.FromColor(const AValue: TColor);
     1251begin
     1252  self := GammaExpansion(ColorToBGRA(AValue));
     1253end;
     1254
     1255function TExpandedPixelBasicHelper.ToBGRAPixel: TBGRAPixel;
    10681256begin
    10691257  result := GammaCompression(Self);
    10701258end;
    10711259
    1072 procedure TExpandedPixelHelper.FromBGRAPixel(AValue: TBGRAPixel);
     1260procedure TExpandedPixelBasicHelper.FromBGRAPixel(AValue: TBGRAPixel);
    10731261begin
    10741262  Self := GammaExpansion(AValue);
    10751263end;
    10761264
    1077 function TExpandedPixelHelper.ToHSLAPixel: THSLAPixel;
     1265function TExpandedPixelBasicHelper.ToHSLAPixel: THSLAPixel;
    10781266begin
    10791267  result := ExpandedToHSLA(Self);
    10801268end;
    10811269
    1082 procedure TExpandedPixelHelper.FromHSLAPixel(AValue: THSLAPixel);
     1270procedure TExpandedPixelBasicHelper.FromHSLAPixel(const AValue: THSLAPixel);
    10831271begin
    10841272  Self := HSLAToExpanded(AValue);
    10851273end;
    10861274
    1087 operator :=(Source: TExpandedPixel): TBGRAPixel;
     1275function TExpandedPixelBasicHelper.ToGSBAPixel: TGSBAPixel;
     1276begin
     1277  result := ExpandedToGSBA(Self);
     1278end;
     1279
     1280procedure TExpandedPixelBasicHelper.FromGSBAPixel(const AValue: TGSBAPixel);
     1281begin
     1282  Self := GSBAToExpanded(AValue);
     1283end;
     1284
     1285procedure TExpandedPixelBasicHelper.FromGSBAPixel(const AValue: THSLAPixel);
     1286begin
     1287  Self := GSBAToExpanded(AValue);
     1288end;
     1289
     1290operator := (const AValue: TExpandedPixel): TColor;
     1291begin Result := BGRAToColor(GammaCompression(AValue)); end;
     1292
     1293operator := (const AValue: TColor): TExpandedPixel;
     1294begin Result := GammaExpansion(ColorToBGRA(ColorToRGB(AValue))) end;
     1295
     1296operator :=(const Source: TExpandedPixel): TBGRAPixel;
    10881297begin
    10891298  result := GammaCompression(Source);
    10901299end;
    10911300
    1092 { THSLAPixelHelper }
    1093 
    1094 function THSLAPixelHelper.ToBGRAPixel: TBGRAPixel;
     1301operator :=(const Source: TBGRAPixel): TExpandedPixel;
     1302begin
     1303  result := GammaExpansion(Source);
     1304end;
     1305
     1306{ TFPColorBasicHelper }
     1307
     1308function TFPColorBasicHelper.ToColor: TColor;
     1309begin
     1310  result := FPColorToTColor(self);
     1311end;
     1312
     1313procedure TFPColorBasicHelper.FromColor(const AValue: TColor);
     1314begin
     1315  self := TColorToFPColor(AValue);
     1316end;
     1317
     1318function TFPColorBasicHelper.ToBGRAPixel: TBGRAPixel;
     1319begin
     1320  result := FPColorToBGRA(self);
     1321end;
     1322
     1323procedure TFPColorBasicHelper.FromBGRAPixel(AValue: TBGRAPixel);
     1324begin
     1325  self := BGRAToFPColor(AValue);
     1326end;
     1327
     1328function TFPColorBasicHelper.ToExpanded(AGammaExpansion: boolean): TExpandedPixel;
     1329begin
     1330  result.FromFPColor(self, AGammaExpansion);
     1331end;
     1332
     1333procedure TFPColorBasicHelper.FromExpanded(const AValue: TExpandedPixel;
     1334  AGammaCompression: boolean);
     1335begin
     1336  self := AValue.ToFPColor(AGammaCompression);
     1337end;
     1338
     1339{ THSLAPixelBasicHelper }
     1340
     1341function THSLAPixelBasicHelper.ToColor: TColor;
     1342begin
     1343  result := BGRAToColor(HSLAToBGRA(self));
     1344end;
     1345
     1346procedure THSLAPixelBasicHelper.FromColor(const AValue: TColor);
     1347begin
     1348  self := BGRAToHSLA(ColorToBGRA(AValue));
     1349end;
     1350
     1351function THSLAPixelBasicHelper.ToBGRAPixel: TBGRAPixel;
    10951352begin
    10961353  result := HSLAToBGRA(self);
    10971354end;
    10981355
    1099 procedure THSLAPixelHelper.FromBGRAPixel(AValue: TBGRAPixel);
     1356procedure THSLAPixelBasicHelper.FromBGRAPixel(AValue: TBGRAPixel);
    11001357begin
    11011358  self := BGRAToHSLA(AValue);
    11021359end;
    11031360
    1104 function THSLAPixelHelper.ToExpanded: TExpandedPixel;
     1361function THSLAPixelBasicHelper.ToGSBAPixel: TGSBAPixel;
     1362begin
     1363  result := HSLAToGSBA(self);
     1364end;
     1365
     1366procedure THSLAPixelBasicHelper.FromGSBAPixel(AValue: TGSBAPixel);
     1367begin
     1368  self := GSBAToHSLA(AValue);
     1369end;
     1370
     1371function THSLAPixelBasicHelper.ToExpanded: TExpandedPixel;
    11051372begin
    11061373  result := HSLAToExpanded(Self);
    11071374end;
    11081375
    1109 procedure THSLAPixelHelper.FromExpanded(AValue: TExpandedPixel);
     1376procedure THSLAPixelBasicHelper.FromExpanded(AValue: TExpandedPixel);
    11101377begin
    11111378  Self := ExpandedToHSLA(AValue);
    11121379end;
     1380
     1381operator :=(const Source: THSLAPixel): TBGRAPixel;
     1382begin
     1383  result := HSLAToBGRA(Source);
     1384end;
     1385
     1386operator :=(const Source: TBGRAPixel): THSLAPixel;
     1387begin
     1388  result := BGRAToHSLA(Source);
     1389end;
     1390
     1391operator :=(const Source: THSLAPixel): TExpandedPixel;
     1392begin
     1393  result := HSLAToExpanded(Source);
     1394end;
     1395
     1396operator:=(const Source: TExpandedPixel): THSLAPixel;
     1397begin
     1398  result := ExpandedToHSLA(Source);
     1399end;
     1400
     1401operator := (const AValue: TColor): THSLAPixel;
     1402begin Result := BGRAToHSLA(ColorToBGRA(ColorToRGB(AValue))) end;
     1403
     1404operator := (const AValue: THSLAPixel): TColor;
     1405begin Result := BGRAToColor(HSLAToBGRA(AValue)) end;
     1406
     1407{ TGSBAPixelBasicHelper }
     1408
     1409function TGSBAPixelBasicHelper.ToColor: TColor;
     1410begin
     1411  result := BGRAToColor(GSBAToBGRA(self));
     1412end;
     1413
     1414procedure TGSBAPixelBasicHelper.FromColor(const AValue: TColor);
     1415begin
     1416  self := BGRAToGSBA(ColorToBGRA(AValue));
     1417end;
     1418
     1419function TGSBAPixelBasicHelper.ToBGRAPixel: TBGRAPixel;
     1420begin
     1421  result := GSBAToBGRA(self);
     1422end;
     1423
     1424procedure TGSBAPixelBasicHelper.FromBGRAPixel(AValue: TBGRAPixel);
     1425begin
     1426  self := BGRAToGSBA(AValue);
     1427end;
     1428
     1429function TGSBAPixelBasicHelper.ToHSLAPixel: THSLAPixel;
     1430begin
     1431  result := GSBAToHSLA(self);
     1432end;
     1433
     1434procedure TGSBAPixelBasicHelper.FromHSLAPixel(AValue: THSLAPixel);
     1435begin
     1436  self := HSLAToGSBA(AValue);
     1437end;
     1438
     1439function TGSBAPixelBasicHelper.ToExpanded: TExpandedPixel;
     1440begin
     1441  result := GSBAToExpanded(self);
     1442end;
     1443
     1444procedure TGSBAPixelBasicHelper.FromExpanded(AValue: TExpandedPixel);
     1445begin
     1446  self := ExpandedToGSBA(AValue);
     1447end;
     1448
     1449operator :=(const Source: TGSBAPixel): TBGRAPixel;
     1450begin
     1451  result := GSBAToBGRA(Source);
     1452end;
     1453
     1454operator :=(const Source: TBGRAPixel): TGSBAPixel;
     1455begin
     1456  result := BGRAToGSBA(Source);
     1457end;
     1458
     1459operator :=(const Source: TGSBAPixel): TExpandedPixel;
     1460begin
     1461  result := GSBAToExpanded(Source);
     1462end;
     1463
     1464operator:=(const Source: TExpandedPixel): TGSBAPixel;
     1465begin
     1466  result := ExpandedToGSBA(Source);
     1467end;
     1468
     1469operator := (const AValue: TColor): TGSBAPixel;
     1470begin Result := BGRAToGSBA(ColorToBGRA(ColorToRGB(AValue))) end;
     1471
     1472operator := (const AValue: TGSBAPixel): TColor;
     1473begin Result := BGRAToColor(GSBAToBGRA(AValue)) end;
     1474
     1475operator :=(const Source: TGSBAPixel): THSLAPixel;
     1476begin
     1477  result := THSLAPixel(Pointer(@Source)^);
     1478end;
     1479
     1480operator:=(const Source: THSLAPixel): TGSBAPixel;
     1481begin
     1482  result := TGSBAPixel(Pointer(@Source)^);
     1483end;
    11131484{$ENDIF}
Note: See TracChangeset for help on using the changeset viewer.