/* Copyright (C) 2000 Free Software Foundation This file is part of libgcj. This software is copyrighted work licensed under the terms of the Libgcj License. Please consult the file "LIBGCJ_LICENSE" for details. */ package java.awt.image; import java.awt.Point; import java.awt.color.ColorSpace; import gnu.gcj.awt.BitMaskExtent; /** * @author Rolf W. Rasmussen */ public abstract class PackedColorModel extends ColorModel { private int masks[]; /* Package accessibility, the DirectColorModel needs this array */ int shifts[]; public PackedColorModel(ColorSpace cspace, int pixelBits, int[] colorMaskArray, int alphaMask, boolean isAlphaPremultiplied, int transparency, int transferType) { super(pixelBits, calcBitsPerComponent(colorMaskArray, alphaMask), cspace, (alphaMask != 0), isAlphaPremultiplied, transparency, transferType); initMasks(colorMaskArray, alphaMask); if ((pixelBits<1) || (pixelBits>32)) { throw new IllegalArgumentException("pixels per bits must be " + "in the range [1, 32]"); } } private static int[] calcBitsPerComponent(int[] colorMaskArray, int alphaMask) { int numComponents = colorMaskArray.length; if (alphaMask != 0) numComponents++; int[] bitsPerComponent = new int[numComponents]; BitMaskExtent extent = new BitMaskExtent(); for (int b=0; b