aboutsummaryrefslogtreecommitdiffstats
path: root/src/cnki_pdf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cnki_pdf.c')
-rw-r--r--src/cnki_pdf.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/cnki_pdf.c b/src/cnki_pdf.c
index 0cb30ca..887e5f4 100644
--- a/src/cnki_pdf.c
+++ b/src/cnki_pdf.c
@@ -11,6 +11,7 @@
#include "iconv.h"
#include "zlib.h"
#include "jpeg.h"
+#include "jp2.h"
#include "pdf.h"
#include "pdf_cnki.h"
@@ -660,6 +661,41 @@ cnki_pdf_hn(cnki_t **param)
dim[i * 2 + 1] = info[1];
break;
case JPX:
+ ret = strinfo_jp2_dim(&info[0],
+ &info[1],
+ ptr->image_data[i].image,
+ ptr->image_data[i].size);
+
+ if (ret != 0) {
+ dim[i * 2] = 0;
+ dim[i * 2 + 1] = 0;
+ break;
+ }
+
+ stream_size = ptr->image_data[i].size;
+ stream = malloc(stream_size);
+ if (stream == NULL) {
+ free(root_kid);
+ free(ids);
+ free(dim);
+ free(dictionary);
+ return 1;
+ }
+ memcpy(stream, ptr->image_data[i].image, stream_size);
+
+ snprintf(buf, 64, "/Width %d\n/Height %d\n",
+ info[0], info[1]);
+ strcat(dictionary, buf);
+
+ snprintf(buf, 64, "/Length %d\n",
+ stream_size);
+ strcat(dictionary, buf);
+
+ strcat(dictionary, "/Filter /JPXDecode\n");
+
+ dim[i * 2] = info[0];
+ dim[i * 2 + 1] = info[1];
+ break;
default:
ret = -1;
dim[i * 2] = -1;