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


Java ComponentColorModel.TRANSLUCENT属性代码示例

本文整理汇总了Java中java.awt.image.ComponentColorModel.TRANSLUCENT属性的典型用法代码示例。如果您正苦于以下问题:Java ComponentColorModel.TRANSLUCENT属性的具体用法?Java ComponentColorModel.TRANSLUCENT怎么用?Java ComponentColorModel.TRANSLUCENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.image.ComponentColorModel的用法示例。


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

示例1: TextureLoader

/**
 * Create a new texture loader based on the game panel
 */
public TextureLoader() {
    glAlphaColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                        new int[] {8,8,8,8},
                                        true,
                                        false,
                                        ComponentColorModel.TRANSLUCENT,
                                        DataBuffer.TYPE_BYTE);

    glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                        new int[] {8,8,8,0},
                                        false,
                                        false,
                                        ComponentColorModel.OPAQUE,
                                        DataBuffer.TYPE_BYTE);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:TextureLoader.java

示例2: TextureLoader

/** 
 * Create a new texture loader based on the game panel
 *
 * @param gl The GL content in which the textures should be loaded
 */
public TextureLoader() {
    glAlphaColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                        new int[] {8,8,8,8},
                                        true,
                                        false,
                                        ComponentColorModel.TRANSLUCENT,
                                        DataBuffer.TYPE_BYTE);
                                        
    glColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
                                        new int[] {8,8,8,0},
                                        false,
                                        false,
                                        ComponentColorModel.OPAQUE,
                                        DataBuffer.TYPE_BYTE);
}
 
开发者ID:WhiteHexagon,项目名称:example-jovr-lwjgl3-rift,代码行数:20,代码来源:TextureLoader.java

示例3: LoadFromBuffered

private void LoadFromBuffered(BufferedImage bufferedImage) {
	width = bufferedImage.getWidth();
	height = bufferedImage.getHeight();

	WritableRaster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
			4, null);
	ComponentColorModel colorModel = new ComponentColorModel(
			ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[] { 8, 8, 8, 8 }, true, false,
			ComponentColorModel.TRANSLUCENT, DataBuffer.TYPE_BYTE);
	BufferedImage dukeImg = new BufferedImage(colorModel, raster, false, null);

	Graphics2D g = dukeImg.createGraphics();
	g.drawImage(bufferedImage, null, null);
	DataBufferByte dukeBuf = (DataBufferByte) raster.getDataBuffer();
	byte[] dukeRGBA = dukeBuf.getData();
	img = ByteBuffer.wrap(dukeRGBA);

	img.position(0);
	img.mark();
}
 
开发者ID:ryft,项目名称:NetVis,代码行数:20,代码来源:Texture.java

示例4: getRemoteBufferedImage

@Override
public BufferedImage getRemoteBufferedImage(){
	SampleModel samplemodel = new BandedSampleModel(DataBuffer.TYPE_DOUBLE, getWidth(), getHeight(), hasAlpha() ? 4:3);
	DataBufferDouble databuffer = new DataBufferDouble(getData(), numValues());
	WritableRaster raster = Raster.createWritableRaster(samplemodel, databuffer, null);
	ColorModel colormodel = new ComponentColorModel(
			ColorSpace.getInstance(ColorSpace.CS_sRGB),
			hasAlpha(),
			false,
			hasAlpha() ? ComponentColorModel.TRANSLUCENT:ComponentColorModel.OPAQUE,
			DataBuffer.TYPE_DOUBLE
	);
	BufferedImage bimg = new BufferedImage(colormodel, raster, false, null);
	return bimg;
}
 
开发者ID:hageldave,项目名称:ImagingKit,代码行数:15,代码来源:ColorImg.java

示例5: draw

/**
 *
 * @todo Write documentation
 * @param texture
 * @param position
 * @since 0.1
 */
