本文整理汇总了Java中java.awt.image.WritableRaster.createWritableChild方法的典型用法代码示例。如果您正苦于以下问题:Java WritableRaster.createWritableChild方法的具体用法?Java WritableRaster.createWritableChild怎么用?Java WritableRaster.createWritableChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.WritableRaster
的用法示例。
在下文中一共展示了WritableRaster.createWritableChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Blit
import java.awt.image.WritableRaster; //导入方法依赖的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: read
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public synchronized WritableRaster read(Rectangle rect) {
tileParam.setSourceRegion(isSubsampling ?
new Rectangle(subsampleX*rect.x,
subsampleY*rect.y,
subsampleX*rect.width,
subsampleY*rect.height) :
rect);
try {
BufferedImage bi = reader.read(imageIndex, tileParam);
WritableRaster ras = bi.getRaster();
return ras.createWritableChild(0, 0,
ras.getWidth(), ras.getHeight(),
rect.x, rect.y,
null);
} catch (IOException e) {
throw new RuntimeException(e);
}
}