Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* vim: set ts=8 sw=8 noexpandtab: */ | 1 /* vim: set ts=8 sw=8 noexpandtab: */ |
| 2 // qcms | 2 // qcms |
| 3 // Copyright (C) 2009 Mozilla Foundation | 3 // Copyright (C) 2009 Mozilla Foundation |
| 4 // Copyright (C) 1998-2007 Marti Maria | 4 // Copyright (C) 1998-2007 Marti Maria |
| 5 // | 5 // |
| 6 // Permission is hereby granted, free of charge, to any person obtaining | 6 // Permission is hereby granted, free of charge, to any person obtaining |
| 7 // a copy of this software and associated documentation files (the "Software"), | 7 // a copy of this software and associated documentation files (the "Software"), |
| 8 // to deal in the Software without restriction, including without limitation | 8 // to deal in the Software without restriction, including without limitation |
| 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, | 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e | 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1231 profile->color_space = RGB_SIGNATURE; | 1231 profile->color_space = RGB_SIGNATURE; |
| 1232 profile->pcs = XYZ_SIGNATURE; | 1232 profile->pcs = XYZ_SIGNATURE; |
| 1233 return profile; | 1233 return profile; |
| 1234 } | 1234 } |
| 1235 | 1235 |
| 1236 /* from lcms: cmsWhitePointFromTemp */ | 1236 /* from lcms: cmsWhitePointFromTemp */ |
| 1237 /* tempK must be >= 4000. and <= 25000. | 1237 /* tempK must be >= 4000. and <= 25000. |
| 1238 * Invalid values of tempK will return | 1238 * Invalid values of tempK will return |
| 1239 * (x,y,Y) = (-1.0, -1.0, -1.0) | 1239 * (x,y,Y) = (-1.0, -1.0, -1.0) |
| 1240 * similar to argyll: icx_DTEMP2XYZ() */ | 1240 * similar to argyll: icx_DTEMP2XYZ() */ |
| 1241 static qcms_CIE_xyY white_point_from_temp(int temp_K) | 1241 qcms_CIE_xyY white_point_from_temp(int temp_K) |
| 1242 { | 1242 { |
| 1243 qcms_CIE_xyY white_point; | 1243 qcms_CIE_xyY white_point; |
| 1244 double x, y; | 1244 double x, y; |
| 1245 double T, T2, T3; | 1245 double T, T2, T3; |
| 1246 // double M1, M2; | 1246 // double M1, M2; |
| 1247 | 1247 |
| 1248 // No optimization provided. | 1248 // No optimization provided. |
| 1249 T = temp_K; | 1249 T = temp_K; |
| 1250 T2 = T*T; // Square | 1250 T2 = T*T; // Square |
| 1251 T3 = T2*T; // Cube | 1251 T3 = T2*T; // Cube |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1284 white_point.Y = 1.0; | 1284 white_point.Y = 1.0; |
| 1285 | 1285 |
| 1286 return white_point; | 1286 return white_point; |
| 1287 } | 1287 } |
| 1288 | 1288 |
| 1289 qcms_profile* qcms_profile_sRGB(void) | 1289 qcms_profile* qcms_profile_sRGB(void) |
| 1290 { | 1290 { |
| 1291 qcms_profile *profile; | 1291 qcms_profile *profile; |
| 1292 uint16_t *table; | 1292 uint16_t *table; |
| 1293 | 1293 |
| 1294 » qcms_CIE_xyYTRIPLE Rec709Primaries = { | 1294 » // Standard Illuminant D65 in XYZ coordinates, which is the standard |
| 1295 » » {0.6400, 0.3300, 1.0}, | 1295 » // sRGB IEC61966-2.1 / Rec.709 profile reference media white point. |
| 1296 » » {0.3000, 0.6000, 1.0}, | 1296 » struct XYZNumber D65 = { |
| 1297 » » {0.1500, 0.0600, 1.0} | 1297 » » » 0xf351, 0x10000, 0x116cc // ( 0.950455, 1.000000, 1.0890 50 ) |
|
Noel Gordon
2016/03/11 15:45:08
Nit: one tab too many.
radu.velea
2016/03/11 15:55:21
Done.
| |
| 1298 }; | 1298 }; |
| 1299 qcms_CIE_xyY D65; | |
| 1300 | 1299 |
| 1301 » D65 = white_point_from_temp(6504); | 1300 » // sRGB IEC61966-2.1 / Rec.709 color profile primaries, chromatically |
| 1301 » // adapted (via Bradford procedures) to the ICC PCS white point, D50. | |
| 1302 » s15Fixed16Number primaries[3][3] = { | |
| 1303 » » » { 0x06fa2, 0x06299, 0x024a0 }, // ( 0.436066, 0.385147, 0.143066 ) | |
|
Noel Gordon
2016/03/11 15:45:08
1303-1304 ditto, one tab too many.
radu.velea
2016/03/11 15:55:21
Done.
| |
| 1304 » » » { 0x038f5, 0x0b785, 0x00f84 }, // ( 0.222488, 0.716873, 0.060608 ) | |
| 1305 » » » { 0x00390, 0x018da, 0x0b6cf }, // ( 0.013916, 0.097076, 0.714096 ) | |
| 1306 » }; | |
| 1302 | 1307 |
| 1303 table = build_sRGB_gamma_table(1024); | 1308 table = build_sRGB_gamma_table(1024); |
| 1304 | 1309 |
| 1305 if (!table) | 1310 if (!table) |
| 1306 return NO_MEM_PROFILE; | 1311 return NO_MEM_PROFILE; |
| 1307 | 1312 |
| 1308 » profile = qcms_profile_create_rgb_with_table(D65, Rec709Primaries, table , 1024); | 1313 » profile = qcms_profile_create(); |
| 1309 » if (profile) | 1314 |
| 1310 » » strcpy(profile->description, "sRGB IEC61966-2.1"); | 1315 » if (!profile) { |
| 1316 » » free(table); | |
| 1317 » » return NO_MEM_PROFILE; | |
| 1318 » } | |
| 1319 | |
| 1320 » profile->redTRC = curve_from_table(table, 1024); | |
| 1321 » profile->blueTRC = curve_from_table(table, 1024); | |
| 1322 » profile->greenTRC = curve_from_table(table, 1024); | |
| 1323 | |
| 1324 » if (!profile->redTRC || !profile->blueTRC || !profile->greenTRC) { | |
| 1325 » » free(table); | |
| 1326 » » qcms_profile_release(profile); | |
| 1327 » » return NO_MEM_PROFILE; | |
| 1328 » } | |
| 1329 | |
| 1330 » profile->redColorant.X = primaries[0][0]; | |
| 1331 » profile->redColorant.Y = primaries[1][0]; | |
| 1332 » profile->redColorant.Z = primaries[2][0]; | |
| 1333 | |
| 1334 » profile->greenColorant.X = primaries[0][1]; | |
| 1335 » profile->greenColorant.Y = primaries[1][1]; | |
| 1336 » profile->greenColorant.Z = primaries[2][1]; | |
| 1337 | |
| 1338 » profile->blueColorant.X = primaries[0][2]; | |
| 1339 » profile->blueColorant.Y = primaries[1][2]; | |
| 1340 » profile->blueColorant.Z = primaries[2][2]; | |
| 1341 | |
| 1342 » profile->mediaWhitePoint.X = D65.X; | |
| 1343 » profile->mediaWhitePoint.Y = D65.Y; | |
| 1344 » profile->mediaWhitePoint.Z = D65.Z; | |
| 1345 | |
| 1346 » profile->class = DISPLAY_DEVICE_PROFILE; | |
| 1347 » profile->rendering_intent = QCMS_INTENT_PERCEPTUAL; | |
| 1348 » profile->color_space = RGB_SIGNATURE; | |
| 1349 » profile->pcs = XYZ_SIGNATURE; | |
| 1350 | |
| 1351 » strcpy(profile->description, "sRGB IEC61966-2.1"); | |
| 1311 | 1352 |
| 1312 free(table); | 1353 free(table); |
| 1354 | |
| 1313 return profile; | 1355 return profile; |
| 1314 } | 1356 } |
| 1315 | 1357 |
| 1316 /* qcms_profile_from_memory does not hold a reference to the memory passed in */ | 1358 /* qcms_profile_from_memory does not hold a reference to the memory passed in */ |
| 1317 qcms_profile* qcms_profile_from_memory(const void *mem, size_t size) | 1359 qcms_profile* qcms_profile_from_memory(const void *mem, size_t size) |
| 1318 { | 1360 { |
| 1319 uint32_t length; | 1361 uint32_t length; |
| 1320 struct mem_source source; | 1362 struct mem_source source; |
| 1321 struct mem_source *src = &source; | 1363 struct mem_source *src = &source; |
| 1322 struct tag_index index; | 1364 struct tag_index index; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1583 { | 1625 { |
| 1584 qcms_profile *profile = NULL; | 1626 qcms_profile *profile = NULL; |
| 1585 FILE *file = _wfopen(path, L"rb"); | 1627 FILE *file = _wfopen(path, L"rb"); |
| 1586 if (file) { | 1628 if (file) { |
| 1587 profile = qcms_profile_from_file(file); | 1629 profile = qcms_profile_from_file(file); |
| 1588 fclose(file); | 1630 fclose(file); |
| 1589 } | 1631 } |
| 1590 return profile; | 1632 return profile; |
| 1591 } | 1633 } |
| 1592 #endif | 1634 #endif |
| OLD | NEW |