當前位置: 首頁>>代碼示例>>Java>>正文


Java IndexColorModel.getGreens方法代碼示例

本文整理匯總了Java中java.awt.image.IndexColorModel.getGreens方法的典型用法代碼示例。如果您正苦於以下問題:Java IndexColorModel.getGreens方法的具體用法?Java IndexColorModel.getGreens怎麽用?Java IndexColorModel.getGreens使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.image.IndexColorModel的用法示例。


在下文中一共展示了IndexColorModel.getGreens方法的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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:JFIFMarkerSegment.java

示例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);
}
 
開發者ID:MinesJTK,項目名稱:jtk,代碼行數:22,代碼來源:ColorMap.java

示例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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:GIFImageReader.java

示例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));
	}
}
 
開發者ID:imagingbook,項目名稱:imagingbook-common,代碼行數:21,代碼來源:LookupTables.java

示例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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:62,代碼來源:GIFImageWriter.java


注:本文中的java.awt.image.IndexColorModel.getGreens方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。