Java Code Examples for java.awt.image.DirectColorModel#getAlphaMask()

The following examples show how to use java.awt.image.DirectColorModel#getAlphaMask() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageLoader.java    From pumpernickel with MIT License 6 votes vote down vote up
/**
 * This checks to see if two DirectColorModels are identical. Apparently the
 * "equals" method in DirectColorModel doesn't really work.
 */
private static boolean equals(DirectColorModel d1, DirectColorModel d2) {
	if (d1.getAlphaMask() != d2.getAlphaMask())
		return false;
	if (d1.getGreenMask() != d2.getGreenMask())
		return false;
	if (d1.getRedMask() != d2.getRedMask())
		return false;
	if (d1.getBlueMask() != d2.getBlueMask())
		return false;
	if (d1.getColorSpace() != d2.getColorSpace())
		return false;
	if (d1.isAlphaPremultiplied() != d2.isAlphaPremultiplied())
		return false;
	if (d1.getTransferType() != d2.getTransferType())
		return false;
	if (d1.getTransparency() != d2.getTransparency())
		return false;
	return true;
}
 
Example 2
Source File: BlendComposite.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
private static boolean isRgbColorModel(ColorModel cm) {
    if (cm instanceof DirectColorModel &&
            cm.getTransferType() == DataBuffer.TYPE_INT) {
        DirectColorModel directCM = (DirectColorModel) cm;

        return directCM.getRedMask() == 0x00FF0000 &&
                directCM.getGreenMask() == 0x0000FF00 &&
                directCM.getBlueMask() == 0x000000FF &&
                (directCM.getNumComponents() == 3 ||
                        directCM.getAlphaMask() == 0xFF000000);
    }

    return false;
}
 
Example 3
Source File: WebP.java    From webp-imageio with Apache License 2.0 5 votes vote down vote up
private static byte[] extractDirectRGBAInt( int aWidth, int aHeight, DirectColorModel aColorModel, SinglePixelPackedSampleModel aSampleModel, DataBufferInt aDataBuffer ) {
  byte[] out = new byte[ aWidth * aHeight * 4 ];

  int rMask = aColorModel.getRedMask();
  int gMask = aColorModel.getGreenMask();
  int bMask = aColorModel.getBlueMask();
  int aMask = aColorModel.getAlphaMask();
  int rShift = getShift( rMask );
  int gShift = getShift( gMask );
  int bShift = getShift( bMask );
  int aShift = getShift( aMask );
  int[] bank = aDataBuffer.getBankData()[ 0 ];
  int scanlineStride = aSampleModel.getScanlineStride();
  int scanIx = 0;
  for ( int b = 0, y = 0; y < aHeight; y++ ) {
    int pixIx = scanIx;
    for ( int x = 0; x < aWidth; x++, b += 4 ) {
      int pixel = bank[ pixIx++ ];
      out[ b ] = ( byte ) ( ( pixel & rMask ) >>> rShift );
      out[ b + 1 ] = ( byte ) ( ( pixel & gMask ) >>> gShift );
      out[ b + 2 ] = ( byte ) ( ( pixel & bMask ) >>> bShift );
      out[ b + 3 ] = ( byte ) ( ( pixel & aMask ) >>> aShift );
    }
    scanIx += scanlineStride;
  }
  return out;
}
 
Example 4
Source File: BlendComposite.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
private static boolean checkComponentsOrder(ColorModel cm) {
    if (cm instanceof DirectColorModel && cm.getTransferType() == DataBuffer.TYPE_INT) {
        DirectColorModel directCM = (DirectColorModel) cm;
        return directCM.getRedMask() == 0x00FF0000 && directCM.getGreenMask() == 0x0000FF00 && directCM.getBlueMask() == 0x000000FF
                && (directCM.getNumComponents() != 4 || directCM.getAlphaMask() == 0xFF000000);
    }
    return false;
}
 
Example 5
Source File: BlendComposite.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
private static boolean checkComponentsOrder(ColorModel cm) {
    if (cm instanceof DirectColorModel
            && cm.getTransferType() == DataBuffer.TYPE_INT) {
        DirectColorModel directCM = (DirectColorModel) cm;

        return directCM.getRedMask() == 0x00FF0000
                && directCM.getGreenMask() == 0x0000FF00
                && directCM.getBlueMask() == 0x000000FF
                && (directCM.getNumComponents() != 4
                || directCM.getAlphaMask() == 0xFF000000);
    }

    return false;
}
 
Example 6
Source File: BlendComposite.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static boolean checkComponentsOrder(ColorModel cm) {
    if (cm instanceof DirectColorModel &&
            cm.getTransferType() == DataBuffer.TYPE_INT) {
        DirectColorModel directCM = (DirectColorModel) cm;
        
        return directCM.getRedMask() == 0x00FF0000 &&
               directCM.getGreenMask() == 0x0000FF00 &&
               directCM.getBlueMask() == 0x000000FF &&
               (directCM.getNumComponents() != 4 ||
                directCM.getAlphaMask() == 0xFF000000);
    }
    
    return false;
}
 