public void draw(Texture2D texture, Vector2 position)
{
	GL2 gl = game.getWindow().getCanvas().getGL().getGL2();
	if (gl != null)
	{
		WritableRaster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texture.getWidth(), texture.getHeight(), 4, null);
		ComponentColorModel colorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[]
		{
			8, 8, 8, 8
		}, true, false, ComponentColorModel.TRANSLUCENT, DataBuffer.TYPE_BYTE);
		Texture2D image = new Texture2D(colorModel, raster, false, null);
		Graphics2D graphics = image.createGraphics();
		graphics.drawImage(texture, null, null);
		DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer();
		byte[] rgba = dataBuffer.getData();
		ByteBuffer buffer = ByteBuffer.wrap(rgba);
		buffer.position(0);
		buffer.mark();
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP);
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP);
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
		gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
		gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
		gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, texture.getWidth(), texture.getHeight(), 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);
		gl.glEnable(GL.GL_TEXTURE_2D);
		gl.glBindTexture(GL.GL_TEXTURE_2D, 13);
		gl.glBegin(GL2.GL_POLYGON);
		gl.glTexCoord2d(0, 0);
		gl.glVertex2d(position.x, position.y);
		gl.glTexCoord2d(1, 0);
		gl.glVertex2d(position.x + texture.getWidth(), position.y);
		gl.glTexCoord2d(1, 1);
		gl.glVertex2d(position.x + texture.getWidth(), position.y + texture.getHeight());
		gl.glTexCoord2d(0, 1);
		gl.glVertex2d(position.x, position.y + texture.getHeight());
		gl.glEnd();
		gl.glFlush();
	}
}
 
开发者ID:TheAtlas,项目名称:Atlas-Game-Framework,代码行数:46,代码来源:SpriteBatch.java

示例6: getColorModel

public ColorModel getColorModel( ColorSpace cs,
                                 int colorType, int depth )
{
  int[] bits;
  boolean hasAlpha = false;
  int transferType;

  switch( colorType )
    {
    case PNGHeader.GRAYSCALE_WITH_ALPHA:
      if( cs == null )
        cs = ColorSpace.getInstance( ColorSpace.CS_GRAY );
      hasAlpha = true;
      bits = new int[]{ depth, depth };
      break;

    case PNGHeader.RGB:
      bits = new int[]{ depth, depth, depth };
      break;

    case PNGHeader.RGB_WITH_ALPHA:
      hasAlpha = true;
      bits = new int[]{ depth, depth, depth, depth };
      break;

    case PNGHeader.GRAYSCALE:
      if( depth < 8 )
        return grayPalette( depth );

      if( cs == null )
        cs = ColorSpace.getInstance( ColorSpace.CS_GRAY );
      bits = new int[]{ depth };
      break;

    default:
    case PNGHeader.INDEXED:
      return null; // Handled by the palette chunk.
    }

  if( cs == null )
    cs = ColorSpace.getInstance( ColorSpace.CS_sRGB );


  return new ComponentColorModel(cs, bits, hasAlpha, false,
                                 (hasAlpha ?
                                  ComponentColorModel.TRANSLUCENT :
                                  ComponentColorModel.OPAQUE),
                                 ((depth == 16) ? DataBuffer.TYPE_USHORT :
                                  DataBuffer.TYPE_BYTE));
}
 
开发者ID:vilie,项目名称:javify,代码行数:50,代码来源:PNGDecoder.java

示例7: getColorModel

public ColorModel getColorModel( ColorSpace cs, 
			   int colorType, int depth )
 {
   int[] bits;
   boolean hasAlpha = false;
   int transferType;

   switch( colorType )
     {
     case PNGHeader.GRAYSCALE_WITH_ALPHA:
if( cs == null )
  cs = ColorSpace.getInstance( ColorSpace.CS_GRAY );
hasAlpha = true;
bits = new int[]{ depth, depth };
break;

     case PNGHeader.RGB:
bits = new int[]{ depth, depth, depth };
break;

     case PNGHeader.RGB_WITH_ALPHA:
hasAlpha = true;
bits = new int[]{ depth, depth, depth, depth };
break;

     case PNGHeader.GRAYSCALE:
if( depth < 8 )
  return grayPalette( depth );

if( cs == null )
  cs = ColorSpace.getInstance( ColorSpace.CS_GRAY );
bits = new int[]{ depth };
break;

     default:
     case PNGHeader.INDEXED:
return null; // Handled by the palette chunk.
     }

   if( cs == null )
     cs = ColorSpace.getInstance( ColorSpace.CS_sRGB );


   return new ComponentColorModel(cs, bits, hasAlpha, false, 
			   (hasAlpha ? 
			    ComponentColorModel.TRANSLUCENT : 
			    ComponentColorModel.OPAQUE), 
			   ((depth == 16) ? DataBuffer.TYPE_USHORT : 
			    DataBuffer.TYPE_BYTE));
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:50,代码来源:PNGDecoder.java

示例8: getGLColorModel

private ColorModel getGLColorModel() {
	return new ComponentColorModel(
			ColorSpace.getInstance(ColorSpace.CS_sRGB), true, false,
			ComponentColorModel.TRANSLUCENT, DataBuffer.TYPE_BYTE);
}
 
开发者ID:g-rauhoeft,项目名称:Beeg-StaKe,代码行数:5,代码来源:FontRenderer.java


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