[hackers] [farbfeld] Use linear RGB || FRIGN

From: <git_AT_suckless.org>
Date: Wed, 20 Jan 2016 22:33:06 +0100 (CET)

commit e9feca5c2bda05b9a356617868fd4b08ec903d0d
Author: FRIGN <dev_AT_frign.de>
AuthorDate: Wed Jan 20 22:31:25 2016 +0100
Commit: FRIGN <dev_AT_frign.de>
CommitDate: Wed Jan 20 22:31:25 2016 +0100

    Use linear RGB
    
    Makes things a lot easier for image manipulation algorithms which
    can be expected to be applied to farbfeld data.

diff --git a/FORMAT b/FORMAT
index 6821ab2..c033efb 100644
--- a/FORMAT
+++ b/FORMAT
_AT_@ -1,15 +1,18 @@
 
   FARBFELD IMAGE FORMAT SPECIFICATION
 
- +--------+-------------------------------------------------------+
- | Bytes | Description |
- +--------+-------------------------------------------------------+
- | 8 | "farbfeld" magic value |
- +--------+-------------------------------------------------------+
- | 4 | 32-Bit BE unsigned integer (width) |
- +--------+-------------------------------------------------------+
- | 4 | 32-Bit BE unsigned integer (height) |
- +--------+-------------------------------------------------------+
- | [2222] | 4*16-Bit BE unsigned integers [RGBA] / pixel |
- | | pixels in rows, ProPhoto RGB, not alpha-premultiplied |
- +--------+-------------------------------------------------------+
+ +--------+-----------------------------------------------+
+ | Bytes | Description |
+ +--------+-----------------------------------------------+
+ | 8 | "farbfeld" magic value |
+ +--------+-----------------------------------------------+
+ | 4 | 32-Bit BE unsigned integer (width) |
+ +--------+-----------------------------------------------+
+ | 4 | 32-Bit BE unsigned integer (height) |
+ +--------+-----------------------------------------------+
+ | [2222] | 4*16-Bit BE unsigned integers [RGBA] / pixel |
+ | | - pixels in rows |
+ | | - linear ROMM RGB (ISO 22028-2:2013) |
+ | | (= linear ProPhoto RGB = Melissa RGB) |
+ | | - no alpha premultiplication |
+ +--------+-----------------------------------------------+
diff --git a/ff2png.c b/ff2png.c
index 9f562b8..03fa1f6 100644
--- a/ff2png.c
+++ b/ff2png.c
_AT_@ -14,7 +14,7 @@
 
 static char *argv0;
 