Example 7
Source File: BlendComposite.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
private static boolean isBgrColorModel(ColorModel cm) {
    if (cm instanceof DirectColorModel &&
            cm.getTransferType() == DataBuffer.TYPE_INT) {
        DirectColorModel directCM = (DirectColorModel) cm;

        return directCM.getRedMask() == 0x000000FF &&
                directCM.getGreenMask() == 0x0000FF00 &&
                directCM.getBlueMask() == 0x00FF0000 &&
                (directCM.getNumComponents() == 3 ||
                        directCM.getAlphaMask() == 0xFF000000);
    }

    return false;
}
 
Example 8
Source File: BlendComposite.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static boolean checkComponentsOrder(ColorModel cm) {
    if (cm instanceof DirectColorModel &&
            cm.getTransferType() == DataBuffer.TYPE_INT) {
        DirectColorModel directCM = (DirectColorModel) cm;
        
        return directCM.getRedMask() == 0x00FF0000 &&
               directCM.getGreenMask() == 0x0000FF00 &&
               directCM.getBlueMask() == 0x000000FF &&
               (directCM.getNumComponents() != 4 ||
                directCM.getAlphaMask() == 0xFF000000);
    }
    
    return false;
}
 
Example 9
Source File: X11SurfaceDataProxy.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 10
Source File: X11SurfaceDataProxy.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 11
Source File: X11SurfaceDataProxy.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 12
Source File: X11SurfaceDataProxy.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 13
Source File: X11SurfaceDataProxy.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 14
Source File: X11SurfaceDataProxy.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 15
Source File: X11SurfaceDataProxy.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 16
Source File: X11SurfaceDataProxy.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 17
Source File: X11SurfaceDataProxy.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 18
Source File: X11SurfaceDataProxy.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}
 
Example 19
Source File: ColorTools.java    From commons-imaging with Apache License 2.0 4 votes vote down vote up
public ColorModel deriveColorModel(final ColorModel colorModel, final ColorSpace cs,
        final boolean forceNoAlpha) throws ImagingOpException {

    if (colorModel instanceof ComponentColorModel) {
        final ComponentColorModel ccm = (ComponentColorModel) colorModel;
        // ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        if (forceNoAlpha) {
            return new ComponentColorModel(cs, false, false,
                    Transparency.OPAQUE, ccm.getTransferType());
        }
        return new ComponentColorModel(cs, ccm.hasAlpha(),
                ccm.isAlphaPremultiplied(), ccm.getTransparency(),
                ccm.getTransferType());
    } else if (colorModel instanceof DirectColorModel) {
        final DirectColorModel dcm = (DirectColorModel) colorModel;

        final int oldMask = dcm.getRedMask() | dcm.getGreenMask()
                | dcm.getBlueMask() | dcm.getAlphaMask();

        final int oldBits = countBitsInMask(oldMask);

        return new DirectColorModel(cs, oldBits, dcm.getRedMask(),
                dcm.getGreenMask(), dcm.getBlueMask(), dcm.getAlphaMask(),
                dcm.isAlphaPremultiplied(), dcm.getTransferType());
    }
    // else if (old_cm instanceof PackedColorModel)
    // {
    // PackedColorModel pcm = (PackedColorModel) old_cm;
    //
    // // int old_mask = dcm.getRedMask() | dcm.getGreenMask()
    // // | dcm.getBlueMask() | dcm.getAlphaMask();
    //
    // int old_masks[] = pcm.getMasks();
    // // System.out.println("old_mask: " + old_mask);
    // int old_bits = countBitsInMask(old_masks);
    // // System.out.println("old_bits: " + old_bits);
    //
    // // PackedColorModel(ColorSpace space, int bits, int rmask, int gmask,
    // int bmask, int amask, boolean isAlphaPremultiplied, int trans, int
    // transferType)
    // cm = new PackedColorModel(cs, old_bits, pcm.getMasks(),
    //
    // pcm.isAlphaPremultiplied(), pcm.getTransparency(), pcm
    // .getTransferType());
    // }

    throw new ImagingOpException("Could not clone unknown ColorModel Type.");
}
 
Example 20
Source File: X11SurfaceDataProxy.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static SurfaceDataProxy createProxy(SurfaceData srcData,
                                           X11GraphicsConfig dstConfig)
{
    if (srcData instanceof X11SurfaceData) {
        // srcData must be a VolatileImage which either matches
        // our visual or not - either way we do not cache it...
        return UNCACHED;
    }

    ColorModel cm = srcData.getColorModel();
    int transparency = cm.getTransparency();

    if (transparency == Transparency.OPAQUE) {
        return new Opaque(dstConfig);
    } else if (transparency == Transparency.BITMASK) {
        // 4673490: updateBitmask() only handles ICMs with 8-bit indices
        if ((cm instanceof IndexColorModel) && cm.getPixelSize() == 8) {
            return new Bitmask(dstConfig);
        }
        // The only other ColorModel handled by updateBitmask() is
        // a DCM where the alpha bit, and only the alpha bit, is in
        // the top 8 bits
        if (cm instanceof DirectColorModel) {
            DirectColorModel dcm = (DirectColorModel) cm;
            int colormask = (dcm.getRedMask() |
                             dcm.getGreenMask() |
                             dcm.getBlueMask());
            int alphamask = dcm.getAlphaMask();

            if ((colormask & 0xff000000) == 0 &&
                (alphamask & 0xff000000) != 0)
            {
                return new Bitmask(dstConfig);
            }
        }
    }

    // For whatever reason, this image is not a good candidate for
    // caching in a pixmap so we return the non-caching (non-)proxy.
    return UNCACHED;
}