本文整理汇总了Java中java.awt.image.Raster.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Raster.getWidth方法的具体用法?Java Raster.getWidth怎么用?Java Raster.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.Raster
的用法示例。
在下文中一共展示了Raster.getWidth方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCachedRaster
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Took this cacheRaster code from GradientPaint. It appears to recycle
* rasters for use by any other instance, as long as they are sufficiently
* large.
*/
private static synchronized Raster getCachedRaster(ColorModel cm,
int w, int h)
{
if (cm == cachedModel) {
if (cached != null) {
Raster ras = (Raster) cached.get();
if (ras != null &&
ras.getWidth() >= w &&
ras.getHeight() >= h)
{
cached = null;
return ras;
}
}
}
return cm.createCompatibleWritableRaster(w, h);
}
示例2: setDataElements
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Stores the Raster data at the specified location.
* An ArrayIndexOutOfBounds exception will be thrown at runtime
* if the pixel coordinates are out of bounds.
* @param x The X coordinate of the pixel location.
* @param y The Y coordinate of the pixel location.
* @param inRaster Raster of data to place at x,y location.
*/
public void setDataElements(int x, int y, Raster inRaster) {
int srcOffX = inRaster.getMinX();
int srcOffY = inRaster.getMinY();
int dstOffX = x + srcOffX;
int dstOffY = y + srcOffY;
int width = inRaster.getWidth();
int height = inRaster.getHeight();
if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
(dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
setDataElements(dstOffX, dstOffY, srcOffX, srcOffY,
width, height, inRaster);
}
示例3: getCachedRaster
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Took this cacheRaster code from GradientPaint. It appears to recycle
* rasters for use by any other instance, as long as they are sufficiently
* large.
*/
private static synchronized Raster getCachedRaster(ColorModel cm,
int w, int h)
{
if (cm == cachedModel) {
if (cached != null) {
Raster ras = cached.get();
if (ras != null &&
ras.getWidth() >= w &&
ras.getHeight() >= h)
{
cached = null;
return ras;
}
}
}
return cm.createCompatibleWritableRaster(w, h);
}
示例4: getCachedRaster
import java.awt.image.Raster; //导入方法依赖的package包/类
static synchronized Raster getCachedRaster(ColorModel cm, int w, int h) {
if (cm == cachedModel) {
if (cached != null) {
Raster ras = (Raster) cached.get();
if (ras != null &&
ras.getWidth() >= w &&
ras.getHeight() >= h)
{
cached = null;
return ras;
}
}
}
return cm.createCompatibleWritableRaster(w, h);
}
示例5: getRaster
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public final Raster getRaster(int x, int y, int w, int h) {
// If working raster is big enough, reuse it. Otherwise,
// build a large enough new one.
Raster raster = saved;
if (raster == null ||
raster.getWidth() < w || raster.getHeight() < h)
{
raster = getCachedRaster(model, w, h);
saved = raster;
}
// Access raster internal int array. Because we use a DirectColorModel,
// we know the DataBuffer is of type DataBufferInt and the SampleModel
// is SinglePixelPackedSampleModel.
// Adjust for initial offset in DataBuffer and also for the scanline
// stride.
// These calls make the DataBuffer non-acceleratable, but the
// Raster is never Stable long enough to accelerate anyway...
DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
int[] pixels = rasterDB.getData(0);
int off = rasterDB.getOffset();
int scanlineStride = ((SinglePixelPackedSampleModel)
raster.getSampleModel()).getScanlineStride();
int adjust = scanlineStride - w;
fillRaster(pixels, off, adjust, x, y, w, h); // delegate to subclass
return raster;
}
示例6: setDataElements
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Stores the Raster data at the specified location.
* The transferType of the inputRaster must match this raster.
* An ArrayIndexOutOfBoundsException will be thrown at runtime
* if the pixel coordinates are out of bounds.
* @param x The X coordinate of the pixel location.
* @param y The Y coordinate of the pixel location.
* @param inRaster Raster of data to place at x,y location.
*/
public void setDataElements(int x, int y, Raster inRaster) {
int dstOffX = x + inRaster.getMinX();
int dstOffY = y + inRaster.getMinY();
int width = inRaster.getWidth();
int height = inRaster.getHeight();
if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
(dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
示例7: setDataElements
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Stores the Raster data at the specified location.
* An ArrayIndexOutOfBounds exception will be thrown at runtime
* if the pixel coordinates are out of bounds.
* @param x The X coordinate of the pixel location.
* @param y The Y coordinate of the pixel location.
* @param inRaster Raster of data to place at x,y location.
*/
public void setDataElements(int x, int y, Raster inRaster) {
int dstOffX = x + inRaster.getMinX();
int dstOffY = y + inRaster.getMinY();
int width = inRaster.getWidth();
int height = inRaster.getHeight();
if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
(dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
示例8: setRect
import java.awt.image.Raster; //导入方法依赖的package包/类
public void setRect(int dx, int dy, Raster srcRaster) {
if (!(srcRaster instanceof ByteInterleavedRaster)) {
super.setRect(dx, dy, srcRaster);
return;
}
int width = srcRaster.getWidth();
int height = srcRaster.getHeight();
int srcOffX = srcRaster.getMinX();
int srcOffY = srcRaster.getMinY();
int dstOffX = dx+srcOffX;
int dstOffY = dy+srcOffY;
// Clip to this raster
if (dstOffX < this.minX) {
int skipX = minX - dstOffX;
width -= skipX;
srcOffX += skipX;
dstOffX = this.minX;
}
if (dstOffY < this.minY) {
int skipY = this.minY - dstOffY;
height -= skipY;
srcOffY += skipY;
dstOffY = this.minY;
}
if (dstOffX+width > this.maxX) {
width = this.maxX - dstOffX;
}
if (dstOffY+height > this.maxY) {
height = this.maxY - dstOffY;
}
setDataElements(dstOffX, dstOffY,
srcOffX, srcOffY,
width, height, srcRaster);
}
示例9: setDataElements
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Stores the Raster data at the specified location.
* The transferType of the inputRaster must match this raster.
* An ArrayIndexOutOfBoundsException will be thrown at runtime
* if the pixel coordinates are out of bounds.
* @param x The X coordinate of the pixel location.
* @param y The Y coordinate of the pixel location.
* @param inRaster Raster of data to place at x,y location.
*/
public void setDataElements(int x, int y, Raster inRaster) {
int dstOffX = x + inRaster.getMinX();
int dstOffY = y + inRaster.getMinY();
int width = inRaster.getWidth();
int height = inRaster.getHeight();
if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
(dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
示例10: setDataElements
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Stores the Raster data at the specified location.
* An ArrayIndexOutOfBounds exception will be thrown at runtime
* if the pixel coordinates are out of bounds.
* @param x The X coordinate of the pixel location.
* @param y The Y coordinate of the pixel location.
* @param inRaster Raster of data to place at x,y location.
*/
public void setDataElements(int x, int y, Raster inRaster) {
int dstOffX = inRaster.getMinX() + x;
int dstOffY = inRaster.getMinY() + y;
int width = inRaster.getWidth();
int height = inRaster.getHeight();
if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
(dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
示例11: getCachedRaster
import java.awt.image.Raster; //导入方法依赖的package包/类
static synchronized Raster getCachedRaster(ColorModel cm, int w, int h) {
if (cm == cachedModel) {
if (cached != null) {
Raster ras = cached.get();
if (ras != null &&
ras.getWidth() >= w &&
ras.getHeight() >= h)
{
cached = null;
return ras;
}
}
}
return cm.createCompatibleWritableRaster(w, h);
}
示例12: getVerticalRulings
import java.awt.image.Raster; //导入方法依赖的package包/类
private List<Ruling> getVerticalRulings(BufferedImage image) {
// get all vertical edges, which we'll define as a change in grayscale colour
// along a straight line of a certain length
ArrayList<Ruling> verticalRulings = new ArrayList<>();
Raster r = image.getRaster();
int width = r.getWidth();
int height = r.getHeight();
for (int y = 0; y < height; y++) {
int[] lastPixel = r.getPixel(0, y, (int[]) null);
for (int x = 1; x < width - 1; x++) {
int[] currPixel = r.getPixel(x, y, (int[]) null);
int diff = Math.abs(currPixel[0] - lastPixel[0]);
if (diff > GRAYSCALE_INTENSITY_THRESHOLD) {
// we hit what could be a line
// don't bother scanning it if we've hit a pixel in the line before
boolean alreadyChecked = false;
for (Line2D.Float line : verticalRulings) {
if (x == line.getX1() && y >= line.getY1() && y <= line.getY2()) {
alreadyChecked = true;
break;
}
}
if (alreadyChecked) {
lastPixel = currPixel;
continue;
}
int lineY = y + 1;
while (lineY < height) {
int[] linePixel = r.getPixel(x, lineY, (int[]) null);
int[] leftPixel = r.getPixel(x - 1, lineY, (int[]) null);
if (Math.abs(linePixel[0] - leftPixel[0]) <= GRAYSCALE_INTENSITY_THRESHOLD
|| Math.abs(currPixel[0] - linePixel[0]) > GRAYSCALE_INTENSITY_THRESHOLD) {
break;
}
lineY++;
}
int endY = lineY - 1;
int lineLength = endY - y;
if (lineLength > VERTICAL_EDGE_HEIGHT_MINIMUM) {
verticalRulings.add(new Ruling(new Point2D.Float(x, y), new Point2D.Float(x, endY)));
}
}
lastPixel = currPixel;
}
}
return verticalRulings;
}
示例13: setRect
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Copies pixels from Raster srcRaster to this WritableRaster.
* For each (x, y) address in srcRaster, the corresponding pixel
* is copied to address (x+dx, y+dy) in this WritableRaster,
* unless (x+dx, y+dy) falls outside the bounds of this raster.
* srcRaster must have the same number of bands as this WritableRaster.
* The copy is a simple copy of source samples to the corresponding
* destination samples. For details, see
* {@link WritableRaster#setRect(Raster)}.
*
* @param dx The X translation factor from src space to dst space
* of the copy.
* @param dy The Y translation factor from src space to dst space
* of the copy.
* @param srcRaster The Raster from which to copy pixels.
*/
public void setRect(int dx, int dy, Raster srcRaster) {
// Check if we can use fast code
if (!(srcRaster instanceof BytePackedRaster) ||
((BytePackedRaster)srcRaster).pixelBitStride != pixelBitStride) {
super.setRect(dx, dy, srcRaster);
return;
}
int width = srcRaster.getWidth();
int height = srcRaster.getHeight();
int srcOffX = srcRaster.getMinX();
int srcOffY = srcRaster.getMinY();
int dstOffX = dx+srcOffX;
int dstOffY = dy+srcOffY;
// Clip to this raster
if (dstOffX < this.minX) {
int skipX = this.minX - dstOffX;
width -= skipX;
srcOffX += skipX;
dstOffX = this.minX;
}
if (dstOffY < this.minY) {
int skipY = this.minY - dstOffY;
height -= skipY;
srcOffY += skipY;
dstOffY = this.minY;
}
if (dstOffX+width > this.maxX) {
width = this.maxX - dstOffX;
}
if (dstOffY+height > this.maxY) {
height = this.maxY - dstOffY;
}
setDataElements(dstOffX, dstOffY,
srcOffX, srcOffY,
width, height,
(BytePackedRaster)srcRaster);
}