    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,
    039            final int LayerAndMaskDataLength, final int Compression) {
    040        this.header = header;
    041        this.ColorModeDataLength = ColorModeDataLength;
    042        this.ImageResourcesLength = ImageResourcesLength;
    043        this.LayerAndMaskDataLength = LayerAndMaskDataLength;
    044        this.Compression = Compression;
    045    }
    046
    047    public void dump() {
    048        try (StringWriter sw = new StringWriter(); 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 + " ("
    062                + Integer.toHexString(Compression) + ")");
    063        pw.println("ColorModeDataLength: " + ColorModeDataLength + " ("
    064                + Integer.toHexString(ColorModeDataLength) + ")");
    065        pw.println("ImageResourcesLength: " + ImageResourcesLength + " ("
    066                + Integer.toHexString(ImageResourcesLength) + ")");
    067        pw.println("LayerAndMaskDataLength: " + LayerAndMaskDataLength + " ("
    068                + Integer.toHexString(LayerAndMaskDataLength) + ")");
    069        // System.out.println("Depth: " + Depth + " ("
    070        // + Integer.toHexString(Depth) + ")");
    071        // System.out.println("Mode: " + Mode + " (" + Integer.toHexString(Mode)
    072        // + ")");
    073        // System.out.println("Reserved: " + Reserved.length);
    074        pw.println("");
    075        pw.flush();
    076
    077    }
    078
    079}