本文整理汇总了Java中java.awt.image.WritableRaster.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java WritableRaster.getHeight方法的具体用法?Java WritableRaster.getHeight怎么用?Java WritableRaster.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.WritableRaster
的用法示例。
在下文中一共展示了WritableRaster.getHeight方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintOverArea
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/**
* change an area of pixels around a pixel to a specified color
*/
private static void paintOverArea(int centerX, int centerY, int areaSize, Color color, WritableRaster raster) {
for (int x = centerX - areaSize; x < raster.getWidth() && x < centerX + areaSize; x++) {
x = x < 0 ? 0 : x; // ArrayOutOfBound protection
for (int y = centerY - areaSize; y < raster.getHeight() && y < centerY + areaSize; y++) {
y = y < 0 ? 0 : y; // ArrayOutOfBound protection
int[] strip = getPixelValue(raster, x, y);
changeColor(strip, color);
raster.setPixel(x, y, strip);
}
}
}
示例2: makeGrayscaleImage
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public static BufferedImage makeGrayscaleImage(float[][] mat) {
mat = padAndNormalize(mat);
final BufferedImage img = new BufferedImage(Math.min(mat.length, maxDim), Math.min(mat[0].length, maxDim), BufferedImage.TYPE_BYTE_GRAY);
WritableRaster writeableRaster = img.getRaster();
for (int i=0; i<writeableRaster.getWidth(); ++i) {
for (int j=0; j<writeableRaster.getHeight(); ++j) {
writeableRaster.setPixel(i, writeableRaster.getHeight()-1-j, new float[] { mat[i][j] * 255 });
}
}
return img;
}
示例3: makeByteRaster
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
synchronized static WritableRaster makeByteRaster(Raster srcRas,
int w, int h)
{
if (byteRasRef != null) {
WritableRaster wr = (WritableRaster) byteRasRef.get();
if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
byteRasRef = null;
return wr;
}
}
// If we are going to cache this Raster, make it non-tiny
if (w <= 32 && h <= 32) {
w = h = 32;
}
return srcRas.createCompatibleWritableRaster(w, h);
}
示例4: getRaster
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public synchronized Raster getRaster(int x, int y, int w, int h) {
WritableRaster t = savedTile;
if (t == null || w > t.getWidth() || h > t.getHeight()) {
t = getColorModel().createCompatibleWritableRaster(w, h);
IntegerComponentRaster icr = (IntegerComponentRaster) t;
Arrays.fill(icr.getDataStorage(), color);
// Note - markDirty is probably unnecessary since icr is brand new
icr.markDirty();
if (w <= 64 && h <= 64) {
savedTile = t;
}
}
return t;
}
示例5: getSplits
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
private static int[] getSplits(BufferedImage image, String name) {
WritableRaster raster = image.getRaster();
int startX = getSplitPoint(raster, name, 1, 0, true, true);
int endX = getSplitPoint(raster, name, startX, 0, false, true);
int startY = getSplitPoint(raster, name, 0, 1, true, false);
int endY = getSplitPoint(raster, name, 0, startY, false, false);
getSplitPoint(raster, name, endX + 1, 0, true, true);
getSplitPoint(raster, name, 0, endY + 1, true, false);
if (startX == 0 && endX == 0 && startY == 0 && endY == 0) return null;
if (startX != 0) {
startX--;
endX = raster.getWidth() - 2 - (endX - 1);
} else {
endX = raster.getWidth() - 2;
}
if (startY != 0) {
startY--;
endY = raster.getHeight() - 2 - (endY - 1);
} else {
endY = raster.getHeight() - 2;
}
return new int[]{startX, endX, startY, endY};
}
示例6: getSplitPoint
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
private static int getSplitPoint(WritableRaster raster, String name, int startX, int startY, boolean startPoint, boolean xAxis) {
int[] rgba = new int[4];
int next = xAxis ? startX : startY;
int end = xAxis ? raster.getWidth() : raster.getHeight();
int breakA = startPoint ? 255 : 0;
int x = startX;
int y = startY;
while (next != end) {
if (xAxis) {
x = next;
} else {
y = next;
}
raster.getPixel(x, y, rgba);
if (rgba[3] == breakA) return next;
if (!startPoint && (rgba[0] != 0 || rgba[1] != 0 || rgba[2] != 0 || rgba[3] != 255))
splitError(x, y, rgba, name);
next++;
}
return 0;
}
示例7: makeByteRaster
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
static synchronized WritableRaster makeByteRaster(Raster srcRas,
int w, int h)
{
if (byteRasRef != null) {
WritableRaster wr = (WritableRaster) byteRasRef.get();
if (wr != null && wr.getWidth() >= w && wr.getHeight() >= h) {
byteRasRef = null;
return wr;
}
}
// If we are going to cache this Raster, make it non-tiny
if (w <= 32 && h <= 32) {
w = h = 32;
}
return srcRas.createCompatibleWritableRaster(w, h);
}
示例8: getSplits
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/** Returns the splits, or null if the image had no splits or the splits were only a single region. Splits are an int[4] that
* has left, right, top, bottom. */
public int[] getSplits (BufferedImage image, String name) {
WritableRaster raster = image.getRaster();
int startX = getSplitPoint(raster, name, 1, 0, true, true);
int endX = getSplitPoint(raster, name, startX, 0, false, true);
int startY = getSplitPoint(raster, name, 0, 1, true, false);
int endY = getSplitPoint(raster, name, 0, startY, false, false);
// Ensure pixels after the end are not invalid.
getSplitPoint(raster, name, endX + 1, 0, true, true);
getSplitPoint(raster, name, 0, endY + 1, true, false);
// No splits, or all splits.
if (startX == 0 && endX == 0 && startY == 0 && endY == 0) return null;
// Subtraction here is because the coordinates were computed before the 1px border was stripped.
if (startX != 0) {
startX--;
endX = raster.getWidth() - 2 - (endX - 1);
} else {
// If no start point was ever found, we assume full stretch.
endX = raster.getWidth() - 2;
}
if (startY != 0) {
startY--;
endY = raster.getHeight() - 2 - (endY - 1);
} else {
// If no start point was ever found, we assume full stretch.
endY = raster.getHeight() - 2;
}
return new int[] {startX, endX, startY, endY};
}
示例9: getSplitPoint
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/** Hunts for the start or end of a sequence of split pixels. Begins searching at (startX, startY) then follows along the x or y
* axis (depending on value of xAxis) for the first non-transparent pixel if startPoint is true, or the first transparent pixel
* if startPoint is false. Returns 0 if none found, as 0 is considered an invalid split point being in the outer border which
* will be stripped. */
static private int getSplitPoint (WritableRaster raster, String name, int startX, int startY, boolean startPoint, boolean xAxis) {
int[] rgba = new int[4];
int next = xAxis ? startX : startY;
int end = xAxis ? raster.getWidth() : raster.getHeight();
int breakA = startPoint ? 255 : 0;
int x = startX;
int y = startY;
while (next != end) {
if (xAxis)
x = next;
else
y = next;
raster.getPixel(x, y, rgba);
if (rgba[3] == breakA) return next;
if (!startPoint && (rgba[0] != 0 || rgba[1] != 0 || rgba[2] != 0 || rgba[3] != 255)) {
// error
}
next++;
}
return 0;
}
示例10: Any
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public Any(WritableRaster srcRas, ColorModel cm,
AffineTransform xform, int maxw, boolean filter)
{
super(cm, xform, srcRas.getWidth(), srcRas.getHeight(), maxw);
this.srcRas = srcRas;
this.filter = filter;
}
示例11: getPads
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/** Returns the pads, or null if the image had no pads or the pads match the splits. Pads are an int[4] that has left, right,
* top, bottom. */
public int[] getPads (BufferedImage image, String name, int[] splits) {
WritableRaster raster = image.getRaster();
int bottom = raster.getHeight() - 1;
int right = raster.getWidth() - 1;
int startX = getSplitPoint(raster, name, 1, bottom, true, true);
int startY = getSplitPoint(raster, name, right, 1, true, false);
// No need to hunt for the end if a start was never found.
int endX = 0;
int endY = 0;
if (startX != 0) endX = getSplitPoint(raster, name, startX + 1, bottom, false, true);
if (startY != 0) endY = getSplitPoint(raster, name, right, startY + 1, false, false);
// Ensure pixels after the end are not invalid.
getSplitPoint(raster, name, endX + 1, bottom, true, true);
getSplitPoint(raster, name, right, endY + 1, true, false);
// No pads.
if (startX == 0 && endX == 0 && startY == 0 && endY == 0) {
return null;
}
// -2 here is because the coordinates were computed before the 1px border was stripped.
if (startX == 0 && endX == 0) {
startX = -1;
endX = -1;
} else {
if (startX > 0) {
startX--;
endX = raster.getWidth() - 2 - (endX - 1);
} else {
// If no start point was ever found, we assume full stretch.
endX = raster.getWidth() - 2;
}
}
if (startY == 0 && endY == 0) {
startY = -1;
endY = -1;
} else {
if (startY > 0) {
startY--;
endY = raster.getHeight() - 2 - (endY - 1);
} else {
// If no start point was ever found, we assume full stretch.
endY = raster.getHeight() - 2;
}
}
int[] pads = new int[] {startX, endX, startY, endY};
if (splits != null && Arrays.equals(pads, splits)) {
return null;
}
return pads;
}
示例12: 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
);
}
示例13: getPads
import java.awt.image.WritableRaster; //导入方法依赖的package包/类
private static int[] getPads(BufferedImage image, String name, int[] splits) {
WritableRaster raster = image.getRaster();
int bottom = raster.getHeight() - 1;
int right = raster.getWidth() - 1;
int startX = getSplitPoint(raster, name, 1, bottom, true, true);
int startY = getSplitPoint(raster, name, right, 1, true, false);
int endX = 0;
int endY = 0;
if (startX != 0) endX = getSplitPoint(raster, name, startX + 1, bottom, false, true);
if (startY != 0) endY = getSplitPoint(raster, name, right, startY + 1, false, false);
getSplitPoint(raster, name, endX + 1, bottom, true, true);
getSplitPoint(raster, name, right, endY + 1, true, false);
if (startX == 0 && endX == 0 && startY == 0 && endY == 0) {
return null;
}
if (startX == 0 && endX == 0) {
startX = -1;
endX = -1;
} else {
if (startX > 0) {
startX--;
endX = raster.getWidth() - 2 - (endX - 1);
} else {
endX = raster.getWidth() - 2;
}
}
if (startY == 0 && endY == 0) {
startY = -1;
endY = -1;
} else {
if (startY > 0) {
startY--;
endY = raster.getHeight() - 2 - (endY - 1);
} else {
endY = raster.getHeight() - 2;
}
}
int[] pads = new int[]{startX, endX, startY, endY};
if (splits != null && Arrays.equals(pads, splits)) {
return null;
}
return pads;
}