    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.imaging.formats.psd;
    018
    019import java.io.IOException;
    020import java.io.PrintWriter;
    021import java.io.StringWriter;
    022import java.util.logging.Level;
    023import java.util.logging.Logger;
    024
    025public class PsdImageContents {
    026
    027    private static final Logger LOGGER = Logger.getLogger(PsdImageContents.class.getName());
    028
    029    public final PsdHeaderInfo header;
    030
    031    public final int colorModeDataLength;
    032    public final int imageResourcesLength;
    033    public final int layerAndMaskDataLength;
    034    public final int compression;
    035
    036    public PsdImageContents(final PsdHeaderInfo header,
    037
    038            final int colorModeDataLength, final int imageResourcesLength, final int layerAndMaskDataLength, final int compression) {
    039        this.header = header;
    040        this.colorModeDataLength = colorModeDataLength;
    041        this.imageResourcesLength = imageResourcesLength;
    042        this.layerAndMaskDataLength = layerAndMaskDataLength;
    043        this.compression = compression;
    044    }
    045
    046    public void dump() {
    047        try (StringWriter sw = new StringWriter();
    048                PrintWriter pw = new PrintWriter(sw)) {
    049            dump(pw);
    050            pw.flush();
    051            sw.flush();
    052            LOGGER.fine(sw.toString());
    053        } catch (final IOException e) {
    054            LOGGER.log(Level.SEVERE, e.getMessage(), e);
    055        }
    056    }
    057
    058    public void dump(final PrintWriter pw) {
    059        pw.println("");
    060        pw.println("ImageContents");
    061        pw.println("Compression: " + compression + " (" + Integer.toHexString(compression) + ")");
    062        pw.println("ColorModeDataLength: " + colorModeDataLength + " (" + Integer.toHexString(colorModeDataLength) + ")");
    063        pw.println("ImageResourcesLength: " + imageResourcesLength + " (" + Integer.toHexString(imageResourcesLength) + ")");
    064        pw.println("LayerAndMaskDataLength: " + layerAndMaskDataLength + " (" + Integer.toHexString(layerAndMaskDataLength) + ")");
    065        // System.out.println("Depth: " + Depth + " ("
    066        // + Integer.toHexString(Depth) + ")");
    067        // System.out.println("Mode: " + Mode + " (" + Integer.toHexString(Mode)
    068        // + ")");
    069        // System.out.println("Reserved: " + Reserved.length);
    070        pw.println("");
    071        pw.flush();
    072
    073    }
    074
    075}