aboutsummaryrefslogtreecommitdiffstats
path: root/src/jpeg.c
diff options
context:
space:
mode:
authoryzrh <yzrh@noema.org>2020-12-31 22:36:28 +0000
committeryzrh <yzrh@noema.org>2021-01-03 03:01:28 +0000
commit1994f122cc29504862944cca1da1c5203c7e41eb (patch)
treed89e37c5f3443156116bd8476e0efc2d380acd55 /src/jpeg.c
parentb20c6ad3ed930977990f3812b25b80d2ce282d79 (diff)
downloadmelon-1994f122cc29504862944cca1da1c5203c7e41eb.tar.gz
melon-1994f122cc29504862944cca1da1c5203c7e41eb.tar.zst
Decode JBIG and JPEG during HN conversion.
Diffstat (limited to 'src/jpeg.c')
-rw-r--r--src/jpeg.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/jpeg.c b/src/jpeg.c
new file mode 100644
index 0000000..4ea4d7f
--- /dev/null
+++ b/src/jpeg.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2020-2021, yzrh <yzrh@noema.org>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <stdio.h>
+
+#include <jpeglib.h>
+
+int
+strinfo_jpeg_dim(int *jpeg_width, int *jpeg_height,
+ const char * restrict data, int data_size)
+{
+ struct jpeg_decompress_struct cinfo;
+ struct jpeg_error_mgr jerr;
+
+ cinfo.err = jpeg_std_error(&jerr);
+
+ jpeg_create_decompress(&cinfo);
+
+ jpeg_mem_src(&cinfo, (unsigned char *) data, data_size);
+
+ jpeg_read_header(&cinfo, TRUE);
+
+ jpeg_calc_output_dimensions(&cinfo);
+
+ *jpeg_width = cinfo.output_width;
+ *jpeg_height = cinfo.output_height;
+
+ jpeg_destroy((struct jpeg_common_struct *) &cinfo);
+
+ jpeg_destroy_decompress(&cinfo);
+
+ return 0;
+}