本文整理汇总了Java中java.awt.image.WritableRaster.getMinY方法的典型用法代码示例。如果您正苦于以下问题:Java WritableRaster.getMinY方法的具体用法?Java WritableRaster.getMinY怎么用?Java WritableRaster.getMinY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.WritableRaster
的用法示例。
在下文中一共展示了WritableRaster.getMinY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reformatDiscontiguousData
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/**
* Reformats bit-discontiguous data into the {@code DataBuffer}
* of the supplied {@code WritableRaster}.
*/
private static void reformatDiscontiguousData(byte[] buf,
int[] bitsPerSample,
int stride,
int w,
int h,
WritableRaster raster)
throws IOException {
// Get SampleModel info.
SampleModel sm = raster.getSampleModel();
int numBands = sm.getNumBands();
// Initialize input stream.
ByteArrayInputStream is = new ByteArrayInputStream(buf);
ImageInputStream iis = new MemoryCacheImageInputStream(is);
// Reformat.
long iisPosition = 0L;
int y = raster.getMinY();
for(int j = 0; j < h; j++, y++) {
iis.seek(iisPosition);
int x = raster.getMinX();
for(int i = 0; i < w; i++, x++) {
for(int b = 0; b < numBands; b++) {
long bits = iis.readBits(bitsPerSample[b]);
raster.setSample(x, y, b, (int)bits);
}
}
iisPosition += stride;
}
}
示例2: zoom
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/**
* Filters a portion of the source image.
*
* @param dstR the destination tile to calculate
* @param dst_fr the bounds of the whole destination image
* @param srcI the source image
* @param filter the filter to apply
* @throws ClassCastException if <code>srcI</code> does not store its data
* in a {@link DataBufferInt}
*/
public static void zoom(
WritableRaster dstR,
Rectangle dst_fr,
BufferedImage srcI,
final Filter filter)
{
final int dst_data[] = ((DataBufferInt) dstR.getDataBuffer()).getData();
final int src_type;
if (srcI.getTransparency() == BufferedImage.OPAQUE) {
src_type = OPAQUE;
}
else if (srcI.isAlphaPremultiplied()) {
src_type = TRANS_PREMULT;
}
else {
src_type = TRANS_UNPREMULT;
}
final int dx0 = dstR.getMinX();
final int dy0 = dstR.getMinY();
final int dx1 = dx0 + dstR.getWidth() - 1;
final int dy1 = dy0 + dstR.getHeight() - 1;
final int dw = dstR.getWidth();
final int dh = dstR.getHeight();
final int dstWidth = dst_fr.width;
final int dstHeight = dst_fr.height;
final int srcWidth = srcI.getWidth();
final int srcHeight = srcI.getHeight();
// We want dstX0 * xscale = srcX0, except when that would make
// xscale = 0; similarly for yscale.
final float xscale =
srcWidth == 1 ? dstWidth : (float)(dstWidth-1) / (srcWidth-1);
final float yscale =
srcHeight == 1 ? dstHeight : (float)(dstHeight-1) / (srcHeight-1);
final float fwidth = filter.getSamplingRadius();
final int sx0 = Math.max(0, (int) Math.floor((dx0-fwidth)/xscale));
final int sy0 = Math.max(0, (int) Math.floor((dy0-fwidth)/yscale));
final int sx1 = Math.min(srcWidth-1, (int) Math.ceil((dx1+fwidth)/xscale));
final int sy1 = Math.min(srcHeight-1, (int) Math.ceil((dy1+fwidth)/yscale));
final int sw = sx1 - sx0 + 1;
final int sh = sy1 - sy0 + 1;
final int src_data[] =
((DataBufferInt) srcI.getRaster().getDataBuffer()).getData();
resample(
src_data, false,
sx0, sy0, sx1, sy1, sw, sh, src_type, srcWidth, srcHeight,
dst_data, dx0, dy0, dx1, dy1, dw, dh, dstWidth, dstHeight,
xscale, yscale, filter
);
}