@@ -57,6 +57,7 @@ This file is part of the iText (R) project.
57
57
import org .junit .Test ;
58
58
import org .junit .experimental .categories .Category ;
59
59
60
+ import java .io .FileNotFoundException ;
60
61
import java .io .IOException ;
61
62
62
63
@ Category (IntegrationTest .class )
@@ -71,7 +72,6 @@ public static void beforeClass() {
71
72
72
73
@ Test
73
74
public void imagesWithDifferentDepth () throws IOException , InterruptedException {
74
- //TODO: update after DEVSIX-1934 ticket will be fixed
75
75
String outFileName = destinationFolder + "transparencyTest01.pdf" ;
76
76
String cmpFileName = sourceFolder + "cmp_transparencyTest01.pdf" ;
77
77
PdfDocument pdfDocument = new PdfDocument (new PdfWriter (outFileName , new WriterProperties ()
@@ -148,4 +148,78 @@ public void imagesWithDifferentDepth() throws IOException, InterruptedException
148
148
149
149
Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff_" ));
150
150
}
151
+
152
+ @ Test
153
+ public void png_imageTransparancy_8bitDepthImage () throws IOException , InterruptedException {
154
+ String outFileName = destinationFolder + "png_imageTransparancy_8bitDepthImage.pdf" ;
155
+ String cmpFileName = sourceFolder + "cmp_png_imageTransparancy_8bitDepthImage.pdf" ;
156
+ PdfDocument pdfDocument = new PdfDocument (new PdfWriter (outFileName , new WriterProperties ()
157
+ .setCompressionLevel (CompressionConstants .NO_COMPRESSION )));
158
+ PdfPage page = pdfDocument .addNewPage (PageSize .A4 );
159
+ PdfCanvas canvas = new PdfCanvas (page );
160
+ canvas .setFillColor (ColorConstants .LIGHT_GRAY ).fill ();
161
+ canvas .rectangle (80 , 0 , PageSize .A4 .getWidth ()-80 , PageSize .A4 .getHeight ()).fill ();
162
+
163
+ canvas
164
+ .saveState ()
165
+ .beginText ()
166
+ .moveText (116 , 800 )
167
+ .setFontAndSize (PdfFontFactory .createFont (StandardFonts .HELVETICA ), 14 )
168
+ .setFillColor (ColorConstants .MAGENTA )
169
+ .showText ("8 bit depth PNG" )
170
+ .moveText (0 ,-20 )
171
+ .showText ("This image should not have a black rectangle as background" )
172
+ .endText ()
173
+ .restoreState ();
174
+ ImageData img = ImageDataFactory .create (sourceFolder + "manualTransparency_8bit.png" );
175
+ canvas .addImage (img , 100 , 450 , 200 , false );
176
+
177
+ canvas .release ();
178
+ pdfDocument .close ();
179
+
180
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff_" ));
181
+ }
182
+
183
+ @ Test
184
+ public void png_imageTransparancy_24bitDepthImage () throws IOException , InterruptedException {
185
+ String outFileName = destinationFolder + "png_imageTransparancy_24bitDepthImage.pdf" ;
186
+ String cmpFileName = sourceFolder + "cmp_png_imageTransparancy_24bitDepthImage.pdf" ;
187
+ PdfDocument pdfDocument = new PdfDocument (new PdfWriter (outFileName , new WriterProperties ()
188
+ .setCompressionLevel (CompressionConstants .NO_COMPRESSION )));
189
+ PdfPage page = pdfDocument .addNewPage (PageSize .A4 );
190
+ PdfCanvas canvas = new PdfCanvas (page );
191
+ canvas .setFillColor (ColorConstants .LIGHT_GRAY ).fill ();
192
+ canvas .rectangle (80 , 0 , PageSize .A4 .getWidth ()-80 , PageSize .A4 .getHeight ()).fill ();
193
+
194
+ canvas
195
+ .saveState ()
196
+ .beginText ()
197
+ .moveText (116 , 800 )
198
+ .setFontAndSize (PdfFontFactory .createFont (StandardFonts .HELVETICA ), 14 )
199
+ .setFillColor (ColorConstants .MAGENTA )
200
+ .showText ("24 bit depth PNG" )
201
+ .moveText (0 ,-20 )
202
+ .showText ("This image should not have a white rectangle as background" )
203
+ .endText ()
204
+ .restoreState ();
205
+ ImageData img = ImageDataFactory .create (sourceFolder + "manualTransparency_24bit.png" );
206
+ canvas .addImage (img , 100 , 450 , 200 , false );
207
+
208
+ canvas
209
+ .saveState ()
210
+ .beginText ()
211
+ .moveText (116 , 400 )
212
+ .setFontAndSize (PdfFontFactory .createFont (StandardFonts .HELVETICA ), 14 )
213
+ .setFillColor (ColorConstants .MAGENTA )
214
+ .showText ("32 bit depth PNG" )
215
+ .endText ()
216
+ .restoreState ();
217
+ img = ImageDataFactory .create (sourceFolder + "manualTransparency_32bit.png" );
218
+ canvas .addImage (img , 116 , 100 , 200 , false );
219
+
220
+ canvas .release ();
221
+ pdfDocument .close ();
222
+
223
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder , "diff_" ));
224
+ }
151
225
}
0 commit comments