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


Java RenderedImage.getSampleModel方法代碼示例

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


在下文中一共展示了RenderedImage.getSampleModel方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDefaultEncodeParam

import java.awt.image.RenderedImage; //導入方法依賴的package包/類
/**
 * Returns an instance of <code>PNGEncodeParam.Palette</code>,
 * <code>PNGEncodeParam.Gray</code>, or
 * <code>PNGEncodeParam.RGB</code> appropriate for encoding
 * the given image.
 *
 * <p> If the image has an <code>IndexColorModel</code>, an
 * instance of <code>PNGEncodeParam.Palette</code> is returned.
 * Otherwise, if the image has 1 or 2 bands an instance of
 * <code>PNGEncodeParam.Gray</code> is returned.  In all other
 * cases an instance of <code>PNGEncodeParam.RGB</code> is
 * returned.
 *
 * <p> Note that this method does not provide any guarantee that
 * the given image will be successfully encoded by the PNG
 * encoder, as it only performs a very superficial analysis of
 * the image structure.
 */
public static mxPngEncodeParam getDefaultEncodeParam(RenderedImage im)
{
	ColorModel colorModel = im.getColorModel();
	if (colorModel instanceof IndexColorModel)
	{
		return new mxPngEncodeParam.Palette();
	}

	SampleModel sampleModel = im.getSampleModel();
	int numBands = sampleModel.getNumBands();

	if (numBands == 1 || numBands == 2)
	{
		return new mxPngEncodeParam.Gray();
	}
	else
	{
		return new mxPngEncodeParam.RGB();
	}
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:39,代碼來源:mxPngEncodeParam.java

示例2: needToCreateIndex

import java.awt.image.RenderedImage; //導入方法依賴的package包/類
private boolean needToCreateIndex(RenderedImage image) {

        SampleModel sampleModel = image.getSampleModel();
        ColorModel colorModel = image.getColorModel();

        return sampleModel.getNumBands() != 1 ||
            sampleModel.getSampleSize()[0] > 8 ||
            colorModel.getComponentSize()[0] > 8;
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:GIFImageWriter.java

示例3: imageIsContiguous

import java.awt.image.RenderedImage; //導入方法依賴的package包/類
/**
 * Returns whether the image has contiguous data across rows.
 */
public static final boolean imageIsContiguous(RenderedImage image) {
    SampleModel sm;
    if(image instanceof BufferedImage) {
        WritableRaster ras = ((BufferedImage)image).getRaster();
        sm = ras.getSampleModel();
    } else {
        sm = image.getSampleModel();
    }

    if (sm instanceof ComponentSampleModel) {
        // Ensure image rows samples are stored contiguously
        // in a single bank.
        ComponentSampleModel csm = (ComponentSampleModel)sm;

        if (csm.getPixelStride() != csm.getNumBands()) {
            return false;
        }

        int[] bandOffsets = csm.getBandOffsets();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bandOffsets[i] != i) {
                return false;
            }
        }

        int[] bankIndices = csm.getBankIndices();
        for (int i = 0; i < bandOffsets.length; i++) {
            if (bankIndices[i] != 0) {
                return false;
            }
        }

        return true;
    }

    // Otherwise true if and only if it's a bilevel image with
    // a MultiPixelPackedSampleModel, 1 bit per pixel, and 1 bit
    // pixel stride.
    return ImageUtil.isBinary(sm);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:44,代碼來源:ImageUtil.java

示例4: ImageTypeSpecifier

import java.awt.image.RenderedImage; //導入方法依賴的package包/類
/**
 * Constructs an <code>ImageTypeSpecifier</code> from a
 * <code>RenderedImage</code>.  If a <code>BufferedImage</code> is
 * being used, one of the factory methods
 * <code>createFromRenderedImage</code> or
 * <code>createFromBufferedImageType</code> should be used instead in
 * order to get a more accurate result.
 *
 * @param image a <code>RenderedImage</code>.
 *
 * @exception IllegalArgumentException if the argument is
 * <code>null</code>.
 */
public ImageTypeSpecifier(RenderedImage image) {
    if (image == null) {
        throw new IllegalArgumentException("image == null!");
    }
    colorModel = image.getColorModel();
    sampleModel = image.getSampleModel();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:ImageTypeSpecifier.java

示例5: ImageTypeSpecifier

import java.awt.image.RenderedImage; //導入方法依賴的package包/類
/**
 * Constructs an {@code ImageTypeSpecifier} from a
 * {@code RenderedImage}.  If a {@code BufferedImage} is
 * being used, one of the factory methods
 * {@code createFromRenderedImage} or
 * {@code createFromBufferedImageType} should be used instead in
 * order to get a more accurate result.
 *
 * @param image a {@code RenderedImage}.
 *
 * @exception IllegalArgumentException if the argument is
 * {@code null}.
 */
public ImageTypeSpecifier(RenderedImage image) {
    if (image == null) {
        throw new IllegalArgumentException("image == null!");
    }
    colorModel = image.getColorModel();
    sampleModel = image.getSampleModel();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:ImageTypeSpecifier.java


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