本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
}
示例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));
}
示例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));
}
示例8: getGLColorModel
private ColorModel getGLColorModel() {
return new ComponentColorModel(
ColorSpace.getInstance(ColorSpace.CS_sRGB), true, false,
ComponentColorModel.TRANSLUCENT, DataBuffer.TYPE_BYTE);
}