• R/O
  • SSH
  • HTTPS

copper: Commit


Commit MetaInfo

Revision1611 (tree)
Time2021-06-17 11:39:43
Authormiyabe

Log Message

(empty log message)

Change Summary

Incremental Difference

--- copper/trunk/homare/pom.xml (revision 1610)
+++ copper/trunk/homare/pom.xml (revision 1611)
@@ -9,7 +9,7 @@
99 <groupId>net.zamasoft</groupId>
1010 <artifactId>homare</artifactId>
1111 <packaging>jar</packaging>
12- <version>3.2.12</version>
12+ <version>3.2.13</version>
1313 <name>Homare</name>
1414 <description>印刷向けのHTML/CSSレンダリングエンジンです。</description>
1515 <url>https://copper.osdn.jp/homare/</url>
@@ -85,7 +85,7 @@
8585 <artifactId>qrcode</artifactId>
8686 <version>1.0</version>
8787 <scope>system</scope>
88- <systemPath>${basedir}/lib/Qrcode.jar</systemPath>
88+ <systemPath>/home/miyabe/workspaces/copper/copper/homare/lib/Qrcode.jar</systemPath>
8989 </dependency>
9090 <dependency>
9191 <groupId>de.rototor.jeuclid</groupId>
@@ -130,7 +130,7 @@
130130 <pluginExecutionFilter>
131131 <groupId>org.codehaus.mojo</groupId>
132132 <artifactId>native2ascii-maven-plugin</artifactId>
133- <versionRange>[0,)</versionRange>
133+ <versionRange>[2,)</versionRange>
134134 <goals>
135135 <goal>native2ascii</goal>
136136 </goals>
@@ -152,7 +152,7 @@
152152 <executions>
153153 <execution>
154154 <goals>
155- <goal>native2ascii</goal>
155+ <goal>resources</goal>
156156 </goals>
157157
158158 <configuration>
--- copper/trunk/homare/src/main/java/jp/cssj/homare/impl/ua/image/RasterImageLoader.java (revision 1610)
+++ copper/trunk/homare/src/main/java/jp/cssj/homare/impl/ua/image/RasterImageLoader.java (revision 1611)
@@ -1,11 +1,11 @@
11 package jp.cssj.homare.impl.ua.image;
22
3-import java.io.BufferedInputStream;
43 import java.io.IOException;
54 import java.util.Iterator;
65
76 import javax.imageio.ImageIO;
87 import javax.imageio.ImageReader;
8+import javax.imageio.ImageTypeSpecifier;
99 import javax.imageio.stream.FileCacheImageInputStream;
1010 import javax.imageio.stream.FileImageInputStream;
1111 import javax.imageio.stream.ImageInputStream;
@@ -22,19 +22,20 @@
2222 return true;
2323 }
2424
25+ @SuppressWarnings("resource")
2526 public boolean available(Source source) throws IOException {
2627 ImageInputStream imageIn;
2728 if (source.isFile()) {
2829 imageIn = new FileImageInputStream(source.getFile());
2930 } else {
30- imageIn = ImageIO.createImageInputStream(new BufferedInputStream(source.getInputStream()));
31+ imageIn = ImageIO.createImageInputStream(source.getInputStream());
3132 }
3233 try { // ImageIOによるラスタ画像の取得
33- Iterator<ImageReader> readers = ImageIO.getImageReaders(imageIn);
34- if (readers == null || !readers.hasNext()) {
35- return false;
34+ Iterator<ImageReader> iri = ImageIO.getImageReaders(imageIn);
35+ if (iri != null && iri.hasNext()) {
36+ return true;
3637 }
37- return true;
38+ return false;
3839 } finally {
3940 imageIn.close();
4041 }
@@ -48,13 +49,23 @@
4849 imageIn = new FileCacheImageInputStream(source.getInputStream(), null);
4950 }
5051 try { // ImageIOによるラスタ画像の取得
51- Iterator<ImageReader> readers = ImageIO.getImageReaders(imageIn);
52- if (readers == null || !readers.hasNext()) {
52+ Iterator<ImageReader> iri = ImageIO.getImageReaders(imageIn);
53+ ImageReader ir = null;
54+ while (iri != null && iri.hasNext()) {
55+ ir = iri.next();
56+ ir.setInput(imageIn);
57+ Iterator<ImageTypeSpecifier> iti = ir.getImageTypes(0);
58+ if (iti != null && iti.hasNext()) {
59+ break;
60+ }
61+ ir.dispose();
62+ ir = null;
63+ }
64+ if (ir == null) {
5365 throw new IOException("ImageIOがサポートしない画像形式です");
5466 }
55- ImageReader reader = (ImageReader) readers.next();
5667 imageIn.seek(0);
57- return new RasterImageImpl(G2dUtils.loadImage(reader, imageIn));
68+ return new RasterImageImpl(G2dUtils.loadImage(ir, imageIn));
5869 } finally {
5970 imageIn.close();
6071 }
--- copper/trunk/sakae/sakae-pdf/pom.xml (revision 1610)
+++ copper/trunk/sakae/sakae-pdf/pom.xml (revision 1611)
@@ -38,6 +38,11 @@
3838 <artifactId>xml-apis</artifactId>
3939 <version>1.4.01</version>
4040 </dependency>
41+ <dependency>
42+ <groupId>fr.sertelon.media</groupId>
43+ <artifactId>jpeg-cmyk</artifactId>
44+ <version>[1.1.0,)</version>
45+ </dependency>
4146 </dependencies>
4247
4348 <build>
--- copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/impl/ImageFlow.java (revision 1610)
+++ copper/trunk/sakae/sakae-pdf/src/main/java/jp/cssj/sakae/pdf/impl/ImageFlow.java (revision 1611)
@@ -26,6 +26,7 @@
2626 import javax.imageio.stream.FileImageInputStream;
2727 import javax.imageio.stream.ImageInputStream;
2828
29+import fr.sertelon.media.jpeg.CMYKJPEGImageReader;
2930 import jp.cssj.resolver.Source;
3031 import jp.cssj.sakae.g2d.util.G2dUtils;
3132 import jp.cssj.sakae.gc.image.Image;
@@ -60,6 +61,10 @@
6061
6162 private int imageNumber = 0;
6263
64+ private static final short DEVICE_GRAY = 1;
65+ private static final short DEVICE_RGB = 2;
66+ private static final short DEVICE_CMYK = 3;
67+
6368 public ImageFlow(Map<String, ObjectRef> nameToResourceRef, PdfFragmentOutputImpl objectsFlow, XRefImpl xref,
6469 PdfParams params) throws IOException {
6570 this.xref = xref;
@@ -105,12 +110,19 @@
105110 PdfImage pdfImage;
106111 ImageReader ir;
107112 if (imageIn != null) {
108- Iterator<?> i = ImageIO.getImageReaders(imageIn);
109- if (i != null && i.hasNext()) {
110- ir = (ImageReader) i.next();
111- ir.setInput(imageIn);
112- } else {
113- throw new IOException("画像ファイル内に読み込み可能な画像がありません:" + String.valueOf(i));
113+ Iterator<ImageReader> iri = ImageIO.getImageReaders(imageIn);
114+ for (;;) {
115+ if (iri != null && iri.hasNext()) {
116+ ir = iri.next();
117+ ir.setInput(imageIn);
118+ Iterator<ImageTypeSpecifier> iti = ir.getImageTypes(0);
119+ if (iti != null && iti.hasNext()) {
120+ break;
121+ }
122+ ir.dispose();
123+ } else {
124+ throw new IOException("画像ファイル内に読み込み可能な画像がありません:" + String.valueOf(iri));
125+ }
114126 }
115127 } else {
116128 ir = null;
@@ -303,20 +315,57 @@
303315 this.objectsFlow.writeInt(8);
304316 this.objectsFlow.breakBefore();
305317
306- boolean srcGray;
307- if (iccErrorHuck) {
308- srcGray = iccGray;
318+ final short deviceColor;
319+ if (iccErrorHuck && iccGray) {
320+ deviceColor = DEVICE_GRAY;
321+ } else if (ir instanceof CMYKJPEGImageReader) {
322+ deviceColor = DEVICE_CMYK;
309323 } else {
310324 Iterator<?> itr = ir.getImageTypes(0);
311325 ImageTypeSpecifier its = (ImageTypeSpecifier) itr.next();
312326 ColorModel cm = its.getColorModel();
313- srcGray = cm.getNumComponents() == 1;
327+ switch (cm.getNumComponents()) {
328+ case 1:
329+ deviceColor = DEVICE_GRAY;
330+ break;
331+ case 4:
332+ deviceColor = DEVICE_CMYK;
333+ break;
334+ default:
335+ deviceColor = DEVICE_RGB;
336+ break;
337+ }
314338 }
315339
316340 this.objectsFlow.writeName("ColorSpace");
317- this.objectsFlow.writeName(srcGray ? "DeviceGray" : "DeviceRGB");
341+ switch (deviceColor) {
342+ case DEVICE_GRAY:
343+ this.objectsFlow.writeName("DeviceGray");
344+ break;
345+ case DEVICE_CMYK:
346+ this.objectsFlow.writeName("DeviceCMYK");
347+ break;
348+ default:
349+ this.objectsFlow.writeName("DeviceRGB");
350+ break;
351+ }
318352 this.objectsFlow.breakBefore();
319353
354+ if (deviceColor == DEVICE_CMYK) {
355+ this.objectsFlow.writeName("Decode");
356+ this.objectsFlow.startArray();
357+ this.objectsFlow.writeInt(1);
358+ this.objectsFlow.writeInt(0);
359+ this.objectsFlow.writeInt(1);
360+ this.objectsFlow.writeInt(0);
361+ this.objectsFlow.writeInt(1);
362+ this.objectsFlow.writeInt(0);
363+ this.objectsFlow.writeInt(1);
364+ this.objectsFlow.writeInt(0);
365+ this.objectsFlow.endArray();
366+ this.objectsFlow.breakBefore();
367+ }
368+
320369 this.objectsFlow.writeName("Filter");
321370 this.objectsFlow.startArray();
322371 switch (streamCompression) {
Show on old repository browser