Changeset 521 for GraphicTest/Packages/bgrabitmap/basiccolorspace.inc
- Timestamp:
- Apr 17, 2019, 12:58:41 AM (5 years ago)
- Location:
- GraphicTest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest
- Property svn:ignore
-
old new 8 8 GraphicTest.lps 9 9 GraphicTest.dbg 10 heaptrclog.trc
-
- Property svn:ignore
-
GraphicTest/Packages/bgrabitmap/basiccolorspace.inc
r494 r521 13 13 14 14 // 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 16 17 17 18 procedure BGRASetGamma(AGamma: single = 1.7); … … 42 43 {** Returns the lightness of an gamma-expanded pixel. The lightness is the 43 44 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; 45 46 {** 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; 47 48 {** Sets the lightness of a gamma expanded pixel, provided you already know the current 48 49 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; 50 51 {** Returns the importance of the color. It is similar to saturation 51 52 in HSL colorspace, except it is gamma corrected. A value of zero indicates … … 88 89 {** Hue of the pixel. Extremum values 0 and 65535 are red } 89 90 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) } 91 92 saturation: word; 92 93 {** Lightness of the color. 0 is black, 32768 is normal, and 65535 is white } … … 116 117 {* Pixel color defined in corrected HSL colorspace. G stands for corrected hue 117 118 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; 119 129 120 130 {** Converts a pixel from sRGB to correct HSL color space } … … 127 137 function HtoG(hue: word): word; 128 138 {** 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; 130 141 {** 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; 132 144 {** 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; 134 148 135 149 type 136 { TBGRAPixel Helper }137 138 TBGRAPixel Helper = record helper for TBGRAPixel150 { TBGRAPixelBasicHelper } 151 152 TBGRAPixelBasicHelper = record helper for TBGRAPixel 139 153 function ToExpanded: TExpandedPixel; 140 154 procedure FromExpanded(const AValue: TExpandedPixel); … … 142 156 procedure FromHSLAPixel(const AValue: THSLAPixel); 143 157 function ToGSBAPixel: TGSBAPixel; 144 procedure FromGSBAPixel(const AValue: TGSBAPixel); 158 procedure FromGSBAPixel(const AValue: TGSBAPixel); overload; 159 procedure FromGSBAPixel(const AValue: THSLAPixel); overload; 145 160 function ToColorF(AGammaExpansion: boolean): TColorF; 146 161 procedure FromColorF(const AValue: TColorF; AGammaCompression: boolean); 147 162 end; 148 163 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 180 operator := (const AValue: TExpandedPixel): TColor; 181 operator := (const AValue: TColor): TExpandedPixel; 182 Operator := (const Source: TExpandedPixel): TBGRAPixel; 183 Operator := (const Source: TBGRAPixel): TExpandedPixel; 184 185 type 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 210 Operator := (const Source: THSLAPixel): TBGRAPixel; 211 Operator := (const Source: TBGRAPixel): THSLAPixel; 212 Operator := (const Source: THSLAPixel): TExpandedPixel; 213 Operator := (const Source: TExpandedPixel): THSLAPixel; 214 operator := (const AValue: TColor): THSLAPixel; 215 operator := (const AValue: THSLAPixel): TColor; 216 217 type 218 { TGSBAPixelBasicHelper } 219 220 TGSBAPixelBasicHelper = record helper for TGSBAPixel 221 function ToColor: TColor; 222 procedure FromColor(const AValue: TColor); 152 223 function ToBGRAPixel: TBGRAPixel; 153 224 procedure FromBGRAPixel(AValue: TBGRAPixel); 154 225 function ToHSLAPixel: THSLAPixel; 155 226 procedure FromHSLAPixel(AValue: THSLAPixel); 156 end;157 158 { THSLAPixelHelper }159 160 THSLAPixelHelper = record helper for THSLAPixel161 function ToBGRAPixel: TBGRAPixel;162 procedure FromBGRAPixel(AValue: TBGRAPixel);163 227 function ToExpanded: TExpandedPixel; 164 228 procedure FromExpanded(AValue: TExpandedPixel); 165 229 end; 166 230 167 Operator := (Source: TExpandedPixel): TBGRAPixel; 231 Operator := (const Source: TGSBAPixel): TBGRAPixel; 232 Operator := (const Source: TBGRAPixel): TGSBAPixel; 233 Operator := (const Source: TGSBAPixel): TExpandedPixel; 234 Operator := (const Source: TExpandedPixel): TGSBAPixel; 235 operator := (const AValue: TColor): TGSBAPixel; 236 operator := (const AValue: TGSBAPixel): TColor; 237 Operator := (const Source: TGSBAPixel): THSLAPixel; //no conversion, just copying for backward compatibility (use ToHSLAPixel instead for conversion) 238 Operator := (const Source: THSLAPixel): TGSBAPixel; //no conversion, just copying for backward compatibility (use ToGSBAPixel instead for conversion) 168 239 {$ENDIF} 169 240 … … 317 388 nextpos := round(power(i+0.5, GammaExpFactor) * GammaLinearFactor); 318 389 GammaExpansionTab[i] := midpos; 319 for j := prevpos to nextpos-1 do 390 for j := prevpos to midpos-1 do 391 begin 320 392 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; 321 400 end; 322 401 GammaCompressionTab[0] := 0; … … 358 437 Result.blue := GammaCompressionTab[blue]; 359 438 Result.alpha := alpha shr 8; 439 end; 440 441 function GammaExpansionW(ACompressed: word): word; 442 var 443 intPart: Integer; 444 f,fracPart: Single; 445 begin 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; 460 end; 461 462 function GammaCompressionW(AExpanded: word): word; 463 begin 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; 360 474 end; 361 475 … … 871 985 var lightness: UInt32Or64; 872 986 red,green,blue: Int32or64; 987 hsla: THSLAPixel; 873 988 begin 874 989 red := GammaExpansionTab[c.red]; 875 990 green := GammaExpansionTab[c.green]; 876 991 blue := GammaExpansionTab[c.blue]; 877 result.alpha := c.alpha shl 8 + c.alpha;992 hsla.alpha := c.alpha shl 8 + c.alpha; 878 993 879 994 lightness := (red * redWeightShl10 + green * greenWeightShl10 + 880 995 blue * blueWeightShl10 + 512) shr 10; 881 996 882 ExpandedToHSLAInline(red,green,blue,result); 997 ExpandedToHSLAInline(red,green,blue,hsla); 998 result := TGSBAPixel(hsla); 999 883 1000 if result.lightness > 32768 then 884 1001 result.saturation := result.saturation* UInt32or64(not result.lightness) div 32767; … … 890 1007 var lightness: UInt32Or64; 891 1008 red,green,blue: Int32or64; 1009 hsla: THSLAPixel; 892 1010 begin 893 1011 red := ec.red; 894 1012 green := ec.green; 895 1013 blue := ec.blue; 896 result.alpha := ec.alpha;1014 hsla.alpha := ec.alpha; 897 1015 898 1016 lightness := (red * redWeightShl10 + green * greenWeightShl10 + 899 1017 blue * blueWeightShl10 + 512) shr 10; 900 1018 901 ExpandedToHSLAInline(red,green,blue,result); 1019 ExpandedToHSLAInline(red,green,blue,hsla); 1020 result := TGSBAPixel(hsla); 1021 902 1022 if result.lightness > 32768 then 903 1023 result.saturation := result.saturation* UInt32or64(not result.lightness) div 32767; … … 1002 1122 lightness := c.lightness; 1003 1123 c.lightness := 32768; 1004 ec := HSLAToExpanded( c);1124 ec := HSLAToExpanded(THSLAPixel(c)); 1005 1125 result := GammaCompression(SetLightness(ec, lightness)); 1126 end; 1127 1128 function GSBAToBGRA(const c: THSLAPixel): TBGRAPixel; 1129 begin 1130 result := GSBAToBGRA(TGSBAPixel(c)); 1006 1131 end; 1007 1132 … … 1012 1137 lightness := c.lightness; 1013 1138 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); 1140 end; 1141 1142 function GSBAToExpanded(const c: THSLAPixel): TExpandedPixel; 1143 begin 1144 result := GSBAToExpanded(TGSBAPixel(c)); 1145 end; 1146 1147 function GSBAToHSLA(const c: TGSBAPixel): THSLAPixel; 1148 begin 1149 result := ExpandedToHSLA(GSBAToExpanded(c)); 1150 end; 1151 1152 function GSBAToHSLA(const c: THSLAPixel): THSLAPixel; 1153 begin 1154 result := ExpandedToHSLA(GSBAToExpanded(TGSBAPixel(c))); 1155 end; 1156 1157 function HSLAToGSBA(const c: THSLAPixel): TGSBAPixel; 1158 begin 1159 result := ExpandedToGSBA(HSLAToExpanded(c)); 1160 end; 1161 1162 { TBGRAPixelBasicHelper } 1163 1164 function TBGRAPixelBasicHelper.ToExpanded: TExpandedPixel; 1025 1165 begin 1026 1166 result := GammaExpansion(self); 1027 1167 end; 1028 1168 1029 procedure TBGRAPixel Helper.FromExpanded(const AValue: TExpandedPixel);1169 procedure TBGRAPixelBasicHelper.FromExpanded(const AValue: TExpandedPixel); 1030 1170 begin 1031 1171 Self := GammaCompression(AValue); 1032 1172 end; 1033 1173 1034 function TBGRAPixel Helper.ToHSLAPixel: THSLAPixel;1174 function TBGRAPixelBasicHelper.ToHSLAPixel: THSLAPixel; 1035 1175 begin 1036 1176 result := BGRAToHSLA(Self); 1037 1177 end; 1038 1178 1039 procedure TBGRAPixel Helper.FromHSLAPixel(const AValue: THSLAPixel);1179 procedure TBGRAPixelBasicHelper.FromHSLAPixel(const AValue: THSLAPixel); 1040 1180 begin 1041 1181 Self := HSLAToBGRA(AValue); 1042 1182 end; 1043 1183 1044 function TBGRAPixel Helper.ToGSBAPixel: TGSBAPixel;1184 function TBGRAPixelBasicHelper.ToGSBAPixel: TGSBAPixel; 1045 1185 begin 1046 1186 result := BGRAToGSBA(Self); 1047 1187 end; 1048 1188 1049 procedure TBGRAPixel Helper.FromGSBAPixel(const AValue: TGSBAPixel);1189 procedure TBGRAPixelBasicHelper.FromGSBAPixel(const AValue: TGSBAPixel); 1050 1190 begin 1051 1191 Self := GSBAToBGRA(AValue); 1052 1192 end; 1053 1193 1054 function TBGRAPixelHelper.ToColorF(AGammaExpansion: boolean): TColorF; 1194 procedure TBGRAPixelBasicHelper.FromGSBAPixel(const AValue: THSLAPixel); 1195 begin 1196 Self := GSBAToBGRA(AValue); 1197 end; 1198 1199 function TBGRAPixelBasicHelper.ToColorF(AGammaExpansion: boolean): TColorF; 1055 1200 begin 1056 1201 result := BGRAToColorF(Self,AGammaExpansion); 1057 1202 end; 1058 1203 1059 procedure TBGRAPixel Helper.FromColorF(const AValue: TColorF;1204 procedure TBGRAPixelBasicHelper.FromColorF(const AValue: TColorF; 1060 1205 AGammaCompression: boolean); 1061 1206 begin … … 1063 1208 end; 1064 1209 1065 { TExpandedPixelHelper } 1066 1067 function TExpandedPixelHelper.ToBGRAPixel: TBGRAPixel; 1210 { TExpandedPixelBasicHelper } 1211 1212 function TExpandedPixelBasicHelper.ToFPColor(AGammaCompression: boolean): TFPColor; 1213 begin 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; 1226 end; 1227 1228 procedure TExpandedPixelBasicHelper.FromFPColor(const AValue: TFPColor; 1229 AGammaExpansion: boolean); 1230 begin 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; 1243 end; 1244 1245 function TExpandedPixelBasicHelper.ToColor: TColor; 1246 begin 1247 result := BGRAToColor(GammaCompression(self)); 1248 end; 1249 1250 procedure TExpandedPixelBasicHelper.FromColor(const AValue: TColor); 1251 begin 1252 self := GammaExpansion(ColorToBGRA(AValue)); 1253 end; 1254 1255 function TExpandedPixelBasicHelper.ToBGRAPixel: TBGRAPixel; 1068 1256 begin 1069 1257 result := GammaCompression(Self); 1070 1258 end; 1071 1259 1072 procedure TExpandedPixel Helper.FromBGRAPixel(AValue: TBGRAPixel);1260 procedure TExpandedPixelBasicHelper.FromBGRAPixel(AValue: TBGRAPixel); 1073 1261 begin 1074 1262 Self := GammaExpansion(AValue); 1075 1263 end; 1076 1264 1077 function TExpandedPixel Helper.ToHSLAPixel: THSLAPixel;1265 function TExpandedPixelBasicHelper.ToHSLAPixel: THSLAPixel; 1078 1266 begin 1079 1267 result := ExpandedToHSLA(Self); 1080 1268 end; 1081 1269 1082 procedure TExpandedPixel Helper.FromHSLAPixel(AValue: THSLAPixel);1270 procedure TExpandedPixelBasicHelper.FromHSLAPixel(const AValue: THSLAPixel); 1083 1271 begin 1084 1272 Self := HSLAToExpanded(AValue); 1085 1273 end; 1086 1274 1087 operator :=(Source: TExpandedPixel): TBGRAPixel; 1275 function TExpandedPixelBasicHelper.ToGSBAPixel: TGSBAPixel; 1276 begin 1277 result := ExpandedToGSBA(Self); 1278 end; 1279 1280 procedure TExpandedPixelBasicHelper.FromGSBAPixel(const AValue: TGSBAPixel); 1281 begin 1282 Self := GSBAToExpanded(AValue); 1283 end; 1284 1285 procedure TExpandedPixelBasicHelper.FromGSBAPixel(const AValue: THSLAPixel); 1286 begin 1287 Self := GSBAToExpanded(AValue); 1288 end; 1289 1290 operator := (const AValue: TExpandedPixel): TColor; 1291 begin Result := BGRAToColor(GammaCompression(AValue)); end; 1292 1293 operator := (const AValue: TColor): TExpandedPixel; 1294 begin Result := GammaExpansion(ColorToBGRA(ColorToRGB(AValue))) end; 1295 1296 operator :=(const Source: TExpandedPixel): TBGRAPixel; 1088 1297 begin 1089 1298 result := GammaCompression(Source); 1090 1299 end; 1091 1300 1092 { THSLAPixelHelper } 1093 1094 function THSLAPixelHelper.ToBGRAPixel: TBGRAPixel; 1301 operator :=(const Source: TBGRAPixel): TExpandedPixel; 1302 begin 1303 result := GammaExpansion(Source); 1304 end; 1305 1306 { TFPColorBasicHelper } 1307 1308 function TFPColorBasicHelper.ToColor: TColor; 1309 begin 1310 result := FPColorToTColor(self); 1311 end; 1312 1313 procedure TFPColorBasicHelper.FromColor(const AValue: TColor); 1314 begin 1315 self := TColorToFPColor(AValue); 1316 end; 1317 1318 function TFPColorBasicHelper.ToBGRAPixel: TBGRAPixel; 1319 begin 1320 result := FPColorToBGRA(self); 1321 end; 1322 1323 procedure TFPColorBasicHelper.FromBGRAPixel(AValue: TBGRAPixel); 1324 begin 1325 self := BGRAToFPColor(AValue); 1326 end; 1327 1328 function TFPColorBasicHelper.ToExpanded(AGammaExpansion: boolean): TExpandedPixel; 1329 begin 1330 result.FromFPColor(self, AGammaExpansion); 1331 end; 1332 1333 procedure TFPColorBasicHelper.FromExpanded(const AValue: TExpandedPixel; 1334 AGammaCompression: boolean); 1335 begin 1336 self := AValue.ToFPColor(AGammaCompression); 1337 end; 1338 1339 { THSLAPixelBasicHelper } 1340 1341 function THSLAPixelBasicHelper.ToColor: TColor; 1342 begin 1343 result := BGRAToColor(HSLAToBGRA(self)); 1344 end; 1345 1346 procedure THSLAPixelBasicHelper.FromColor(const AValue: TColor); 1347 begin 1348 self := BGRAToHSLA(ColorToBGRA(AValue)); 1349 end; 1350 1351 function THSLAPixelBasicHelper.ToBGRAPixel: TBGRAPixel; 1095 1352 begin 1096 1353 result := HSLAToBGRA(self); 1097 1354 end; 1098 1355 1099 procedure THSLAPixel Helper.FromBGRAPixel(AValue: TBGRAPixel);1356 procedure THSLAPixelBasicHelper.FromBGRAPixel(AValue: TBGRAPixel); 1100 1357 begin 1101 1358 self := BGRAToHSLA(AValue); 1102 1359 end; 1103 1360 1104 function THSLAPixelHelper.ToExpanded: TExpandedPixel; 1361 function THSLAPixelBasicHelper.ToGSBAPixel: TGSBAPixel; 1362 begin 1363 result := HSLAToGSBA(self); 1364 end; 1365 1366 procedure THSLAPixelBasicHelper.FromGSBAPixel(AValue: TGSBAPixel); 1367 begin 1368 self := GSBAToHSLA(AValue); 1369 end; 1370 1371 function THSLAPixelBasicHelper.ToExpanded: TExpandedPixel; 1105 1372 begin 1106 1373 result := HSLAToExpanded(Self); 1107 1374 end; 1108 1375 1109 procedure THSLAPixel Helper.FromExpanded(AValue: TExpandedPixel);1376 procedure THSLAPixelBasicHelper.FromExpanded(AValue: TExpandedPixel); 1110 1377 begin 1111 1378 Self := ExpandedToHSLA(AValue); 1112 1379 end; 1380 1381 operator :=(const Source: THSLAPixel): TBGRAPixel; 1382 begin 1383 result := HSLAToBGRA(Source); 1384 end; 1385 1386 operator :=(const Source: TBGRAPixel): THSLAPixel; 1387 begin 1388 result := BGRAToHSLA(Source); 1389 end; 1390 1391 operator :=(const Source: THSLAPixel): TExpandedPixel; 1392 begin 1393 result := HSLAToExpanded(Source); 1394 end; 1395 1396 operator:=(const Source: TExpandedPixel): THSLAPixel; 1397 begin 1398 result := ExpandedToHSLA(Source); 1399 end; 1400 1401 operator := (const AValue: TColor): THSLAPixel; 1402 begin Result := BGRAToHSLA(ColorToBGRA(ColorToRGB(AValue))) end; 1403 1404 operator := (const AValue: THSLAPixel): TColor; 1405 begin Result := BGRAToColor(HSLAToBGRA(AValue)) end; 1406 1407 { TGSBAPixelBasicHelper } 1408 1409 function TGSBAPixelBasicHelper.ToColor: TColor; 1410 begin 1411 result := BGRAToColor(GSBAToBGRA(self)); 1412 end; 1413 1414 procedure TGSBAPixelBasicHelper.FromColor(const AValue: TColor); 1415 begin 1416 self := BGRAToGSBA(ColorToBGRA(AValue)); 1417 end; 1418 1419 function TGSBAPixelBasicHelper.ToBGRAPixel: TBGRAPixel; 1420 begin 1421 result := GSBAToBGRA(self); 1422 end; 1423 1424 procedure TGSBAPixelBasicHelper.FromBGRAPixel(AValue: TBGRAPixel); 1425 begin 1426 self := BGRAToGSBA(AValue); 1427 end; 1428 1429 function TGSBAPixelBasicHelper.ToHSLAPixel: THSLAPixel; 1430 begin 1431 result := GSBAToHSLA(self); 1432 end; 1433 1434 procedure TGSBAPixelBasicHelper.FromHSLAPixel(AValue: THSLAPixel); 1435 begin 1436 self := HSLAToGSBA(AValue); 1437 end; 1438 1439 function TGSBAPixelBasicHelper.ToExpanded: TExpandedPixel; 1440 begin 1441 result := GSBAToExpanded(self); 1442 end; 1443 1444 procedure TGSBAPixelBasicHelper.FromExpanded(AValue: TExpandedPixel); 1445 begin 1446 self := ExpandedToGSBA(AValue); 1447 end; 1448 1449 operator :=(const Source: TGSBAPixel): TBGRAPixel; 1450 begin 1451 result := GSBAToBGRA(Source); 1452 end; 1453 1454 operator :=(const Source: TBGRAPixel): TGSBAPixel; 1455 begin 1456 result := BGRAToGSBA(Source); 1457 end; 1458 1459 operator :=(const Source: TGSBAPixel): TExpandedPixel; 1460 begin 1461 result := GSBAToExpanded(Source); 1462 end; 1463 1464 operator:=(const Source: TExpandedPixel): TGSBAPixel; 1465 begin 1466 result := ExpandedToGSBA(Source); 1467 end; 1468 1469 operator := (const AValue: TColor): TGSBAPixel; 1470 begin Result := BGRAToGSBA(ColorToBGRA(ColorToRGB(AValue))) end; 1471 1472 operator := (const AValue: TGSBAPixel): TColor; 1473 begin Result := BGRAToColor(GSBAToBGRA(AValue)) end; 1474 1475 operator :=(const Source: TGSBAPixel): THSLAPixel; 1476 begin 1477 result := THSLAPixel(Pointer(@Source)^); 1478 end; 1479 1480 operator:=(const Source: THSLAPixel): TGSBAPixel; 1481 begin 1482 result := TGSBAPixel(Pointer(@Source)^); 1483 end; 1113 1484 {$ENDIF}
Note:
See TracChangeset
for help on using the changeset viewer.