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 PsdHeaderInfo { 026 027 private static final Logger LOGGER = Logger.getLogger(PsdHeaderInfo.class.getName()); 028 029 public final int version; 030 private final byte[] reserved; 031 public final int channels; 032 public final int rows; 033 public final int columns; 034 public final int depth; 035 public final int mode; 036 037 public PsdHeaderInfo(final int version, final byte[] reserved, final int channels, final int rows, final int columns, final int depth, final int mode) { 038 this.version = version; 039 this.reserved = reserved.clone(); 040 this.channels = channels; 041 this.rows = rows; 042 this.columns = columns; 043 this.depth = depth; 044 this.mode = mode; 045 046 } 047 048 public byte[] getReserved() { 049 return reserved.clone(); 050 } 051 052 public void dump() { 053 try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) { 054 dump(pw); 055 pw.flush(); 056 sw.flush(); 057 LOGGER.fine(sw.toString()); 058 } catch (final IOException e) { 059 LOGGER.log(Level.SEVERE, e.getMessage(), e); 060 } 061 } 062 063 public void dump(final PrintWriter pw) { 064 pw.println(""); 065 pw.println("Header"); 066 pw.println("Version: " + version + " (" + Integer.toHexString(version) + ")"); 067 pw.println("Channels: " + channels + " (" + Integer.toHexString(channels) + ")"); 068 pw.println("Rows: " + rows + " (" + Integer.toHexString(rows) + ")"); 069 pw.println("Columns: " + columns + " (" + Integer.toHexString(columns) + ")"); 070 pw.println("Depth: " + depth + " (" + Integer.toHexString(depth) + ")"); 071 pw.println("Mode: " + mode + " (" + Integer.toHexString(mode) + ")"); 072 pw.println("Reserved: " + reserved.length); 073 pw.println(""); 074 pw.flush(); 075 } 076 077}