Cleaned up the coding style of the test programs run by "make check".
- Converted comments from "/* ... */" to "// ..."
- Suppressed warnings of unused return values of fgets() and fread(), via
"fread(...);" -> "if (fread(...));"
-/*
- * IEEE-1284 support functions test program for OpenPrinting CUPS Filters.
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "COPYING"
- * which should have been included with this file.
- *
- * Contents:
- *
- * main() - Test the device-ID functions.
- */
+//
+// IEEE-1284 support functions test program for OpenPrinting CUPS Filters.
+//
+// Copyright 2007-2011 by Apple Inc.
+// Copyright 1997-2006 by Easy Software Products, all rights reserved.
+//
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "COPYING"
+// which should have been included with this file.
+//
+// Contents:
+//
+// main() - Test the device-ID functions.
+//
-/*
- * Include necessary headers.
- */
+//
+// Include necessary headers.
+//
#include <config.h>
#include <string.h>
#else
# include <unistd.h>
# include <fcntl.h>
-#endif /* WIN32 */
+#endif // WIN32
#include <cupsfilters/ieee1284.h>
-/*
- * 'main()' - Test the device-ID functions.
- */
+//
+// 'main()' - Test the device-ID functions.
+//
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line args */
- char *argv[]) /* I - Command-line arguments */
+int // O - Exit status
+main(int argc, // I - Number of command-line args
+ char *argv[]) // I - Command-line arguments
{
- int i, /* Looping var */
- fd; /* File descriptor */
- char device_id[1024], /* 1284 device ID string */
- make_model[1024], /* make-and-model string */
- uri[1024]; /* URI string */
+ int i, // Looping var
+ fd; // File descriptor
+ char device_id[1024], // 1284 device ID string
+ make_model[1024], // make-and-model string
+ uri[1024]; // URI string
if (argc < 2)
printf("%s:\n", argv[i]);
cfIEEE1284GetDeviceID(fd, device_id, sizeof(device_id), make_model,
- sizeof(make_model), "test", uri, sizeof(uri));
+ sizeof(make_model), "test", uri, sizeof(uri));
printf(" device_id=\"%s\"\n", device_id);
printf(" make_model=\"%s\"\n", make_model);
-/*
- * Test the CMYK color separation code for CUPS.
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1993-2006 by Easy Software Products, All Rights Reserved.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "COPYING"
- * which should have been included with this file.
- *
- * Contents:
- *
- * test_gray() - Test grayscale separations...
- * test_rgb() - Test color separations...
- * main() - Do color separation tests.
- */
-
-/*
- * Include necessary headers.
- */
+//
+// Test the CMYK color separation code for libcupsfilters.
+//
+// Copyright 2007-2011 by Apple Inc.
+// Copyright 1993-2006 by Easy Software Products, All Rights Reserved.
+//
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "COPYING"
+// which should have been included with this file.
+//
+// Contents:
+//
+// test_gray() - Test grayscale separations...
+// test_rgb() - Test color separations...
+// main() - Do color separation tests.
+
+
+//
+// Include necessary headers.
+
#include <config.h>
#include <string.h>
#include "driver.h"
#include <sys/stat.h>
-cf_logfunc_t logfunc = cfCUPSLogFunc; /* Log function */
-void *ld = NULL; /* Log function data */
+cf_logfunc_t logfunc = cfCUPSLogFunc; // Log function
+void *ld = NULL; // Log function data
void test_gray(int num_comps, const char *basename);
void test_rgb(int num_comps, const char *basename);
-/*
- * 'main()' - Do color separation tests.
- */
+//
+// 'main()' - Do color separation tests.
+//
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
{
- /*
- * Make the test directory...
- */
+ //
+ // Make the test directory...
+ //
mkdir("test", 0755);
- /*
- * Run tests for K, Kk, CMY, CMYK, CcMmYK, and CcMmYKk separations...
- */
+ //
+ // Run tests for K, Kk, CMY, CMYK, CcMmYK, and CcMmYKk separations...
+ //
test_rgb(1, "test/K-rgb");
test_rgb(2, "test/Kk-rgb");
test_gray(6, "test/CcMmYK-gray");
test_gray(7, "test/CcMmYKk-gray");
- /*
- * Return with no errors...
- */
+ //
+ // Return with no errors...
+ //
return (0);
}
-/*
- * 'test_gray()' - Test grayscale separations...
- */
+//
+// 'test_gray()' - Test grayscale separations...
+//
void
-test_gray(int num_comps, /* I - Number of components */
- const char *basename) /* I - Base filename of output */
+test_gray(int num_comps, // I - Number of components
+ const char *basename) // I - Base filename of output
{
- int i; /* Looping var */
- char filename[255]; /* Output filename */
- char line[255]; /* Line from PGM file */
- int width, height; /* Width and height of test image */
- int x, y; /* Current coordinate in image */
- int r, g, b; /* Current RGB color */
- unsigned char input[7000]; /* Line to separate */
- short output[48000], /* Output separation data */
- *outptr; /* Pointer in output */
- FILE *in; /* Input PPM file */
+ int i; // Looping var
+ char filename[255]; // Output filename
+ char line[255]; // Line from PGM file
+ int width, height; // Width and height of test image
+ int x, y; // Current coordinate in image
+ int r, g, b; // Current RGB color
+ unsigned char input[7000]; // Line to separate
+ short output[48000], // Output separation data
+ *outptr; // Pointer in output
+ FILE *in; // Input PPM file
FILE *out[CF_MAX_CHAN];
- /* Output PGM files */
- FILE *comp; /* Composite output */
- cf_cmyk_t *cmyk; /* Color separation */
+ // Output PGM files
+ FILE *comp; // Composite output
+ cf_cmyk_t *cmyk; // Color separation
- /*
- * Open the test image...
- */
+ //
+ // Open the test image...
+ //
in = fopen("image.pgm", "rb");
while (fgets(line, sizeof(line), in) != NULL)
sscanf(line, "%d%d", &width, &height);
- fgets(line, sizeof(line), in);
+ if (fgets(line, sizeof(line), in)); // Ignore return value of fgets()
- /*
- * Create the color separation...
- */
+ //
+ // Create the color separation...
+ //
cmyk = cfCMYKNew(num_comps);
switch (num_comps)
{
- case 2 : /* Kk */
+ case 2 : // Kk
cfCMYKSetLtDk(cmyk, 0, 0.5, 1.0, logfunc, ld);
break;
cfCMYKSetBlack(cmyk, 0.5, 1.0, logfunc, ld);
break;
- case 6 : /* CcMmYK */
+ case 6 : // CcMmYK
cfCMYKSetLtDk(cmyk, 0, 0.5, 1.0, logfunc, ld);
cfCMYKSetLtDk(cmyk, 2, 0.5, 1.0, logfunc, ld);
cfCMYKSetGamma(cmyk, 4, 1.0, 0.9, logfunc, ld);
cfCMYKSetBlack(cmyk, 0.5, 1.0, logfunc, ld);
break;
- case 7 : /* CcMmYKk */
+ case 7 : // CcMmYKk
cfCMYKSetLtDk(cmyk, 0, 0.5, 1.0, logfunc, ld);
cfCMYKSetLtDk(cmyk, 2, 0.5, 1.0, logfunc, ld);
cfCMYKSetGamma(cmyk, 4, 1.0, 0.9, logfunc, ld);
break;
}
- /*
- * Open the color separation files...
- */
+ //
+ // Open the color separation files...
+ //
for (i = 0; i < num_comps; i ++)
{
fprintf(comp, "P6\n%d %d 255\n", width, height);
- /*
- * Read the image and do the separations...
- */
+ //
+ // Read the image and do the separations...
+ //
for (y = 0; y < height; y ++)
{
- fread(input, width, 1, in);
+ if (fread(input, width, 1, in)); // Ignore return value of fread()
cfCMYKDoGray(cmyk, input, output, width);
}
-/*
- * 'test_rgb()' - Test color separations...
- */
+//
+// 'test_rgb()' - Test color separations...
+//
void
-test_rgb(int num_comps, /* I - Number of components */
- const char *basename) /* I - Base filename of output */
+test_rgb(int num_comps, // I - Number of components
+ const char *basename) // I - Base filename of output
{
- int i; /* Looping var */
- char filename[255]; /* Output filename */
- char line[255]; /* Line from PPM file */
- int width, height; /* Width and height of test image */
- int x, y; /* Current coordinate in image */
- int r, g, b; /* Current RGB color */
- unsigned char input[7000]; /* Line to separate */
- short output[48000], /* Output separation data */
- *outptr; /* Pointer in output */
- FILE *in; /* Input PPM file */
+ int i; // Looping var
+ char filename[255]; // Output filename
+ char line[255]; // Line from PPM file
+ int width, height; // Width and height of test image
+ int x, y; // Current coordinate in image
+ int r, g, b; // Current RGB color
+ unsigned char input[7000]; // Line to separate
+ short output[48000], // Output separation data
+ *outptr; // Pointer in output
+ FILE *in; // Input PPM file
FILE *out[CF_MAX_CHAN];
- /* Output PGM files */
- FILE *comp; /* Composite output */
- cf_cmyk_t *cmyk; /* Color separation */
+ // Output PGM files
+ FILE *comp; // Composite output
+ cf_cmyk_t *cmyk; // Color separation
- /*
- * Open the test image...
- */
+ //
+ // Open the test image...
+ //
in = fopen("image.ppm", "rb");
while (fgets(line, sizeof(line), in) != NULL)
sscanf(line, "%d%d", &width, &height);
- fgets(line, sizeof(line), in);
+ if (fgets(line, sizeof(line), in)); // Ignore return value of fgets()
- /*
- * Create the color separation...
- */
+ //
+ // Create the color separation...
+ //
cmyk = cfCMYKNew(num_comps);
switch (num_comps)
{
- case 2 : /* Kk */
+ case 2 : // Kk
cfCMYKSetLtDk(cmyk, 0, 0.5, 1.0, logfunc, ld);
break;
- case 6 : /* CcMmYK */
+ case 6 : // CcMmYK
cfCMYKSetGamma(cmyk, 0, 1.0, 0.8, logfunc, ld);
cfCMYKSetLtDk(cmyk, 0, 0.5, 1.0, logfunc, ld);
cfCMYKSetGamma(cmyk, 2, 1.0, 0.8, logfunc, ld);
cfCMYKSetLtDk(cmyk, 2, 0.5, 1.0, logfunc, ld);
break;
- case 7 : /* CcMmYKk */
+ case 7 : // CcMmYKk
cfCMYKSetGamma(cmyk, 0, 1.0, 0.8, logfunc, ld);
cfCMYKSetLtDk(cmyk, 0, 0.5, 1.0, logfunc, ld);
cfCMYKSetGamma(cmyk, 2, 1.0, 0.8, logfunc, ld);
break;
}
- /*
- * Open the color separation files...
- */
+ //
+ // Open the color separation files...
+ //
for (i = 0; i < num_comps; i ++)
{
fprintf(comp, "P6\n%d %d 255\n", width, height);
- /*
- * Read the image and do the separations...
- */
+ //
+ // Read the image and do the separations...
+ //
for (y = 0; y < height; y ++)
{
- fread(input, width, 3, in);
+ if (fread(input, width, 3, in)); // Ignore return value of fread()
cfCMYKDoRGB(cmyk, input, output, width);
cfCMYKDelete(cmyk);
}
-
-/*
- * Dither test program for CUPS.
- *
- * Try the following:
- *
- * testdither 0 255 > filename.ppm
- * testdither 0 127 255 > filename.ppm
- * testdither 0 85 170 255 > filename.ppm
- * testdither 0 63 127 170 198 227 255 > filename.ppm
- * testdither 0 210 383 > filename.ppm
- * testdither 0 82 255 > filename.ppm
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1993-2005 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "COPYING"
- * which should have been included with this file.
- *
- * Contents:
- *
- * main() - Test dithering and output a PPM file.
- * usage() - Show program usage...
- */
-
-/*
- * Include necessary headers.
- */
+//
+// Dither test program for libcupsfilters.
+//
+// Try the following:
+//
+// testdither 0 255 > filename.ppm
+// testdither 0 127 255 > filename.ppm
+// testdither 0 85 170 255 > filename.ppm
+// testdither 0 63 127 170 198 227 255 > filename.ppm
+// testdither 0 210 383 > filename.ppm
+// testdither 0 82 255 > filename.ppm
+//
+// Copyright 2007-2011 by Apple Inc.
+// Copyright 1993-2005 by Easy Software Products.
+//
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "COPYING"
+// which should have been included with this file.
+//
+// Contents:
+//
+// main() - Test dithering and output a PPM file.
+// usage() - Show program usage...
+//
+
+//
+// Include necessary headers.
+//
#include "driver.h"
#include <config.h>
#include <string.h>
#include <ctype.h>
-cf_logfunc_t logfunc = cfCUPSLogFunc; /* Log function */
-void *ld = NULL; /* Log function data */
+cf_logfunc_t logfunc = cfCUPSLogFunc; // Log function
+void *ld = NULL; // Log function data
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
void usage(void);
-/*
- * 'main()' - Test dithering and output a PPM file.
- */
+//
+// 'main()' - Test dithering and output a PPM file.
+//
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
{
- int x, y; /* Current coordinate in image */
- short line[512]; /* Line to dither */
- unsigned char pixels[512], /* Dither pixels */
- *pixptr; /* Pointer in line */
- int output; /* Output pixel */
- cf_lut_t *lut; /* Dither lookup table */
- cf_dither_t *dither; /* Dither state */
- int nlutvals; /* Number of lookup values */
- float lutvals[16]; /* Lookup values */
- int pixvals[16]; /* Pixel values */
-
-
- /*
- * See if we have lookup table values on the command-line...
- */
+ int x, y; // Current coordinate in image
+ short line[512]; // Line to dither
+ unsigned char pixels[512], // Dither pixels
+ *pixptr; // Pointer in line
+ int output; // Output pixel
+ cf_lut_t *lut; // Dither lookup table
+ cf_dither_t *dither; // Dither state
+ int nlutvals; // Number of lookup values
+ float lutvals[16]; // Lookup values
+ int pixvals[16]; // Pixel values
+
+
+ //
+ // See if we have lookup table values on the command-line...
+ //
if (argc > 1)
{
- /*
- * Yes, collect them...
- */
+ //
+ // Yes, collect them...
+ //
nlutvals = 0;
else
usage();
- /*
- * See if we have at least 2 values...
- */
+ //
+ // See if we have at least 2 values...
+ //
if (nlutvals < 2)
usage();
}
else
{
- /*
- * Otherwise use the default 2-entry LUT with values of 0 and 255...
- */
+ //
+ // Otherwise use the default 2-entry LUT with values of 0 and 255...
+ //
nlutvals = 2;
lutvals[0] = 0.0;
pixvals[1] = 255;
}
- /*
- * Create the lookup table and dither state...
- */
+ //
+ // Create the lookup table and dither state...
+ //
lut = cfLutNew(nlutvals, lutvals, logfunc, ld);
dither = cfDitherNew(512);
- /*
- * Put out the PGM header for a raw 256x256x8-bit grayscale file...
- */
+ //
+ // Put out the PGM header for a raw 256x256x8-bit grayscale file...
+ //
puts("P5\n512\n512\n255");
- /*
- * Dither 512 lines, which are written out in 256 image lines...
- */
+ //
+ // Dither 512 lines, which are written out in 256 image lines...
+ //
for (y = 0; y < 512; y ++)
{
- /*
- * Create the grayscale data for the current line...
- */
+ //
+ // Create the grayscale data for the current line...
+ //
for (x = 0; x < 512; x ++)
line[x] = 4095 * ((y / 32) * 16 + x / 32) / 255;
- /*
- * Dither the line...
- */
+ //
+ // Dither the line...
+ //
cfDitherLine(dither, lut, line, 1, pixels);
fputs("\n", stderr);
}
- /*
- * Add or set the output pixel values...
- */
+ //
+ // Add or set the output pixel values...
+ //
for (x = 0, pixptr = pixels; x < 512; x ++, pixptr ++)
{
}
}
- /*
- * Free the dither state and lookup table...
- */
+ //
+ // Free the dither state and lookup table...
+ //
cfDitherDelete(dither);
cfLutDelete(lut);
- /*
- * Return with no errors...
- */
+ //
+ // Return with no errors...
+ //
return (0);
}
-/*
- * 'usage()' - Show program usage...
- */
+//
+// 'usage()' - Show program usage...
+//
void
usage(void)
puts("Usage: testdither [val1 val2 [... val16]] >filename.ppm");
exit(1);
}
-
-/*
- * Image library test program for CUPS.
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1993-2006 by Easy Software Products.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "COPYING"
- * which should have been included with this file.
- *
- * Contents:
- *
- * main() - Main entry...
- */
-
-/*
- * Include necessary headers...
- */
+//
+// Image library test program for libcupsfilters.
+//
+// Copyright 2007-2011 by Apple Inc.
+// Copyright 1993-2006 by Easy Software Products.
+//
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "COPYING"
+// which should have been included with this file.
+//
+// Contents:
+//
+// main() - Main entry...
+//
+
+//
+// Include necessary headers...
+//
#include "image.h"
-/*
- * 'main()' - Main entry...
- */
+//
+// 'main()' - Main entry...
+//
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
{
- cf_image_t *img; /* Image to print */
- cf_icspace_t primary; /* Primary image colorspace */
- FILE *out; /* Output PPM/PGM file */
- cf_ib_t *line; /* Line from file */
- int y, /* Current line */
- width, /* Width of image */
- height, /* Height of image */
- depth; /* Depth of image */
+ cf_image_t *img; // Image to print
+ cf_icspace_t primary; // Primary image colorspace
+ FILE *out; // Output PPM/PGM file
+ cf_ib_t *line; // Line from file
+ int y, // Current line
+ width, // Width of image
+ height, // Height of image
+ depth; // Depth of image
if (argc != 3)
return (0);
}
-
-/*
- * Test the new RGB color separation code for CUPS.
- *
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1993-2006 by Easy Software Products, All Rights Reserved.
- *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "COPYING"
- * which should have been included with this file.
- *
- * Contents:
- *
- * main() - Do color rgb tests.
- * test_gray() - Test grayscale rgbs...
- * test_rgb() - Test color rgbs...
- */
-
-/*
- * Include necessary headers.
- */
+//
+// Test the new RGB color separation code for libcupsfilters.
+//
+// Copyright 2007-2011 by Apple Inc.
+// Copyright 1993-2006 by Easy Software Products, All Rights Reserved.
+//
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "COPYING"
+// which should have been included with this file.
+//
+// Contents:
+//
+// main() - Do color rgb tests.
+// test_gray() - Test grayscale rgbs...
+// test_rgb() - Test color rgbs...
+//
+
+//
+// Include necessary headers.
+//
#include <config.h>
#include <string.h>
#ifdef USE_LCMS1
# include <lcms.h>
-#endif /* USE_LCMS1 */
+#endif // USE_LCMS1
void test_gray(cf_sample_t *samples, int num_samples,
const char *basename);
-/*
- * 'main()' - Do color rgb tests.
- */
+//
+// 'main()' - Do color rgb tests.
+//
-int /* O - Exit status */
-main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
{
- static cf_sample_t CMYK[] = /* Basic 4-color sep */
+ static cf_sample_t CMYK[] = // Basic 4-color sep
{
- /*{ r, g, b }, { C, M, Y, K }*/
+ //{ r, g, b }, { C, M, Y, K }
{ { 0, 0, 0 }, { 0, 0, 0, 255 } },
{ { 255, 0, 0 }, { 0, 255, 240, 0 } },
{ { 0, 255, 0 }, { 200, 0, 200, 0 } },
};
- /*
- * Make the test directory...
- */
+ //
+ // Make the test directory...
+ //
mkdir("test", 0755);
- /*
- * Run tests for CMYK and CMYK separations...
- */
+ //
+ // Run tests for CMYK and CMYK separations...
+ //
test_rgb(CMYK, 8, 2, 4, "test/rgb-cmyk");
test_gray(CMYK, 8, 2, 4, "test/gray-cmyk");
- /*
- * Return with no errors...
- */
+ //
+ // Return with no errors...
+ //
return (0);
}
-/*
- * 'test_gray()' - Test grayscale rgbs...
- */
+//
+// 'test_gray()' - Test grayscale rgbs...
+//
void
-test_gray(cf_sample_t *samples, /* I - Sample values */
- int num_samples, /* I - Number of samples */
- int cube_size, /* I - Cube size */
- int num_comps, /* I - Number of components */
- const char *basename) /* I - Base filename of output */
+test_gray(cf_sample_t *samples, // I - Sample values
+ int num_samples, // I - Number of samples
+ int cube_size, // I - Cube size
+ int num_comps, // I - Number of components
+ const char *basename) // I - Base filename of output
{
- int i; /* Looping var */
- char filename[255]; /* Output filename */
- char line[255]; /* Line from PPM file */
- int width, height; /* Width and height of test image */
- int x, y; /* Current coordinate in image */
- int r, g, b; /* Current RGB color */
- unsigned char input[7000]; /* Line to rgbarate */
- unsigned char output[48000], /* Output rgb data */
- *outptr; /* Pointer in output */
- FILE *in; /* Input PPM file */
+ int i; // Looping var
+ char filename[255]; // Output filename
+ char line[255]; // Line from PPM file
+ int width, height; // Width and height of test image
+ int x, y; // Current coordinate in image
+ int r, g, b; // Current RGB color
+ unsigned char input[7000]; // Line to rgbarate
+ unsigned char output[48000], // Output rgb data
+ *outptr; // Pointer in output
+ FILE *in; // Input PPM file
FILE *out[CF_MAX_CHAN];
- /* Output PGM files */
- FILE *comp; /* Composite output */
- cf_rgb_t *rgb; /* Color separation */
+ // Output PGM files
+ FILE *comp; // Composite output
+ cf_rgb_t *rgb; // Color separation
- /*
- * Open the test image...
- */
+ //
+ // Open the test image...
+ //
in = fopen("image.pgm", "rb");
while (fgets(line, sizeof(line), in) != NULL)
sscanf(line, "%d%d", &width, &height);
- fgets(line, sizeof(line), in);
+ if (fgets(line, sizeof(line), in)); // Ignore return value of fgets()
- /*
- * Create the color rgb...
- */
+ //
+ // Create the color rgb...
+ //
rgb = cfRGBNew(num_samples, samples, cube_size, num_comps);
- /*
- * Open the color rgb files...
- */
+ //
+ // Open the color rgb files...
+ //
for (i = 0; i < num_comps; i ++)
{
fprintf(comp, "P6\n%d %d 255\n", width, height);
- /*
- * Read the image and do the rgbs...
- */
+ //
+ // Read the image and do the rgbs...
+ //
for (y = 0; y < height; y ++)
{
- fread(input, width, 1, in);
+ if (fread(input, width, 1, in)); // Ignore return value of fread()
cfRGBDoGray(rgb, input, output, width);
}
-/*
- * 'test_rgb()' - Test color rgbs...
- */
+//
+// 'test_rgb()' - Test color rgbs...
+//
void
-test_rgb(cf_sample_t *samples, /* I - Sample values */
- int num_samples, /* I - Number of samples */
- int cube_size, /* I - Cube size */
- int num_comps, /* I - Number of components */
- const char *basename) /* I - Base filename of output */
+test_rgb(cf_sample_t *samples, // I - Sample values
+ int num_samples, // I - Number of samples
+ int cube_size, // I - Cube size
+ int num_comps, // I - Number of components
+ const char *basename) // I - Base filename of output
{
- int i; /* Looping var */
- char filename[255]; /* Output filename */
- char line[255]; /* Line from PPM file */
- int width, height; /* Width and height of test image */
- int x, y; /* Current coordinate in image */
- int r, g, b; /* Current RGB color */
- unsigned char input[7000]; /* Line to rgbarate */
- unsigned char output[48000], /* Output rgb data */
- *outptr; /* Pointer in output */
- FILE *in; /* Input PPM file */
+ int i; // Looping var
+ char filename[255]; // Output filename
+ char line[255]; // Line from PPM file
+ int width, height; // Width and height of test image
+ int x, y; // Current coordinate in image
+ int r, g, b; // Current RGB color
+ unsigned char input[7000]; // Line to rgbarate
+ unsigned char output[48000], // Output rgb data
+ *outptr; // Pointer in output
+ FILE *in; // Input PPM file
FILE *out[CF_MAX_CHAN];
- /* Output PGM files */
- FILE *comp; /* Composite output */
- cf_rgb_t *rgb; /* Color separation */
+ // Output PGM files
+ FILE *comp; // Composite output
+ cf_rgb_t *rgb; // Color separation
- /*
- * Open the test image...
- */
+ //
+ // Open the test image...
+ //
in = fopen("image.ppm", "rb");
while (fgets(line, sizeof(line), in) != NULL)
sscanf(line, "%d%d", &width, &height);
- fgets(line, sizeof(line), in);
+ if (fgets(line, sizeof(line), in)); // Ignore return value of fgets()
- /*
- * Create the color rgb...
- */
+ //
+ // Create the color rgb...
+ //
rgb = cfRGBNew(num_samples, samples, cube_size, num_comps);
- /*
- * Open the color rgb files...
- */
+ //
+ // Open the color rgb files...
+ //
for (i = 0; i < num_comps; i ++)
{
fprintf(comp, "P6\n%d %d 255\n", width, height);
- /*
- * Read the image and do the rgbs...
- */
+ //
+ // Read the image and do the rgbs...
+ //
for (y = 0; y < height; y ++)
{
- fread(input, width, 3, in);
+ if (fread(input, width, 3, in)); // Ignore return value of fread()
cfRGBDoRGB(rgb, input, output, width);
cfRGBDelete(rgb);
}
-