本文整理汇总了Java中javax.media.jai.ImageLayout.getColorModel方法的典型用法代码示例。如果您正苦于以下问题:Java ImageLayout.getColorModel方法的具体用法?Java ImageLayout.getColorModel怎么用?Java ImageLayout.getColorModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.jai.ImageLayout
的用法示例。
在下文中一共展示了ImageLayout.getColorModel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AffineNearestBinaryOpImage
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
* Constructs an AffineNearestBinaryOpImage from a RenderedImage source,
*
* @param source a RenderedImage.
* @param layout an ImageLayout optionally containing the tile grid layout,
* SampleModel, and ColorModel, or null.
* @param interp an Interpolation object to use for resampling
* @param transform the desired AffineTransform.
*/
public AffineNearestBinaryOpImage(RenderedImage source,
BorderExtender extender,
Map config,
ImageLayout layout,
AffineTransform transform,
Interpolation interp,
double[] backgroundValues) {
super(source,
extender,
configHelper(config),
layout,
transform,
interp,
backgroundValues);
// Propagate source's ColorModel and SampleModel but change tile size.
if (layout != null) {
colorModel = layout.getColorModel(source);
} else {
colorModel = source.getColorModel();
}
sampleModel =
source.getSampleModel().createCompatibleSampleModel(tileWidth,
tileHeight);
// Set the background to color to 1 if the color
// model specifies that as "black", otherwise 0.
//
// This cause problem on the background (Bug 4380285): because
// (1) if the tile does not intersect with the source, zeroed tile(white
// is created; (2) if the line does not intersect with the source,
// zeroed-line is created; (3) if the image area does not equal to
// the whole destination rectangle, some white line will be displayed.
//
//if (colorModel.getRGB(1) == 0xff000000) {
// black = 1;
//}
}
示例2: ScaleNearestBinaryOpImage
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
* Constructs a ScaleNearestBinaryOpImage from a RenderedImage source,
*
* @param source a RenderedImage.
* @param layout an ImageLayout optionally containing the tile grid layout,
* SampleModel, and ColorModel, or null.
* @param xScale scale factor along x axis.
* @param yScale scale factor along y axis.
* @param xTrans translation factor along x axis.
* @param yTrans translation factor along y axis.
* @param interp an Interpolation object to use for resampling.
*/
public ScaleNearestBinaryOpImage(RenderedImage source,
BorderExtender extender,
Map config,
ImageLayout layout,
float xScale,
float yScale,
float xTrans,
float yTrans,
Interpolation interp) {
super(source,
layout,
config,
true,
extender,
interp,
xScale,
yScale,
xTrans,
yTrans);
// Propagate source's ColorModel
if (layout != null) {
colorModel = layout.getColorModel(source);
} else {
colorModel = source.getColorModel();
}
sampleModel =
source.getSampleModel().createCompatibleSampleModel(tileWidth,
tileHeight);
if (invScaleXRational.num > invScaleXRational.denom) {
invScaleXInt = invScaleXRational.num / invScaleXRational.denom;
invScaleXFrac = invScaleXRational.num % invScaleXRational.denom;
} else {
invScaleXInt = 0;
invScaleXFrac = invScaleXRational.num;
}
if (invScaleYRational.num > invScaleYRational.denom) {
invScaleYInt = invScaleYRational.num / invScaleYRational.denom;
invScaleYFrac = invScaleYRational.num % invScaleYRational.denom;
} else {
invScaleYInt = 0;
invScaleYFrac = invScaleYRational.num;
}
}
示例3: layoutHelper
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
* Override the dimension specification for the destination such that it
* has width and height which are equal to non-negative powers of 2.
*/
private static ImageLayout layoutHelper(ImageLayout layout,
RenderedImage source) {
// Create an ImageLayout or clone the one passed in.
ImageLayout il = layout == null ?
new ImageLayout() : (ImageLayout)layout.clone();
// Force the origin to coincide with that of the source.
il.setMinX(source.getMinX());
il.setMinY(source.getMinY());
// Recalculate the non-unity dimensions to be a positive power of 2.
// XXX This calculation should not be effected if an implementation
// of the FCT which supports arbitrary dimensions is used.
boolean createNewSampleModel = false;
int w = il.getWidth(source);
if(w > 1) {
int newWidth = MathJAI.nextPositivePowerOf2(w);
if(newWidth != w) {
il.setWidth(w = newWidth);
createNewSampleModel = true;
}
}
int h = il.getHeight(source);
if(h > 1) {
int newHeight = MathJAI.nextPositivePowerOf2(h);
if(newHeight != h) {
il.setHeight(h = newHeight);
createNewSampleModel = true;
}
}
// Force the image to contain floating point data.
SampleModel sm = il.getSampleModel(source);
int dataType = sm.getTransferType();
if(dataType != DataBuffer.TYPE_FLOAT &&
dataType != DataBuffer.TYPE_DOUBLE) {
dataType = DataBuffer.TYPE_FLOAT;
createNewSampleModel = true;
}
// Create a new SampleModel for the destination.
if(createNewSampleModel) {
sm = RasterFactory.createComponentSampleModel(sm, dataType, w, h,
sm.getNumBands());
il.setSampleModel(sm);
// Clear the ColorModel mask if needed.
ColorModel cm = il.getColorModel(null);
if(cm != null &&
!JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
// Clear the mask bit if incompatible.
il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
}
}
return il;
}
示例4: layoutHelper
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
private static ImageLayout layoutHelper(Vector sources,
ImageLayout il) {
ImageLayout layout = (il == null) ? new ImageLayout() : (ImageLayout)il.clone();
int numSources = sources.size();
// dest data type is the maximum of transfertype of source image
// utilizing the monotonicity of data types.
// dest number of bands = sum of source bands
int destNumBands = totalNumBands(sources);
int destDataType = DataBuffer.TYPE_BYTE; // initialize
RenderedImage srci = (RenderedImage)sources.get(0);
Rectangle destBounds = new Rectangle(srci.getMinX(), srci.getMinY(),
srci.getWidth(), srci.getHeight());
for ( int i = 0; i < numSources; i++ ) {
srci = (RenderedImage)sources.get(i);
destBounds = destBounds.intersection(new Rectangle(srci.getMinX(), srci.getMinY(),
srci.getWidth(), srci.getHeight()));
int typei = srci.getSampleModel().getTransferType();
// NOTE: this depends on JDK ordering
destDataType = typei > destDataType ? typei : destDataType;
}
SampleModel sm = layout.getSampleModel((RenderedImage)sources.get(0));
if ( sm.getNumBands() < destNumBands ) {
int[] destOffsets = new int[destNumBands];
for(int i=0; i < destNumBands; i++) {
destOffsets[i] = i;
}
// determine the proper width and height to use
int destTileWidth = sm.getWidth();
int destTileHeight = sm.getHeight();
if(layout.isValid(ImageLayout.TILE_WIDTH_MASK))
{
destTileWidth =
layout.getTileWidth((RenderedImage)sources.get(0));
}
if(layout.isValid(ImageLayout.TILE_HEIGHT_MASK))
{
destTileHeight =
layout.getTileHeight((RenderedImage)sources.get(0));
}
sm = RasterFactory.createComponentSampleModel(sm,
destDataType,
destTileWidth,
destTileHeight,
destNumBands);
layout.setSampleModel(sm);
}
ColorModel cm = layout.getColorModel(null);
if ( cm != null &&
!JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
// Clear the mask bit if incompatible.
layout.unsetValid(ImageLayout.COLOR_MODEL_MASK);
}
return layout;
}
示例5: ScaleBilinearBinaryOpImage
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
* Constructs a ScaleBilinearBinaryOpImage from a RenderedImage source,
*
* @param source a RenderedImage.
* @param layout an ImageLayout optionally containing the tile grid layout,
* SampleModel, and ColorModel, or null.
* @param xScale scale factor along x axis.
* @param yScale scale factor along y axis.
* @param xTrans translation factor along x axis.
* @param yTrans translation factor along y axis.
* @param interp an Interpolation object to use for resampling.
*/
public ScaleBilinearBinaryOpImage(RenderedImage source,
BorderExtender extender,
Map config,
ImageLayout layout,
float xScale,
float yScale,
float xTrans,
float yTrans,
Interpolation interp)
{
super(source,
layout,
config,
true,
extender,
interp,
xScale,
yScale,
xTrans,
yTrans);
subsampleBits = interp.getSubsampleBitsH ();
// Numnber of subsampling positions
one = 1 << subsampleBits;
//Subsampling related variables
shift2 = 2 * subsampleBits;
round2 = 1 << (shift2 - 1);
// Propagate source's ColorModel
if (layout != null)
{
colorModel = layout.getColorModel(source);
}
else
{
colorModel = source.getColorModel();
}
sampleModel = source.getSampleModel().createCompatibleSampleModel(tileWidth, tileHeight);
if (invScaleXRational.num > invScaleXRational.denom)
{
invScaleXInt = invScaleXRational.num / invScaleXRational.denom;
invScaleXFrac = invScaleXRational.num % invScaleXRational.denom;
}
else
{
invScaleXInt = 0;
invScaleXFrac = invScaleXRational.num;
}
if (invScaleYRational.num > invScaleYRational.denom)
{
invScaleYInt = invScaleYRational.num / invScaleYRational.denom;
invScaleYFrac = invScaleYRational.num % invScaleYRational.denom;
}
else
{
invScaleYInt = 0;
invScaleYFrac = invScaleYRational.num;
}
}
示例6: layoutHelper
import javax.media.jai.ImageLayout; //导入方法依赖的package包/类
/**
* Force the destination image to have a signed data type.
*/
private static ImageLayout layoutHelper(ImageLayout layout,
RenderedImage source) {
// Create or clone the layout.
ImageLayout il = layout == null ?
new ImageLayout() : (ImageLayout)layout.clone();
// Get the reference SampleModel.
SampleModel sm = il.getSampleModel(source);
// Get the data type.
int dataType = sm.getTransferType();
// Determine whether the destination requires a different data type
// and set it if so.
boolean createNewSampleModel = false;
if(dataType == DataBuffer.TYPE_BYTE) {
dataType = DataBuffer.TYPE_SHORT;
createNewSampleModel = true;
} else if(dataType == DataBuffer.TYPE_USHORT) {
dataType = DataBuffer.TYPE_INT;
createNewSampleModel = true;
}
// Create a new SampleModel for the destination if necessary.
if(createNewSampleModel) {
sm = RasterFactory.createComponentSampleModel(sm, dataType,
sm.getWidth(),
sm.getHeight(),
sm.getNumBands());
il.setSampleModel(sm);
// Check ColorModel.
ColorModel cm = il.getColorModel(null);
if(cm != null &&
!JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
// Clear the mask bit if incompatible.
il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
}
}
return il;
}