View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.imaging.formats.psd;
18  
19  import java.io.IOException;
20  import java.io.PrintWriter;
21  import java.io.StringWriter;
22  import java.util.logging.Level;
23  import java.util.logging.Logger;
24  
25  public class PsdImageContents {
26  
27      private static final Logger LOGGER = Logger.getLogger(PsdImageContents.class.getName());
28  
29      public final PsdHeaderInfo header;
30  
31      public final int colorModeDataLength;
32      public final int imageResourcesLength;
33      public final int layerAndMaskDataLength;
34      public final int compression;
35  
36      public PsdImageContents(final PsdHeaderInfo header,
37  
38              final int colorModeDataLength, final int imageResourcesLength, final int layerAndMaskDataLength, final int compression) {
39          this.header = header;
40          this.colorModeDataLength = colorModeDataLength;
41          this.imageResourcesLength = imageResourcesLength;
42          this.layerAndMaskDataLength = layerAndMaskDataLength;
43          this.compression = compression;
44      }
45  
46      public void dump() {
47          try (StringWriter sw = new StringWriter();
48                  PrintWriter pw = new PrintWriter(sw)) {
49              dump(pw);
50              pw.flush();
51              sw.flush();
52              LOGGER.fine(sw.toString());
53          } catch (final IOException e) {
54              LOGGER.log(Level.SEVERE, e.getMessage(), e);
55          }
56      }
57  
58      public void dump(final PrintWriter pw) {
59          pw.println("");
60          pw.println("ImageContents");
61          pw.println("Compression: " + compression + " (" + Integer.toHexString(compression) + ")");
62          pw.println("ColorModeDataLength: " + colorModeDataLength + " (" + Integer.toHexString(colorModeDataLength) + ")");
63          pw.println("ImageResourcesLength: " + imageResourcesLength + " (" + Integer.toHexString(imageResourcesLength) + ")");
64          pw.println("LayerAndMaskDataLength: " + layerAndMaskDataLength + " (" + Integer.toHexString(layerAndMaskDataLength) + ")");
65          // System.out.println("Depth: " + Depth + " ("
66          // + Integer.toHexString(Depth) + ")");
67          // System.out.println("Mode: " + Mode + " (" + Integer.toHexString(Mode)
68          // + ")");
69          // System.out.println("Reserved: " + Reserved.length);
70          pw.println("");
71          pw.flush();
72  
73      }
74  
75  }