本文整理了Java中javax.media.jai.JAI
类的一些代码示例,展示了JAI
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JAI
类的具体详情如下:
包路径:javax.media.jai.JAI
类名称:JAI
暂无
代码示例来源:origin: geotools/geotools
public static RenderedOp create(RenderedImage source0, FillType type, RenderingHints hints) {
ParameterBlockJAI pb =
new ParameterBlockJAI("TransparencyFill", RenderedRegistryMode.MODE_NAME);
pb.setSource("source0", source0);
pb.setParameter("type", type);
return JAI.create("TransparencyFill", pb, hints);
}
}
代码示例来源:origin: geoserver/geoserver
final OperationRegistry opRegistry = JAI.getDefaultInstance().getOperationRegistry();
for (String mode : RegistryMode.getModeNames()) {
for (Iterator descriptors = opRegistry.getDescriptors(mode).iterator();
代码示例来源:origin: geoserver/geoserver
JAI.getDefaultInstance()
.setImagingListener(
new ImagingListener() {
final Logger LOGGER = Logging.getLogger("javax.media.jai");
JAI jaiDef = JAI.getDefaultInstance();
if (!(jaiDef.getOperationRegistry() instanceof ConcurrentOperationRegistry
|| jaiDef.getOperationRegistry()
instanceof it.geosolutions.jaiext.ConcurrentOperationRegistry)) {
jaiDef.setOperationRegistry(ConcurrentOperationRegistry.initializeRegistry());
if (!(jaiDef.getTileCache() instanceof ConcurrentTileCacheMultiMap)) {
jaiDef.setTileCache(new ConcurrentTileCacheMultiMap());
代码示例来源:origin: geoserver/geoserver
public static OperationRegistry initializeRegistry() {
try {
InputStream url = PropertyUtil.getFileFromClasspath(JAI_REGISTRY_FILE);
if (url == null) {
throw new RuntimeException("Could not find the main registry file");
}
OperationRegistry registry = new ConcurrentOperationRegistry();
if (url != null) {
registry.updateFromStream(url);
}
registry.registerServices(null);
return registry;
} catch (IOException ioe) {
ImagingListener listener = JAI.getDefaultInstance().getImagingListener();
String message = "Error occurred while initializing JAI";
listener.errorOccurred(
message, new ImagingException(message, ioe), OperationRegistry.class, false);
return null;
}
}
代码示例来源:origin: geoserver/geoserver
void initJAI(JAIInfo jai) {
JAI jaiDef = JAI.getDefaultInstance();
jai.setJAI(jaiDef);
if (ImageWorker.isJaiExtEnabled()) {
if (jai.getJAIEXTInfo() != null) {
JAIEXTInfo jaiext = jai.getJAIEXTInfo();
jaiDef.setRenderingHint(JAI.KEY_CACHED_TILE_RECYCLING_ENABLED, jai.isRecycling());
&& !(jaiDef.getRenderingHint(JAI.KEY_TILE_FACTORY)
instanceof ConcurrentTileFactory)) {
final ConcurrentTileFactory recyclingFactory = new ConcurrentTileFactory();
jaiDef.setRenderingHint(JAI.KEY_TILE_FACTORY, recyclingFactory);
jaiDef.setRenderingHint(JAI.KEY_TILE_RECYCLER, recyclingFactory);
} else {
if (!jai.isRecycling()) {
final PassThroughTileFactory passThroughFactory = new PassThroughTileFactory();
jaiDef.setRenderingHint(JAI.KEY_TILE_FACTORY, passThroughFactory);
jaiDef.setRenderingHint(JAI.KEY_TILE_RECYCLER, passThroughFactory);
TileCache jaiCache = jaiDef.getTileCache();
jai.setTileCache(jaiCache);
jaiDef.getTileScheduler().setParallelism(jai.getTileThreads());
jaiDef.getTileScheduler().setPrefetchParallelism(jai.getTileThreads());
jaiDef.getTileScheduler().setPriority(jai.getTilePriority());
jaiDef.getTileScheduler().setPrefetchPriority(jai.getTilePriority());
代码示例来源:origin: geotools/geotools
ColorModel colorModel = image.getColorModel();
ParameterBlock pb = new ParameterBlock();
pb.setSource(image, 0);
pb.set(table, 0);
if (isNoDataNeeded()) {
result = JAI.create("Lookup", pb, hints);
expanded = new ImageWorker(image).forceComponentColorModel().getRenderedImage();
} else {
expanded = image;
if (!expanded.getColorModel().hasAlpha()) {
new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));
result = JAI.create("BandMerge", pb, null);
final int bands = expanded.getSampleModel().getNumBands();
int alphaBand = bands - 1;
opacity, bands, alphaBand, expanded.getSampleModel().getDataType());
result = JAI.create("Lookup", pb, null);
代码示例来源:origin: geotools/geotools
final ColorModel cm = image.getColorModel();
if (cm instanceof ComponentColorModel) {
final SampleModel sm = this.image.getSampleModel();
final int datatype = sm.getDataType();
Range noData = getNoData();
final boolean gray =
ColorUtilities.isGrayPalette(icm, checkTransparent)
Color bgColor = getBackgroundColor();
if (bgColor == null) {
bgColor = Color.BLACK;
for (int i = 0; i < numDestinationBands; i++) bits[i] = sm.getSampleSize(i);
final ComponentColorModel destinationColorModel =
new ComponentColorModel(
ParameterBlock pb = new ParameterBlock();
pb.setSource(image, 0);
pb.set(lut, 0);
image = JAI.create("Lookup", pb, hints);
(cm instanceof DirectColorModel)
? DataBuffer.TYPE_BYTE
: image.getSampleModel().getTransferType();
image = JAI.create("Format", pb, hints);
代码示例来源:origin: geotools/geotools
RenderedImage src = pb.getRenderedSource(0);
Object property = src.getProperty("ROI");
if (property == null
|| property.equals(java.awt.Image.UndefinedProperty)
Interpolation interp = (Interpolation) pb.getObjectParameter(1);
srcBounds =
new Rectangle(
src.getMinX() + interp.getLeftPadding(),
src.getMinY() + interp.getTopPadding(),
src.getWidth() - interp.getWidth() + 1,
src.getHeight() - interp.getHeight() + 1);
Warp warp = (Warp) pb.getObjectParameter(0);
layout.setTileHeight(op.getTileHeight());
RenderingHints hints = op.getRenderingHints();
hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));
warpingHints.remove(JAI.KEY_IMAGE_LAYOUT);
roiImage = JAI.create("Warp", paramBlk, localHints);
} else {
代码示例来源:origin: geotools/geotools
for (int i = 0; i < 4; i++) {
if (USE_JAI_SCALE2) {
pb.set(scalingParams[i], i);
} else {
pb.set((float) scalingParams[i], i);
RenderedImage sourceImage = pb.getRenderedSource(0);
ColorModel cm = sourceImage.getColorModel();
SampleModel sm = sourceImage.getSampleModel();
final int numBands = sm.getNumBands();
RenderedImage alphaChannel = null;
new ImageWorker(sourceImage).setRenderingHints(hints).retainBands(numBands - 1);
alphaChannel =
new ImageWorker(sourceImage)
RenderedImage scaledImage = JAI.create(SCALE_OP_NAME, pb, hints);
image = scaledImage;
if (alphaChannel != null) {
pb2.set(roi, 5);
pb2.set(nodata, 7);
alphaChannel = JAI.create(SCALE_OP_NAME, pb2, hints);
if (hints.containsKey(JAI.KEY_IMAGE_LAYOUT)) {
ImageLayout layout = (ImageLayout) hints.get(JAI.KEY_IMAGE_LAYOUT);
newImageLayout =
new ImageLayout2(
代码示例来源:origin: geotools/geotools
/** Forces the provided {@link ColorModel} via the JAI ColorConvert operation. */
private void forceColorModel(final ColorModel cm) {
final ImageLayout2 il = new ImageLayout2(image);
il.setColorModel(cm);
il.setSampleModel(cm.createCompatibleSampleModel(image.getWidth(), image.getHeight()));
final RenderingHints oldRi = this.getRenderingHints();
final RenderingHints newRi = (RenderingHints) oldRi.clone();
newRi.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il));
setRenderingHints(newRi);
// Setting the parameter blocks
ParameterBlock pb = new ParameterBlock();
pb.setSource(image, 0);
pb.set(cm, 0);
pb.set(roi, 1);
pb.set(nodata, 2);
if (isNoDataNeeded()) {
if (background != null && background.length > 0) {
// Elaborating the final NoData value
if (background.length != cm.getNumColorComponents()) {
throw new IllegalArgumentException("Wrong DestinationNoData value defined");
}
pb.set(background, 3);
}
}
image = JAI.create("ColorConvert", pb, getRenderingHints());
// restore RI
this.setRenderingHints(oldRi);
// invalidate stats
invalidateStatistics();
}
代码示例来源:origin: geotools/geotools
assert image.getColorModel() instanceof ComponentColorModel;
assert image.getSampleModel().getDataType() == DataBuffer.TYPE_BYTE;
int numBands = image.getSampleModel().getNumBands();
final int numColorBands = image.getColorModel().getNumColorComponents();
final RenderingHints hints = getRenderingHints();
if (numColorBands != numBands) {
ParameterBlock pb = new ParameterBlock();
pb.setSource(image, 0);
pb.set(opaqueBands, 0);
image = JAI.create("BandSelect", pb, hints);
numBands = numColorBands;
LookupTableFactory.create(tableData, image.getSampleModel().getDataType());
hints.put(JAI.KEY_TRANSFORM_ON_COLORMAP, Boolean.FALSE);
ParameterBlock pb = new ParameterBlock();
PlanarImage luImage = JAI.create("Lookup", pb, hints);
luImage = JAI.create("BandCombine", pb, getRenderingHints());
pb.set(roi, 3);
pb.set(true, 4);
image = JAI.create("BandMerge", pb, hints);
代码示例来源:origin: geotools/geotools
assert image.getColorModel() instanceof IndexColorModel;
IndexColorModel cm = (IndexColorModel) image.getColorModel();
final int numComponents = cm.getNumComponents();
int transparency = cm.getTransparency();
final RenderingHints hints = getRenderingHints();
hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));
hints.add(new RenderingHints(JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.FALSE));
ParameterBlock pb = new ParameterBlock();
pb.setSource(image, 0); // The source image.
pb.set(image.getSampleModel().getDataType(), 0);
image = JAI.create("Format", pb, hints);
setNoData(RangeFactory.convert(nodata, image.getSampleModel().getDataType()));
invalidateStatistics();
return this;
代码示例来源:origin: geotools/geotools
if (image.getMinX() == x
&& image.getMinY() == y
&& image.getWidth() == width
&& image.getHeight() == height) {
return this;
if ("Crop".equals(op.getOperationName()) || "GTCrop".equals(op.getOperationName())) {
ParameterBlock paramBlock = op.getParameterBlock();
source = paramBlock.getRenderedSource(0);
float sx = paramBlock.getFloatParameter(0);
float sy = paramBlock.getFloatParameter(1);
float sWidth = paramBlock.getFloatParameter(2);
float sHeight = paramBlock.getFloatParameter(3);
pb.set(roi, 4);
pb.set(nodata, 5);
if (isNoDataNeeded()) {
double destinationNoData =
nodata != null
image = JAI.create("Crop", pb, commonHints);
invalidateStatistics();
return this;
代码示例来源:origin: geotools/geotools
final ImageWorker worker = new ImageWorker(image);
worker.setROI(CoverageUtilities.getROIProperty(sourceCoverage));
NoDataContainer noDataProperty = CoverageUtilities.getNoDataProperty(sourceCoverage);
worker.setNoData(noDataProperty != null ? noDataProperty.getAsRange() : null);
if (image.getColorModel() instanceof IndexColorModel
&& (image.getSampleModel().getNumBands() > 1)) {
worker.retainBands(1);
image = worker.getRenderedImage();
if (image.getColorModel() instanceof DirectColorModel) {
worker.forceComponentColorModel();
image = worker.getRenderedImage();
if (image.getColorModel() instanceof IndexColorModel
&& (image.getSampleModel().getTransferType() != DataBuffer.TYPE_BYTE)) {
worker.forceComponentColorModel();
image = worker.getRenderedImage();
final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite");
pbjImageWrite.addSource(image);
pbjImageWrite.setParameter("Output", outstream);
pbjImageWrite.setParameter("VerifyOutput", Boolean.FALSE);
pbjImageWrite.setParameter("Format", extension);
JAI.create("ImageWrite", pbjImageWrite);
outstream.flush();
outstream.close();
代码示例来源:origin: GeoWebCache/geowebcache
/**
* Shave off the alpha band, JPEG cannot write it out
*
* @param ri
* @return
*/
@Override
public RenderedImage preprocess(RenderedImage ri) {
if (ri.getColorModel().hasAlpha()) {
final int numBands = ri.getSampleModel().getNumBands();
// handle both gray-alpha and RGBA (same code as in GeoTools ImageWorker)
final int[] bands = new int[numBands - 1];
for (int i = 0; i < bands.length; i++) {
bands[i] = i;
}
// ParameterBlock creation
ParameterBlock pb = new ParameterBlock();
pb.setSource(ri, 0);
pb.set(bands, 0);
final RenderingHints hints =
new RenderingHints(JAI.KEY_IMAGE_LAYOUT, new ImageLayout(ri));
ri = JAI.create("BandSelect", pb, hints);
}
return ri;
}
};
代码示例来源:origin: geotools/geotools
if ((image.getNumXTiles() == 1 || image.getTileWidth() < STRIPE_SIZE)
&& (image.getNumYTiles() == 1 || image.getTileHeight() < STRIPE_SIZE)) {
layout = layout.unsetTileLayout();
Dimension defaultSize = JAI.getDefaultTileSize();
if (defaultSize == null) {
defaultSize = GEOTOOLS_DEFAULT_TILE_SIZE;
代码示例来源:origin: geotools/geotools
final ColorModel cm = image.getColorModel();
if (cm instanceof IndexColorModel) {
final IndexColorModel oldCM = (IndexColorModel) cm;
LookupTableFactory.create(table, image.getSampleModel().getDataType());
} else {
final short[] table = new short[mapSize];
hints.put(JAI.KEY_TRANSFORM_ON_COLORMAP, Boolean.FALSE);
hints.put(JAI.KEY_IMAGE_LAYOUT, layout);
ParameterBlock pb = new ParameterBlock();
pb.setSource(image, 0);
pb.set(lookupTable, 0);
if (isNoDataNeeded()) {
image = JAI.create("Lookup", pb, hints);
int dataType = image.getSampleModel().getDataType();
pb.set(dataType, 0);
image = JAI.create("Format", pb, hints);
final RenderedOp alphaChannel = JAI.create("BandSelect", pb, hints);
代码示例来源:origin: geotools/geotools
final int numBands = sourceImage.getSampleModel().getNumBands();
if (band < 0 || band >= numBands) {
throw new ProcessException(Errors.format(ErrorKeys.ILLEGAL_ARGUMENT_$2, "band", band));
ParameterBlock pb = new ParameterBlock();
pb.addSource(sourceImage);
pb.set(classes, 0);
pb.set(toJAIExtMethod(method), 1);
pb.set(null, 2);
(Classification) op.getProperty(ClassBreaksDescriptor.CLASSIFICATION_PROPERTY);
ParameterBlockJAI pbj = new ParameterBlockJAI("ZonalStats");
pbj.addSource(sourceImage);
pbj.setParameter("stats", stats.toArray(new Statistic[stats.size()]));
pbj.setParameter("bands", new Integer[] {band});
pbj.setParameter("ranges", ranges);
op = JAI.create("ZonalStats", pbj);
(ZonalStats) op.getProperty(ZonalStatsDescriptor.ZONAL_STATS_PROPERTY);
return new Results(stats, zonalStats);
代码示例来源:origin: geotools/geotools
cm.getTransparency(),
cm.getTransferType());
sm = cm.createCompatibleSampleModel(sm.getWidth(), sm.getHeight());
Dimension tileSize = request.getTileDimensions();
if (tileSize == null) {
tileSize = JAI.getDefaultTileSize();
.setTileWidth((int) tileSize.getWidth())
.setTileHeight((int) tileSize.getHeight());
final RenderingHints renderingHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
new ImageWorker(finalImage)
.setRenderingHints(renderingHints)
.format(il.getSampleModel(null).getDataType())
.getRenderedImage();
.makeColorTransparent(inputTransparentColor)
.getRenderedImage();
hasAlpha = finalImage.getColorModel().hasAlpha();
if (!hasAlpha) {
.makeColorTransparent(inputTransparentColor)
.getRenderedImage();
hasAlpha = finalImage.getColorModel().hasAlpha();
代码示例来源:origin: geotools/geotools
LookupTableFactory.create(lutData, mask.getSampleModel().getDataType());
mask = JAI.create("Lookup", pb, hints);
prepareAlgebricOperation(Operator.SUM, pb, roi, nodata, true);
image = JAI.create(ALGEBRIC_OP_NAME, pb, getRenderingHints());
} else {
image = JAI.create("Add", pb, getRenderingHints());
new RenderingHints(JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.FALSE);
mask = JAI.create(ALGEBRIC_OP_NAME, pb, renderingHints);
} else {
mask = JAI.create("Not", pb, renderingHints);
image = JAI.create(ALGEBRIC_OP_NAME, pb, getRenderingHints());
} else {
image = JAI.create("And", pb, getRenderingHints());
image = JAI.create(OPERATION_CONST_OP_NAME, pb, renderingHints);
} else {
image = JAI.create("AddConst", pb, renderingHints);
image = JAI.create(ALGEBRIC_OP_NAME, pb, getRenderingHints());
} else {
image = JAI.create("Add", pb, getRenderingHints());
内容来源于网络,如有侵权,请联系作者删除!