本文整理匯總了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);
}
}