aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/dct_compress.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-02 23:14:10 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-04 14:10:40 +0200
commit12f1eb15ca3fed6310402847559a7c99d3c77847 (patch)
tree8935675b623c6f3b4914b8b44f7fa5f2816a9241 /libtests/dct_compress.cc
parentf20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff)
downloadqpdf-12f1eb15ca3fed6310402847559a7c99d3c77847.tar.zst
Programmatically apply new formatting to code
Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done
Diffstat (limited to 'libtests/dct_compress.cc')
-rw-r--r--libtests/dct_compress.cc48
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);