-/* ProPhoto RGB */
+/* ROMM RGB primaries (ISO 22028-2:2013) */
 static cmsCIExyYTRIPLE primaries = {
         /* x, y, Y */
         { 0.7347, 0.2653, 0.288040 }, /* red */
_AT_@ -34,8 +34,8 @@ main(int argc, char *argv[])
 {
         cmsContext icc_context;
         cmsHPROFILE out_prof;
- cmsMLU *mlu1, *mlu2;
- cmsToneCurve *gamma18, *out_curve[3];
+ cmsMLU *mlu1, *mlu2, *mlu3;
+ cmsToneCurve *gamma10, *out_curve[3];
         png_structp pngs;
         png_infop pngi;
         size_t png_row_len, j;
_AT_@ -62,25 +62,27 @@ main(int argc, char *argv[])
         width = ntohl(*((uint32_t *)(hdr + 8)));
         height = ntohl(*((uint32_t *)(hdr + 12)));
 
- /* icc profile (ProPhoto RGB) */
+ /* icc profile (linear ROMM RGB (ISO 22028-2:2013)) */
         if (!(icc_context = cmsCreateContext(NULL, NULL)))
                 goto lcmserr;
- if (!(gamma18 = cmsBuildGamma(icc_context, 1.8)))
+ if (!(gamma10 = cmsBuildGamma(icc_context, 1.0)))
                 goto lcmserr;
- out_curve[0] = out_curve[1] = out_curve[2] = gamma18;
+ out_curve[0] = out_curve[1] = out_curve[2] = gamma10;
         if (!(out_prof = cmsCreateRGBProfileTHR(icc_context, cmsD50_xyY(),
                                                 &primaries, out_curve)))
                 goto lcmserr;
         cmsSetHeaderFlags(out_prof, cmsEmbeddedProfileTrue | cmsUseAnywhere);
         cmsSetHeaderRenderingIntent(out_prof, INTENT_RELATIVE_COLORIMETRIC);
         cmsSetDeviceClass(out_prof, cmsSigColorSpaceClass);
- if (!(mlu1 = cmsMLUalloc(NULL, 1)) || !(mlu2 = cmsMLUalloc(NULL, 1)))
+ if (!(mlu1 = cmsMLUalloc(NULL, 1)) || !(mlu2 = cmsMLUalloc(NULL, 1)) ||
+ !(mlu3 = cmsMLUalloc(NULL, 1)))
                 goto lcmserr;
         cmsMLUsetASCII(mlu1, "en", "US", "Public Domain");
         cmsWriteTag(out_prof, cmsSigCopyrightTag, mlu1);
- cmsMLUsetASCII(mlu2, "en", "US", "ProPhoto RGB");
- cmsWriteTag(out_prof, cmsSigProfileDescriptionTag, mlu2);
+ cmsMLUsetASCII(mlu2, "en", "US", "aka Linear ProPhoto RGB, Melissa RGB");
         cmsWriteTag(out_prof, cmsSigDeviceModelDescTag, mlu2);
+ cmsMLUsetASCII(mlu3, "en", "US", "Linear ROMM RGB (ISO 22028-2:2013)");
+ cmsWriteTag(out_prof, cmsSigProfileDescriptionTag, mlu3);
         cmsSaveProfileToMem(out_prof, NULL, &icclen);
         if (!(icc = malloc(icclen))) {
                 fprintf(stderr, "%s: malloc: out of memory\n", argv0);
_AT_@ -101,7 +103,8 @@ main(int argc, char *argv[])
         png_set_IHDR(pngs, pngi, width, height, 16, PNG_COLOR_TYPE_RGB_ALPHA,
                      PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
                      PNG_FILTER_TYPE_BASE);
- png_set_iCCP(pngs, pngi, "ProPhoto RGB", 0, icc, icclen);
+ png_set_iCCP(pngs, pngi, "Linear ROMM RGB (ISO 22028-2:2013)", 0,
+ icc, icclen);
         png_write_info(pngs, pngi);
 
         /* write rows */
diff --git a/jpg2ff.c b/jpg2ff.c
index c1a0f92..cdf5d56 100644
--- a/jpg2ff.c
+++ b/jpg2ff.c
_AT_@ -12,7 +12,7 @@
 
 static char *argv0;
 
-/* ProPhoto RGB */
+/* ROMM RGB primaries (ISO 22028-2:2013) */
 static cmsCIExyYTRIPLE primaries = {
         /* x, y, Y */
         { 0.7347, 0.2653, 0.288040 }, /* red */
_AT_@ -33,7 +33,7 @@ main(int argc, char *argv[])
 {
         cmsHPROFILE in_profile = NULL, out_profile;
         cmsHTRANSFORM transform;
- cmsToneCurve *gamma18, *out_curves[3];
+ cmsToneCurve *gamma10, *out_curves[3];
         struct jpeg_decompress_struct cinfo;
         jpeg_saved_marker_ptr marker;
         struct jpeg_error_mgr jerr;
_AT_@ -97,12 +97,12 @@ main(int argc, char *argv[])
                 return 1;
         }
 
- /* icc profile (output ProPhoto RGB) */
+ /* icc profile (output linear ROMM RGB (ISO 22028-2:2013)) */
         if (!in_profile && !(in_profile = cmsCreate_sRGBProfile()))
                 goto lcmserr;
- if (!(gamma18 = cmsBuildGamma(NULL, 1.8)))
+ if (!(gamma10 = cmsBuildGamma(NULL, 1.0)))
                 goto lcmserr;
- out_curves[0] = out_curves[1] = out_curves[2] = gamma18;
+ out_curves[0] = out_curves[1] = out_curves[2] = gamma10;
         if (!(out_profile = cmsCreateRGBProfile(cmsD50_xyY(), &primaries,
                                                 out_curves)))
                 goto lcmserr;
diff --git a/png2ff.c b/png2ff.c
index 6750b6b..a5b96ce 100644
--- a/png2ff.c
+++ b/png2ff.c
_AT_@ -12,7 +12,7 @@
 
 static char *argv0;
 
-/* ProPhoto RGB */
+/* ROMM RGB primaries (ISO 22028-2:2013) */
 static cmsCIExyYTRIPLE primaries = {
         /* x, y, Y */
         { 0.7347, 0.2653, 0.288040 }, /* red */
_AT_@ -32,7 +32,7 @@ main(int argc, char *argv[])
 {
         cmsHPROFILE in_prof, out_prof;
         cmsHTRANSFORM trans;
- cmsToneCurve *gamma18, *out_curves[3];
+ cmsToneCurve *gamma10, *out_curves[3];
         png_structp pngs;
         png_infop pngi;
         int icc_compression;
_AT_@ -70,7 +70,7 @@ main(int argc, char *argv[])
         height = png_get_image_height(pngs, pngi);
         png_row_p = png_get_rows(pngs, pngi);
 
- /* icc profile (output ProPhoto RGB) */
+ /* icc profile (output linear ROMM RGB (ISO 22028-2:2013)) */
         if (png_get_valid(pngs, pngi, PNG_INFO_iCCP)) {
                 png_get_iCCP(pngs, pngi, &icc_name,
                              &icc_compression, &icc_data, &icc_len);
_AT_@ -81,9 +81,9 @@ main(int argc, char *argv[])
                 if (!(in_prof = cmsCreate_sRGBProfile()))
                         goto lcmserr;
         }
- if (!(gamma18 = cmsBuildGamma(NULL, 1.8)))
+ if (!(gamma10 = cmsBuildGamma(NULL, 1.0)))
                 goto lcmserr;
- out_curves[0] = out_curves[1] = out_curves[2] = gamma18;
+ out_curves[0] = out_curves[1] = out_curves[2] = gamma10;
         if (!(out_prof = cmsCreateRGBProfile(cmsD50_xyY(), &primaries,
                                                 out_curves)))
                 goto lcmserr;
Received on Wed Jan 20 2016 - 22:33:06 CET

This archive was generated by hypermail 2.3.0 : Wed Jan 20 2016 - 22:36:22 CET