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


Java IndexColorModel.getMapSize方法代码示例

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


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

示例1: 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

示例2: createIndexedImage

import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
protected static BufferedImage createIndexedImage(int w, int h,
                                                  IndexColorModel icm)
{
    BufferedImage img = new BufferedImage(w, h,
                                          BufferedImage.TYPE_BYTE_INDEXED,
                                          icm);

    int mapSize = icm.getMapSize();
    int width = w / mapSize;

    WritableRaster wr = img.getRaster();
    for (int i = 0; i < mapSize; i++) {
        for (int y = 0; y < h; y++) {
            for (int x = 0; x < width; x++) {
                wr.setSample(i * width + x, y, 0, i);
            }
        }
    }
    return img;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:TransparencyTest.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: gethISTNode

import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
private IIOMetadataNode gethISTNode(BufferedImage bi) {
    IndexColorModel icm = (IndexColorModel)bi.getColorModel();
    int mapSize = icm.getMapSize();

    int[] hist = new int[mapSize];
    Arrays.fill(hist, 0);

    Raster r = bi.getData();
    for (int y = 0; y < bi.getHeight(); y++) {
        for (int x = 0; x < bi.getWidth(); x++) {
            int s = r.getSample(x, y, 0);
            hist[s] ++;
        }
    }

    IIOMetadataNode hIST = new IIOMetadataNode("hIST");
    for (int i = 0; i < hist.length; i++) {
        IIOMetadataNode n = new IIOMetadataNode("hISTEntry");
        n.setAttribute("index", "" + i);
        n.setAttribute("value", "" + hist[i]);
        hIST.appendChild(n);
    }

    return hIST;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ShortHistogramTest.java

示例5: brightLut

import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
/**
 * Modifies the lookup table to display a bright image with gray values
 * in the range minGray ... 255. Does nothing if ip is of type
 * ColorProcessor.
 * 
 * @param ip The target image.
 * @param minGray Minimum gray value.
 */
public static void brightLut(ImageProcessor ip, int minGray) {
	if (minGray < 0 || minGray >= 255)
		return;
	ColorModel cm = ip.getColorModel();
	if (!(cm instanceof IndexColorModel))
		return;
	IndexColorModel icm = (IndexColorModel) cm;
	int mapSize = icm.getMapSize();
	byte[] reds = new byte[mapSize];
	byte[] grns = new byte[mapSize];
	byte[] blus = new byte[mapSize];
	float scale = (255 - minGray) / 255f;
	for (int i = 0; i < mapSize; i++) {
		byte g = (byte) (Math.round(minGray + scale * i) & 0xFF);
		reds[i] = g;
		grns[i] = g;
		blus[i] = g;
	}
	ip.setColorModel(new IndexColorModel(8, mapSize, reds, grns, blus));
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:29,代码来源:LookupTables.java

示例6: isMultiColor

import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
/**
 * Determines if a specified color map has more than one color.
 * Note that we ignore any variation in alpha.
 */
private static boolean isMultiColor(ColorMapped cm) {
  ColorMap cmap = cm.getColorMap();
  IndexColorModel icm = cmap.getColorModel();
  int n = icm.getMapSize();
  int rgb = icm.getRGB(0)&0x00ffffff;
  for (int i=1; i<n; ++i) 
    if (rgb!=(icm.getRGB(i)&0x00ffffff))
      return true;
  return false;
}
 
开发者ID:MinesJTK,项目名称:jtk,代码行数:15,代码来源:PlotPanel.java

示例7: isFilterableICM

import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
public static boolean isFilterableICM(ColorModel cm) {
    if (cm instanceof IndexColorModel) {
        IndexColorModel icm = (IndexColorModel) cm;
        if (icm.getMapSize() <= 256) {
            return true;
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:TexturePaintContext.java

示例8: JFIFThumbPalette

import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
JFIFThumbPalette(BufferedImage thumb) throws IllegalThumbException {
    super(thumb);
    IndexColorModel icm = (IndexColorModel) thumbnail.getColorModel();
    if (icm.getMapSize() > 256) {
        throw new IllegalThumbException();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:JFIFMarkerSegment.java

示例9: drawDIBImage

import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
protected void drawDIBImage(byte[] image,
                            float destX, float destY,
                            float destWidth, float destHeight,
                            float srcX, float srcY,
                            float srcWidth, float srcHeight,
                            int sampleBitsPerPixel,
                            IndexColorModel icm) {
    int bitCount = 24;
    byte[] bmiColors = null;

    if (icm != null) {
        bitCount = sampleBitsPerPixel;
        bmiColors = new byte[(1<<icm.getPixelSize())*4];
        for (int i=0;i<icm.getMapSize(); i++) {
            bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff);
            bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff);
            bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff);
        }
    }

    drawDIBImage(getPrintDC(), image,
                 destX, destY,
                 destWidth, destHeight,
                 srcX, srcY,
                 srcWidth, srcHeight,
                 bitCount, bmiColors);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:WPrinterJob.java

示例10: 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

示例11: setColorModel

import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
public void setColorModel(ColorModel model) {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    srcModel = model;

    // Check to see if model is INT_RGB
    if (model instanceof IndexColorModel) {
        if (model.getTransparency() == model.TRANSLUCENT) {
            // REMIND:
            // Probably need to composite anyway so force ARGB
            cmodel = ColorModel.getRGBdefault();
            srcLUT = null;
        }
        else {
            IndexColorModel icm = (IndexColorModel) model;
            numSrcLUT = icm.getMapSize();
            srcLUT = new int[Math.max(numSrcLUT, 256)];
            icm.getRGBs(srcLUT);
            srcLUTtransIndex = icm.getTransparentPixel();
            cmodel = model;
        }
    }
    else {
        if (cmodel == null) {
            cmodel = model;
            srcLUT   = null;
        }
        else if (model instanceof DirectColorModel) {
            // If it is INT_RGB or INT_ARGB, use the model
            DirectColorModel dcm = (DirectColorModel) model;
            if ((dcm.getRedMask() == 0xff0000) &&
                (dcm.getGreenMask() == 0xff00) &&
                (dcm.getBlueMask()  == 0x00ff)) {
                cmodel   = model;
                srcLUT   = null;
            }
        }
    }

    isSameCM = (cmodel == model);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:ImageRepresentation.java

示例12: 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

示例13: setColorModel

import java.awt.image.IndexColorModel; //导入方法依赖的package包/类
public void setColorModel(ColorModel model) {
    if (src != null) {
        src.checkSecurity(null, false);
    }
    srcModel = model;

    // Check to see if model is INT_RGB
    if (model instanceof IndexColorModel) {
        if (model.getTransparency() == Transparency.TRANSLUCENT) {
            // REMIND:
            // Probably need to composite anyway so force ARGB
            cmodel = ColorModel.getRGBdefault();
            srcLUT = null;
        }
        else {
            IndexColorModel icm = (IndexColorModel) model;
            numSrcLUT = icm.getMapSize();
            srcLUT = new int[Math.max(numSrcLUT, 256)];
            icm.getRGBs(srcLUT);
            srcLUTtransIndex = icm.getTransparentPixel();
            cmodel = model;
        }
    }
    else {
        if (cmodel == null) {
            cmodel = model;
            srcLUT   = null;
        }
        else if (model instanceof DirectColorModel) {
            // If it is INT_RGB or INT_ARGB, use the model
            DirectColorModel dcm = (DirectColorModel) model;
            if ((dcm.getRedMask() == 0xff0000) &&
                (dcm.getGreenMask() == 0xff00) &&
                (dcm.getBlueMask()  == 0x00ff)) {
                cmodel   = model;
                srcLUT   = null;
            }
        }
    }

    isSameCM = (cmodel == model);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:ImageRepresentation.java


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