Java Code Examples for java.awt.image.DirectColorModel#getRedMask()
The following examples show how to use
java.awt.image.DirectColorModel#getRedMask() .
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: AbstractVideoCodec.java From jpexs-decompiler with GNU General Public License v3.0 | 6 votes |
/** Gets 32-bit ARGB pixels from a buffer. Returns null if conversion failed. */ protected int[] getARGB32(Buffer buf) { if (buf.data instanceof int[]) { return (int[]) buf.data; } if (buf.data instanceof BufferedImage) { BufferedImage image = (BufferedImage) buf.data; if (image.getColorModel() instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel) image.getColorModel(); if (dcm.getBlueMask() == 0xff && dcm.getGreenMask() == 0xff00 && dcm.getRedMask() == 0xff0000) { if (image.getRaster().getDataBuffer() instanceof DataBufferInt) { return ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); } } } return image.getRGB(0, 0, // outputFormat.get(WidthKey), outputFormat.get(HeightKey), // null, 0, outputFormat.get(WidthKey)); } return null; }
Example 2
Source File: WebP.java From webp-imageio with Apache License 2.0 | 6 votes |
private static byte[] extractDirectRGBInt( int aWidth, int aHeight, DirectColorModel aColorModel, SinglePixelPackedSampleModel aSampleModel, DataBufferInt aDataBuffer ) { byte[] out = new byte[ aWidth * aHeight * 3 ]; int rMask = aColorModel.getRedMask(); int gMask = aColorModel.getGreenMask(); int bMask = aColorModel.getBlueMask(); int rShift = getShift( rMask ); int gShift = getShift( gMask ); int bShift = getShift( bMask ); 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 += 3 ) { int pixel = bank[ pixIx++ ]; out[ b ] = ( byte ) ( ( pixel & rMask ) >>> rShift ); out[ b + 1 ] = ( byte ) ( ( pixel & gMask ) >>> gShift ); out[ b + 2 ] = ( byte ) ( ( pixel & bMask ) >>> bShift ); } scanIx += scanlineStride; } return out; }
Example 3
Source File: ImageRepresentation.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
void createBufferedImage() { // REMIND: Be careful! Is this called everytime there is a // startProduction? We only want to call it if it is new or // there is an error isDefaultBI = false; try { biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, cmodel.isAlphaPremultiplied(), null); } catch (Exception e) { // Create a default image cmodel = ColorModel.getRGBdefault(); biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, false, null); } int type = bimage.getType(); if ((cmodel == ColorModel.getRGBdefault()) || (type == BufferedImage.TYPE_INT_RGB) || (type == BufferedImage.TYPE_INT_ARGB_PRE)) { isDefaultBI = true; } else if (cmodel instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel) cmodel; if (dcm.getRedMask() == 0xff0000 && dcm.getGreenMask() == 0xff00 && dcm.getBlueMask() == 0xff) { isDefaultBI = true; } } }
Example 4
Source File: GDIWindowSurfaceData.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private GDIWindowSurfaceData(WComponentPeer peer, SurfaceType sType) { super(sType, peer.getDeviceColorModel()); ColorModel cm = peer.getDeviceColorModel(); this.peer = peer; int rMask = 0, gMask = 0, bMask = 0; int depth; switch (cm.getPixelSize()) { case 32: case 24: if (cm instanceof DirectColorModel) { depth = 32; } else { depth = 24; } break; default: depth = cm.getPixelSize(); } if (cm instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel)cm; rMask = dcm.getRedMask(); gMask = dcm.getGreenMask(); bMask = dcm.getBlueMask(); } this.graphicsConfig = (Win32GraphicsConfig) peer.getGraphicsConfiguration(); this.solidloops = graphicsConfig.getSolidLoops(sType); Win32GraphicsDevice gd = graphicsConfig.getDevice(); scaleX = gd.getDefaultScaleX(); scaleY = gd.getDefaultScaleY(); initOps(peer, depth, rMask, gMask, bMask, gd.getScreen()); setBlitProxyKey(graphicsConfig.getProxyKey()); }
Example 5
Source File: ImageRepresentation.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void createBufferedImage() { // REMIND: Be careful! Is this called everytime there is a // startProduction? We only want to call it if it is new or // there is an error isDefaultBI = false; try { biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, cmodel.isAlphaPremultiplied(), null); } catch (Exception e) { // Create a default image cmodel = ColorModel.getRGBdefault(); biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, false, null); } int type = bimage.getType(); if ((cmodel == ColorModel.getRGBdefault()) || (type == BufferedImage.TYPE_INT_RGB) || (type == BufferedImage.TYPE_INT_ARGB_PRE)) { isDefaultBI = true; } else if (cmodel instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel) cmodel; if (dcm.getRedMask() == 0xff0000 && dcm.getGreenMask() == 0xff00 && dcm.getBlueMask() == 0xff) { isDefaultBI = true; } } }
Example 6
Source File: ImageRepresentation.java From Bytecoder with Apache License 2.0 | 5 votes |
void createBufferedImage() { // REMIND: Be careful! Is this called everytime there is a // startProduction? We only want to call it if it is new or // there is an error isDefaultBI = false; try { biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, cmodel.isAlphaPremultiplied(), null); } catch (Exception e) { // Create a default image cmodel = ColorModel.getRGBdefault(); biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, false, null); } int type = bimage.getType(); if ((cmodel == ColorModel.getRGBdefault()) || (type == BufferedImage.TYPE_INT_RGB) || (type == BufferedImage.TYPE_INT_ARGB_PRE)) { isDefaultBI = true; } else if (cmodel instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel) cmodel; if (dcm.getRedMask() == 0xff0000 && dcm.getGreenMask() == 0xff00 && dcm.getBlueMask() == 0xff) { isDefaultBI = true; } } }
Example 7
Source File: BlendComposite.java From Pixelitor with GNU General Public License v3.0 | 5 votes |
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 8
Source File: BlendComposite.java From amodeus with GNU General Public License v2.0 | 5 votes |
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: BlendComposite.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 10
Source File: GDIWindowSurfaceData.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private GDIWindowSurfaceData(WComponentPeer peer, SurfaceType sType) { super(sType, peer.getDeviceColorModel()); ColorModel cm = peer.getDeviceColorModel(); this.peer = peer; int rMask = 0, gMask = 0, bMask = 0; int depth; switch (cm.getPixelSize()) { case 32: case 24: if (cm instanceof DirectColorModel) { depth = 32; } else { depth = 24; } break; default: depth = cm.getPixelSize(); } if (cm instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel)cm; rMask = dcm.getRedMask(); gMask = dcm.getGreenMask(); bMask = dcm.getBlueMask(); } this.graphicsConfig = (Win32GraphicsConfig) peer.getGraphicsConfiguration(); this.solidloops = graphicsConfig.getSolidLoops(sType); Win32GraphicsDevice gd = (Win32GraphicsDevice)graphicsConfig.getDevice(); initOps(peer, depth, rMask, gMask, bMask, gd.getScreen()); setBlitProxyKey(graphicsConfig.getProxyKey()); }
Example 11
Source File: GDIWindowSurfaceData.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private GDIWindowSurfaceData(WComponentPeer peer, SurfaceType sType) { super(sType, peer.getDeviceColorModel()); ColorModel cm = peer.getDeviceColorModel(); this.peer = peer; int rMask = 0, gMask = 0, bMask = 0; int depth; switch (cm.getPixelSize()) { case 32: case 24: if (cm instanceof DirectColorModel) { depth = 32; } else { depth = 24; } break; default: depth = cm.getPixelSize(); } if (cm instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel)cm; rMask = dcm.getRedMask(); gMask = dcm.getGreenMask(); bMask = dcm.getBlueMask(); } this.graphicsConfig = (Win32GraphicsConfig) peer.getGraphicsConfiguration(); this.solidloops = graphicsConfig.getSolidLoops(sType); Win32GraphicsDevice gd = (Win32GraphicsDevice)graphicsConfig.getDevice(); initOps(peer, depth, rMask, gMask, bMask, gd.getScreen()); setBlitProxyKey(graphicsConfig.getProxyKey()); }
Example 12
Source File: GDIWindowSurfaceData.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private GDIWindowSurfaceData(WComponentPeer peer, SurfaceType sType) { super(sType, peer.getDeviceColorModel()); ColorModel cm = peer.getDeviceColorModel(); this.peer = peer; int rMask = 0, gMask = 0, bMask = 0; int depth; switch (cm.getPixelSize()) { case 32: case 24: if (cm instanceof DirectColorModel) { depth = 32; } else { depth = 24; } break; default: depth = cm.getPixelSize(); } if (cm instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel)cm; rMask = dcm.getRedMask(); gMask = dcm.getGreenMask(); bMask = dcm.getBlueMask(); } this.graphicsConfig = (Win32GraphicsConfig) peer.getGraphicsConfiguration(); this.solidloops = graphicsConfig.getSolidLoops(sType); Win32GraphicsDevice gd = (Win32GraphicsDevice)graphicsConfig.getDevice(); initOps(peer, depth, rMask, gMask, bMask, gd.getScreen()); setBlitProxyKey(graphicsConfig.getProxyKey()); }
Example 13
Source File: ImageRepresentation.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
void createBufferedImage() { // REMIND: Be careful! Is this called everytime there is a // startProduction? We only want to call it if it is new or // there is an error isDefaultBI = false; try { biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, cmodel.isAlphaPremultiplied(), null); } catch (Exception e) { // Create a default image cmodel = ColorModel.getRGBdefault(); biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, false, null); } int type = bimage.getType(); if ((cmodel == ColorModel.getRGBdefault()) || (type == BufferedImage.TYPE_INT_RGB) || (type == BufferedImage.TYPE_INT_ARGB_PRE)) { isDefaultBI = true; } else if (cmodel instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel) cmodel; if (dcm.getRedMask() == 0xff0000 && dcm.getGreenMask() == 0xff00 && dcm.getBlueMask() == 0xff) { isDefaultBI = true; } } }
Example 14
Source File: ImageRepresentation.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 15
Source File: ImageRepresentation.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 16
Source File: ImageRepresentation.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == Transparency.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 17
Source File: ImageRepresentation.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public void setColorModel(ColorModel model) { if (src != null) { src.checkSecurity(null, false); } srcModel = model; // Check to see if model is INT_RGB if (model instanceof IndexColorModel) { if (model.getTransparency() == model.TRANSLUCENT) { // REMIND: // Probably need to composite anyway so force ARGB cmodel = ColorModel.getRGBdefault(); srcLUT = null; } else { IndexColorModel icm = (IndexColorModel) model; numSrcLUT = icm.getMapSize(); srcLUT = new int[Math.max(numSrcLUT, 256)]; icm.getRGBs(srcLUT); srcLUTtransIndex = icm.getTransparentPixel(); cmodel = model; } } else { if (cmodel == null) { cmodel = model; srcLUT = null; } else if (model instanceof DirectColorModel) { // If it is INT_RGB or INT_ARGB, use the model DirectColorModel dcm = (DirectColorModel) model; if ((dcm.getRedMask() == 0xff0000) && (dcm.getGreenMask() == 0xff00) && (dcm.getBlueMask() == 0x00ff)) { cmodel = model; srcLUT = null; } } } isSameCM = (cmodel == model); }
Example 18
Source File: X11SurfaceDataProxy.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
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: X11SurfaceDataProxy.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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 20
Source File: X11SurfaceDataProxy.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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; }