当前位置: 首页>>代码示例>>Java>>正文


Java DirectColorModel类代码示例

本文整理汇总了Java中java.awt.image.DirectColorModel的典型用法代码示例。如果您正苦于以下问题:Java DirectColorModel类的具体用法?Java DirectColorModel怎么用?Java DirectColorModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DirectColorModel类属于java.awt.image包,在下文中一共展示了DirectColorModel类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getColorModel

import java.awt.image.DirectColorModel; //导入依赖的package包/类
@Override
public ColorModel getColorModel(int transparency) {
    switch (transparency) {
    case Transparency.OPAQUE:
        // REMIND: once the ColorModel spec is changed, this should be
        //         an opaque premultiplied DCM...
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        return new DirectColorModel(cs, 32,
                                    0xff0000, 0xff00, 0xff, 0xff000000,
                                    true, DataBuffer.TYPE_INT);
    default:
        return null;
    }
}
 
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:19,代码来源:WGLGraphicsConfig.java

示例2: extractDirectRGBInt

import java.awt.image.DirectColorModel; //导入依赖的package包/类
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;
}
 
开发者ID:lonnyj,项目名称:webp-imageio,代码行数:25,代码来源:WebP.java

示例3: getColorModel

import java.awt.image.DirectColorModel; //导入依赖的package包/类
/**
 * Returns the color model associated with this configuration that
 * supports the specified transparency.
 */
