本文整理汇总了Java中java.awt.image.Raster.createChild方法的典型用法代码示例。如果您正苦于以下问题:Java Raster.createChild方法的具体用法?Java Raster.createChild怎么用?Java Raster.createChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.Raster
的用法示例。
在下文中一共展示了Raster.createChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Blit
import java.awt.image.Raster; //导入方法依赖的package包/类
public void Blit(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int srcx, int srcy,
int dstx, int dsty,
int width, int height)
{
ColorModel srcCM = srcData.getColorModel();
ColorModel dstCM = dstData.getColorModel();
// REMIND: Should get RenderingHints from sg2d
CompositeContext ctx = comp.createContext(srcCM, dstCM,
new RenderingHints(null));
Raster srcRas = srcData.getRaster(srcx, srcy, width, height);
WritableRaster dstRas =
(WritableRaster) dstData.getRaster(dstx, dsty, width, height);
if (clip == null) {
clip = Region.getInstanceXYWH(dstx, dsty, width, height);
}
int span[] = {dstx, dsty, dstx+width, dsty+height};
SpanIterator si = clip.getSpanIterator(span);
srcx -= dstx;
srcy -= dsty;
while (si.nextSpan(span)) {
int w = span[2] - span[0];
int h = span[3] - span[1];
Raster tmpSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
w, h, 0, 0, null);
WritableRaster tmpDstRas = dstRas.createWritableChild(span[0], span[1],
w, h, 0, 0, null);
ctx.compose(tmpSrcRas, tmpDstRas, tmpDstRas);
}
ctx.dispose();
}
示例2: writeIDAT
import java.awt.image.Raster; //导入方法依赖的package包/类
private void writeIDAT() throws IOException
{
IDATOutputStream ios = new IDATOutputStream(dataOutput, 8192);
DeflaterOutputStream dos = new DeflaterOutputStream(ios,
new Deflater(9));
// Future work - don't convert entire image to a Raster It
// might seem that you could just call image.getData() but
// 'BufferedImage.subImage' doesn't appear to set the Width
// and height properly of the Child Raster, so the Raster
// you get back here appears larger than it should.
// This solves that problem by bounding the raster to the
// image's bounds...
Raster ras = image.getData(new Rectangle(image.getMinX(), image
.getMinY(), image.getWidth(), image.getHeight()));
// System.out.println("Image: [" +
// image.getMinY() + ", " +
// image.getMinX() + ", " +
// image.getWidth() + ", " +
// image.getHeight() + "]");
// System.out.println("Ras: [" +
// ras.getMinX() + ", " +
// ras.getMinY() + ", " +
// ras.getWidth() + ", " +
// ras.getHeight() + "]");
if (skipAlpha)
{
int numBands = ras.getNumBands() - 1;
int[] bandList = new int[numBands];
for (int i = 0; i < numBands; i++)
{
bandList[i] = i;
}
ras = ras.createChild(0, 0, ras.getWidth(), ras.getHeight(), 0, 0,
bandList);
}
if (interlace)
{
// Interlacing pass 1
encodePass(dos, ras, 0, 0, 8, 8);
// Interlacing pass 2
encodePass(dos, ras, 4, 0, 8, 8);
// Interlacing pass 3
encodePass(dos, ras, 0, 4, 4, 8);
// Interlacing pass 4
encodePass(dos, ras, 2, 0, 4, 4);
// Interlacing pass 5
encodePass(dos, ras, 0, 2, 2, 4);
// Interlacing pass 6
encodePass(dos, ras, 1, 0, 2, 2);
// Interlacing pass 7
encodePass(dos, ras, 0, 1, 1, 2);
}
else
{
encodePass(dos, ras, 0, 0, 1, 1);
}
dos.finish();
ios.flush();
}
示例3: copyData
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Copies an arbitrary rectangular region of the RenderedImage
* into a caller-supplied WritableRaster. The region to be
* computed is determined by clipping the bounds of the supplied
* WritableRaster against the bounds of the image. The supplied
* WritableRaster must have a SampleModel that is compatible with
* that of the image.
*
* <p> If the raster argument is null, the entire image will
* be copied into a newly-created WritableRaster with a SampleModel
* that is compatible with that of the image.
*
* @param dest a WritableRaster to hold the returned portion of
* the image.
* @return a reference to the supplied WritableRaster, or to a
* new WritableRaster if the supplied one was null.
*/
public WritableRaster copyData(WritableRaster dest) {
// Get the image bounds.
Rectangle imageBounds = getBounds();
Rectangle bounds;
if (dest == null) {
// Create a WritableRaster for the entire image.
bounds = imageBounds;
Point p = new Point(minX, minY);
SampleModel sm =
sampleModel.createCompatibleSampleModel(width, height);
dest = Raster.createWritableRaster(sm, p);
} else {
bounds = dest.getBounds();
}
// Determine tile limits for the intersection of the prescribed
// bounds with the image bounds.
Rectangle xsect = imageBounds.contains(bounds) ?
bounds : bounds.intersection(imageBounds);
int startX = XToTileX(xsect.x);
int startY = YToTileY(xsect.y);
int endX = XToTileX(xsect.x + xsect.width - 1);
int endY = YToTileY(xsect.y + xsect.height - 1);
// Loop over the tiles in the intersection.
for (int j = startY; j <= endY; j++) {
for (int i = startX; i <= endX; i++) {
// Retrieve the tile.
Raster tile = getTile(i, j);
// Create a child of the tile for the intersection of
// the tile bounds and the bounds of the requested area.
Rectangle tileRect = tile.getBounds();
Rectangle intersectRect =
bounds.intersection(tile.getBounds());
Raster liveRaster = tile.createChild(intersectRect.x,
intersectRect.y,
intersectRect.width,
intersectRect.height,
intersectRect.x,
intersectRect.y,
null);
// Copy the data from the child.
dest.setRect(liveRaster);
}
}
return dest;
}