本文整理汇总了Java中java.awt.image.IndexColorModel.getBlues方法的典型用法代码示例。如果您正苦于以下问题:Java IndexColorModel.getBlues方法的具体用法?Java IndexColorModel.getBlues怎么用?Java IndexColorModel.getBlues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.IndexColorModel
的用法示例。
在下文中一共展示了IndexColorModel.getBlues方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
void write(ImageOutputStream ios,
JPEGImageWriter writer) throws IOException {
super.write(ios, writer); // width and height
// Write the palette (must be 768 bytes)
byte [] palette = new byte[768];
IndexColorModel icm = (IndexColorModel) thumbnail.getColorModel();
byte [] reds = new byte [256];
byte [] greens = new byte [256];
byte [] blues = new byte [256];
icm.getReds(reds);
icm.getGreens(greens);
icm.getBlues(blues);
for (int i = 0; i < 256; i++) {
palette[i*3] = reds[i];
palette[i*3+1] = greens[i];
palette[i*3+2] = blues[i];
}
ios.write(palette);
writePixels(ios, writer);
}
示例2: setAlpha
import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
/**
* Returns an index color model with specified opacity (alpha).
* @param icm an index color model from which to copy RGBs.
* @param alpha opacity in the range [0.0,1.0].
* @return the index color model with alpha.
*/
public static IndexColorModel setAlpha(IndexColorModel icm, double alpha) {
int bits = icm.getPixelSize();
int size = icm.getMapSize();
byte[] r = new byte[size];
byte[] g = new byte[size];
byte[] b = new byte[size];
byte[] a = new byte[size];
icm.getReds(r);
icm.getGreens(g);
icm.getBlues(b);
byte ia = (byte)(255.0*alpha+0.5);
for (int i=0; i<size; ++i)
a[i] = ia;
return new IndexColorModel(bits,size,r,g,b,a);
}
示例3: getDefaultPalette
import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
private static synchronized byte[] getDefaultPalette() {
if (defaultPalette == null) {
BufferedImage img = new BufferedImage(1, 1,
BufferedImage.TYPE_BYTE_INDEXED);
IndexColorModel icm = (IndexColorModel) img.getColorModel();
final int size = icm.getMapSize();
byte[] r = new byte[size];
byte[] g = new byte[size];
byte[] b = new byte[size];
icm.getReds(r);
icm.getGreens(g);
icm.getBlues(b);
defaultPalette = new byte[size * 3];
for (int i = 0; i < size; i++) {
defaultPalette[3 * i + 0] = r[i];
defaultPalette[3 * i + 1] = g[i];
defaultPalette[3 * i + 2] = b[i];
}
}
return defaultPalette;
}
示例4: listCurrentLut
import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
/**
* Lists the contents of the lookup-table currently associated
* with the specified image.
*
* @param ip The image.
*/
public static void listCurrentLut(ImageProcessor ip) {
ColorModel cm = ip.getCurrentColorModel();
IndexColorModel icm = (IndexColorModel) cm;
int mapSize = icm.getMapSize();
byte[] reds = new byte[mapSize];
byte[] grns = new byte[mapSize];
byte[] blus = new byte[mapSize];
icm.getReds(reds);
icm.getGreens(grns);
icm.getBlues(blus);
for (int i = 0; i < mapSize; i++) {
IJ.log(String.format("%3d: %3d %3d %3d", i, reds[i] & 0xFF, grns[i] & 0xFF, blus[i] & 0xFF));
}
}
示例5: createColorTable
import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
/**
* Create a color table from the image ColorModel and SampleModel.
*/
private static byte[] createColorTable(ColorModel colorModel,
SampleModel sampleModel)
{
byte[] colorTable;
if (colorModel instanceof IndexColorModel) {
IndexColorModel icm = (IndexColorModel)colorModel;
int mapSize = icm.getMapSize();
/**
* The GIF image format assumes that size of image palette
* is power of two. We will use closest larger power of two
* as size of color table.
*/
int ctSize = getGifPaletteSize(mapSize);
byte[] reds = new byte[ctSize];
byte[] greens = new byte[ctSize];
byte[] blues = new byte[ctSize];
icm.getReds(reds);
icm.getGreens(greens);
icm.getBlues(blues);
/**
* fill tail of color component arrays by replica of first color
* in order to avoid appearance of extra colors in the color table
*/
for (int i = mapSize; i < ctSize; i++) {
reds[i] = reds[0];
greens[i] = greens[0];
blues[i] = blues[0];
}
colorTable = new byte[3*ctSize];
int idx = 0;
for (int i = 0; i < ctSize; i++) {
colorTable[idx++] = reds[i];
colorTable[idx++] = greens[i];
colorTable[idx++] = blues[i];
}
} else if (sampleModel.getNumBands() == 1) {
// create gray-scaled color table for single-banded images
int numBits = sampleModel.getSampleSize()[0];
if (numBits > 8) {
numBits = 8;
}
int colorTableLength = 3*(1 << numBits);
colorTable = new byte[colorTableLength];
for (int i = 0; i < colorTableLength; i++) {
colorTable[i] = (byte)(i/3);
}
} else {
// We do not have enough information here
// to create well-fit color table for RGB image.
colorTable = null;
}
return colorTable;
}