public ColorModel getColorModel(int transparency) {

    if (model.getTransparency() == transparency) {
        return model;
    }
    switch (transparency) {
    case Transparency.OPAQUE:
        return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    case Transparency.BITMASK:
        return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
    case Transparency.TRANSLUCENT:
        return ColorModel.getRGBdefault();
    default:
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:BufferedImageGraphicsConfig.java

示例4: verifyEquals

import java.awt.image.DirectColorModel; //导入依赖的package包/类
private static void verifyEquals(DirectColorModel m1,
                                 DirectColorModel m2) {
    if (m1.equals(null)) {
        throw new RuntimeException("equals(null) returns true");
    }
    if (!(m1.equals(m2))) {
        throw new RuntimeException("equals() method is not working"
                + " properly");
    }
    if (!(m2.equals(m1))) {
        throw new RuntimeException("equals() method is not working"
                + " properly");
    }
    if (m1.hashCode() != m2.hashCode()) {
        throw new RuntimeException("HashCode is not same for same"
                + " PackedColorModels");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:PackedColorModelEqualsTest.java

示例5: testMaskArrayEquality

import java.awt.image.DirectColorModel; //导入依赖的package包/类
private static void testMaskArrayEquality() {
    /*
     * Test with different maskArray values, since PackedColorModel
     * is abstract we use subclass DirectColorModel.
     */
    DirectColorModel model1 =
        new DirectColorModel(24, 0x00FF0000, 0x0000FF00, 0x000000FF);
    DirectColorModel model2 =
        new DirectColorModel(24, 0x000000FF, 0x0000FF00, 0x00FF0000);
    if (model1.equals(model2)) {
        throw new RuntimeException("equals() method is determining"
                + " ColorMap equality improperly");
    }
    if (model2.equals(model1)) {
        throw new RuntimeException("equals() method is determining"
                + " ColorMap equality improperly");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:PackedColorModelEqualsTest.java

示例6: testConstructor2

import java.awt.image.DirectColorModel; //导入依赖的package包/类
private static void testConstructor2() {
    /*
     * verify equality with constructor
     * DirectColorModel(ColorSpace space, int bits, int rmask, int gmask,
     * int bmask, int amask, boolean isAlphaPremultiplied, int transferType)
     */
    DirectColorModel model1 =
        new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF,
                false, DataBuffer.TYPE_BYTE);
    DirectColorModel model2 =
        new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF,
                false, DataBuffer.TYPE_BYTE);
    verifyEquals(model1, model2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PackedColorModelEqualsTest.java

示例7: getImageToWrite

import java.awt.image.DirectColorModel; //导入依赖的package包/类
/**
 * Get the image to write. This is the mosaic image with alpha channel stripped, as this
 * doesn't work with the JPEG export.
 */
private BufferedImage getImageToWrite() throws InterruptedException {
	BufferedImage image = SwingFXUtils.fromFXImage(mainController.getMosaicImage(), null);
	final int[] RGB_MASKS = {0xFF0000, 0xFF00, 0xFF};
	final ColorModel rgbOpaque = new DirectColorModel(32, RGB_MASKS[0], RGB_MASKS[1], RGB_MASKS[2]);

	PixelGrabber pg = new PixelGrabber(image, 0, 0, -1, -1, true);
	pg.grabPixels();
	int width = pg.getWidth(), height = pg.getHeight();

	DataBuffer buffer = new DataBufferInt((int[]) pg.getPixels(), pg.getWidth() * pg.getHeight());
	WritableRaster raster = Raster.createPackedRaster(buffer, width, height, width, RGB_MASKS, null);
	BufferedImage bi = new BufferedImage(rgbOpaque, raster, false, null);
	
	return bi;
}
 
开发者ID:mrpolyonymous,项目名称:BrickifyFX,代码行数:20,代码来源:OutputPaneController.java

示例8: equals

import java.awt.image.DirectColorModel; //导入依赖的package包/类
/** 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;
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:23,代码来源:ImageLoader.java

示例9: fixColorModel

import java.awt.image.DirectColorModel; //导入依赖的package包/类
protected static ColorModel fixColorModel(CachableRed src) {
    ColorModel  cm = src.getColorModel();

    if (cm.hasAlpha()) {
        if (!cm.isAlphaPremultiplied())
            cm = GraphicsUtil.coerceColorModel(cm, true);
        return cm;
    }

    int b = src.getSampleModel().getNumBands()+1;
    if (b > 4)
        throw new IllegalArgumentException
            ("CompositeRed can only handle up to three band images");

    int [] masks = new int[4];
    for (int i=0; i < b-1; i++)
        masks[i] = 0xFF0000 >> (8*i);
    masks[3] = 0xFF << (8*(b-1));
    ColorSpace cs = cm.getColorSpace();

    return new DirectColorModel(cs, 8*b, masks[0], masks[1],
                                masks[2], masks[3],
                                true, DataBuffer.TYPE_INT);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:25,代码来源:CompositeRed.java

示例10: construct

import java.awt.image.DirectColorModel; //导入依赖的package包/类
public static CachableRed construct(CachableRed src, ColorModel cm) {
    ColorModel srcCM = src.getColorModel();
    if ((cm.hasAlpha() != srcCM.hasAlpha()) ||
        (cm.isAlphaPremultiplied() != srcCM.isAlphaPremultiplied()))
        return new FormatRed(src, cm);

    if (cm.getNumComponents() != srcCM.getNumComponents())
        throw new IllegalArgumentException
            ("Incompatible ColorModel given");


    if ((srcCM instanceof ComponentColorModel) &&
        (cm    instanceof ComponentColorModel))
        return src;

    if ((srcCM instanceof DirectColorModel) &&
        (cm    instanceof DirectColorModel))
        return src;

    return new FormatRed(src, cm);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:22,代码来源:FormatRed.java

示例11: debugRaster

import java.awt.image.DirectColorModel; //导入依赖的package包/类
public static void debugRaster(Raster raster) {
    ColorModel colorModel = new DirectColorModel(
            ColorSpace.getInstance(ColorSpace.CS_sRGB),
            32,
            0x00ff0000,// Red
            0x0000ff00,// Green
            0x000000ff,// Blue
            0xff000000,// Alpha
            true,       // Alpha Premultiplied
            DataBuffer.TYPE_INT
    );

    Raster correctlyTranslated = raster.createChild(raster.getMinX(), raster.getMinY(), raster.getWidth(), raster.getHeight(), 0, 0, null);
    BufferedImage debugImage = new BufferedImage(colorModel, (WritableRaster) correctlyTranslated, true, null);
    debugImage(debugImage);
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:17,代码来源:Utils.java

示例12: createGrayscale

import java.awt.image.DirectColorModel; //导入依赖的package包/类
/**
 * Create a grayscale image type specifier, given the number of
 * bits, data type and whether or not the data is signed.
 *
 * @param bits the number of bits used to specify a greyscale value
 * @param dataType a DataBuffer type constant
 * @param isSigned true if this type specifier should support
 * negative values, false otherwise
 *
 * @return a greyscal image type specifier
 *
 * @exception IllegalArgumentException if bits is not 1, 2, 4, 8 or
 * 16
 * @exception IllegalArgumentException if dataType is not
 * DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT or
 * DataBuffer.TYPE_USHORT
 * @exception if bits is larger than the number of bits in the given
 * data type
 */
public static ImageTypeSpecifier createGrayscale (int bits, int dataType,
                                                  boolean isSigned,
                                                  boolean isAlphaPremultiplied)
{
  if (bits != 1 && bits != 2 && bits != 4 && bits != 8 && bits != 16)
    throw new IllegalArgumentException ("invalid bit size");

  if (dataType != DataBuffer.TYPE_BYTE && dataType != DataBuffer.TYPE_SHORT
      && dataType != DataBuffer.TYPE_USHORT)
    throw new IllegalArgumentException ("invalid data type");

  if (dataType == DataBuffer.TYPE_BYTE && bits > 8)
    throw new IllegalArgumentException ("number of bits too large for data type");

  // FIXME: this is probably wrong:
  return new ImageTypeSpecifier (new DirectColorModel (bits, 0xff, 0x0,
                                                       0x0, 0xff),
                                 new MultiPixelPackedSampleModel (dataType,
                                                                  1, 1,
                                                                  bits));
}
 
开发者ID:vilie,项目名称:javify,代码行数:41,代码来源:ImageTypeSpecifier.java


注:本文中的java.awt.image.DirectColorModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。