diff options
Diffstat (limited to 'libtests/dct_compress.cc')
-rw-r--r-- | libtests/dct_compress.cc | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/libtests/dct_compress.cc b/libtests/dct_compress.cc index 2a583ffd..446d4d0a 100644 --- a/libtests/dct_compress.cc +++ b/libtests/dct_compress.cc @@ -2,12 +2,13 @@ #include <qpdf/Pl_StdioFile.hh> #include <qpdf/QUtil.hh> -#include <stdio.h> -#include <string.h> #include <iostream> +#include <stdio.h> #include <stdlib.h> +#include <string.h> -static void usage() +static void +usage() { std::cerr << "Usage: dct_compress infile outfile width height" << " {rgb|cmyk|gray}" << std::endl; @@ -28,15 +29,16 @@ class Callback: public Pl_DCT::CompressConfig bool called; }; -void Callback::apply(jpeg_compress_struct*) +void +Callback::apply(jpeg_compress_struct*) { this->called = true; } -int main(int argc, char* argv[]) +int +main(int argc, char* argv[]) { - if (argc != 6) - { + if (argc != 6) { usage(); } @@ -46,23 +48,22 @@ int main(int argc, char* argv[]) JDIMENSION height = QUtil::string_to_uint(argv[4]); char* colorspace = argv[5]; J_COLOR_SPACE cs = - ((strcmp(colorspace, "rgb") == 0) ? JCS_RGB : - (strcmp(colorspace, "cmyk") == 0) ? JCS_CMYK : - (strcmp(colorspace, "gray") == 0) ? JCS_GRAYSCALE : - JCS_UNKNOWN); + ((strcmp(colorspace, "rgb") == 0) ? JCS_RGB + : (strcmp(colorspace, "cmyk") == 0) ? JCS_CMYK + : (strcmp(colorspace, "gray") == 0) ? JCS_GRAYSCALE + : JCS_UNKNOWN); int components = 0; - switch (cs) - { - case JCS_RGB: + switch (cs) { + case JCS_RGB: components = 3; break; - case JCS_CMYK: + case JCS_CMYK: components = 4; break; - case JCS_GRAYSCALE: + case JCS_GRAYSCALE: components = 1; break; - default: + default: usage(); break; } @@ -74,21 +75,16 @@ int main(int argc, char* argv[]) bool done = false; Callback callback; Pl_DCT dct("dct", &out, width, height, components, cs, &callback); - while (! done) - { + while (!done) { size_t len = fread(buf, 1, sizeof(buf), infile); - if (len <= 0) - { + if (len <= 0) { done = true; - } - else - { + } else { dct.write(buf, len); } } dct.finish(); - if (! callback.called) - { + if (!callback.called) { std::cout << "Callback was not called" << std::endl; } fclose(infile); |