本文整理汇总了Java中com.badlogic.gdx.graphics.Pixmap.Format.Alpha方法的典型用法代码示例。如果您正苦于以下问题:Java Format.Alpha方法的具体用法?Java Format.Alpha怎么用?Java Format.Alpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.Pixmap.Format
的用法示例。
在下文中一共展示了Format.Alpha方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.badlogic.gdx.graphics.Pixmap.Format; //导入方法依赖的package包/类
@Override
public void create () {
FileHandle file = Gdx.files.internal("data/bobargb8888-32x32.png");
nonMipMapped[0] = new Texture(file, Format.Alpha, false);
nonMipMapped[1] = new Texture(file, Format.LuminanceAlpha, false);
nonMipMapped[2] = new Texture(file, Format.RGB888, false);
nonMipMapped[3] = new Texture(file, Format.RGB565, false);
nonMipMapped[4] = new Texture(file, Format.RGBA8888, false);
nonMipMapped[5] = new Texture(file, Format.RGBA4444, false);
mipMapped[0] = new Texture(file, Format.Alpha, true);
mipMapped[1] = new Texture(file, Format.LuminanceAlpha, true);
mipMapped[2] = new Texture(file, Format.RGB888, true);
mipMapped[3] = new Texture(file, Format.RGB565, true);
mipMapped[4] = new Texture(file, Format.RGBA8888, true);
mipMapped[5] = new Texture(file, Format.RGBA4444, true);
batch = new SpriteBatch();
}
示例2: getPixmap
import com.badlogic.gdx.graphics.Pixmap.Format; //导入方法依赖的package包/类
/**
* @return Pixmap representing the glyph, needs to be disposed manually.
*/
public Pixmap getPixmap(Format format) {
Pixmap pixmap = new Pixmap(getWidth(), getRows(), Format.Alpha);
BufferUtils.copy(getBuffer(), pixmap.getPixels(), pixmap.getPixels().capacity());
Pixmap converted = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), format);
Blending blending = Pixmap.getBlending();
Pixmap.setBlending(Blending.None);
converted.drawPixmap(pixmap, 0, 0);
Pixmap.setBlending(blending);
pixmap.dispose();
return converted;
}
示例3: getPixmap
import com.badlogic.gdx.graphics.Pixmap.Format; //导入方法依赖的package包/类
public Pixmap getPixmap (Format format, Color color, float gamma) {
int width = getWidth(), rows = getRows();
ByteBuffer src = getBuffer();
Pixmap pixmap;
int pixelMode = getPixelMode();
int rowBytes = Math.abs(getPitch()); // We currently ignore negative pitch.
if (color == Color.WHITE && pixelMode == FT_PIXEL_MODE_GRAY && rowBytes == width && gamma == 1) {
pixmap = new Pixmap(width, rows, Format.Alpha);
BufferUtils.copy(src, pixmap.getPixels(), pixmap.getPixels().capacity());
} else {
pixmap = new Pixmap(width, rows, Format.RGBA8888);
int rgba = Color.rgba8888(color);
byte[] srcRow = new byte[rowBytes];
int[] dstRow = new int[width];
IntBuffer dst = pixmap.getPixels().asIntBuffer();
if (pixelMode == FT_PIXEL_MODE_MONO) {
// Use the specified color for each set bit.
for (int y = 0; y < rows; y++) {
src.get(srcRow);
for (int i = 0, x = 0; x < width; i++, x += 8) {
byte b = srcRow[i];
for (int ii = 0, n = Math.min(8, width - x); ii < n; ii++) {
if ((b & (1 << (7 - ii))) != 0)
dstRow[x + ii] = rgba;
else
dstRow[x + ii] = 0;
}
}
dst.put(dstRow);
}
} else {
// Use the specified color for RGB, blend the FreeType bitmap with alpha.
int rgb = rgba & 0xffffff00;
int a = rgba & 0xff;
for (int y = 0; y < rows; y++) {
src.get(srcRow);
for (int x = 0; x < width; x++) {
float alpha = (srcRow[x] & 0xff) / 255f;
alpha = (float)Math.pow(alpha, gamma); // Inverse gamma.
dstRow[x] = rgb | (int)(a * alpha);
}
dst.put(dstRow);
}
}
}
Pixmap converted = pixmap;
if (format != pixmap.getFormat()) {
converted = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), format);
converted.setBlending(Blending.None);
converted.drawPixmap(pixmap, 0, 0);
pixmap.dispose();
}
return converted;
}
示例4: getPixmap
import com.badlogic.gdx.graphics.Pixmap.Format; //导入方法依赖的package包/类
public Pixmap getPixmap (Format format, Color color, float gamma) {
int width = getWidth(), rows = getRows();
ByteBuffer src = getBuffer();
FreeTypePixmap pixmap;
ByteBuffer changedPixels;
int pixelMode = getPixelMode();
int rowBytes = Math.abs(getPitch()); // We currently ignore negative pitch.
if (color == Color.WHITE && pixelMode == FT_PIXEL_MODE_GRAY && rowBytes == width && gamma == 1) {
pixmap = new FreeTypePixmap(width, rows, Format.Alpha);
changedPixels = pixmap.getRealPixels();
BufferUtils.copy(src, changedPixels, pixmap.getRealPixels().capacity());
} else {
pixmap = new FreeTypePixmap(width, rows, Format.RGBA8888);
int rgba = Color.rgba8888(color);
byte[] srcRow = new byte[rowBytes];
int[] dstRow = new int[width];
changedPixels = pixmap.getRealPixels();
IntBuffer dst = changedPixels.asIntBuffer();
if (pixelMode == FT_PIXEL_MODE_MONO) {
// Use the specified color for each set bit.
for (int y = 0; y < rows; y++) {
src.get(srcRow);
for (int i = 0, x = 0; x < width; i++, x += 8) {
byte b = srcRow[i];
for (int ii = 0, n = Math.min(8, width - x); ii < n; ii++) {
if ((b & (1 << (7 - ii))) != 0)
dstRow[x + ii] = rgba;
else
dstRow[x + ii] = 0;
}
}
dst.put(dstRow);
}
} else {
// Use the specified color for RGB, blend the FreeType bitmap with alpha.
int rgb = rgba & 0xffffff00;
int a = rgba & 0xff;
for (int y = 0; y < rows; y++) {
src.get(srcRow);
for (int x = 0; x < width; x++) {
float alpha;
// Zero raised to any power is always zero.
// 255 (=one) raised to any power is always one
// This means that we only have to calculate Math.pow() when alpha is NOT zero and NOT one
if ((srcRow[x] & 0xff) == 0) {
alpha = 0f;
} else if ((srcRow[x] & 0xff) == 255) {
alpha = 1f;
} else {
alpha = (float)Math.pow(((srcRow[x] & 0xff) / 255f), gamma); // Inverse gamma.
}
dstRow[x] = rgb | (int)(a * alpha);
}
dst.put(dstRow);
}
}
}
pixmap.putPixelsBack(changedPixels);
pixmap.setPixelsNull();
Pixmap p = pixmap;
Pixmap converted = pixmap;
if (pixmap.getFormat() != null && format != pixmap.getFormat()) {
converted = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), format);
pixmap.setBlending(Blending.None);
converted.drawPixmap(pixmap, 0, 0);
pixmap.dispose();
}
return converted;
}