本文整理汇总了Java中java.awt.image.Raster.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Raster.getHeight方法的具体用法?Java Raster.getHeight怎么用?Java Raster.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.Raster
的用法示例。
在下文中一共展示了Raster.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRaster
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Return a Raster containing the colors generated for the graphics
* operation.
* @param x,y,w,h The area in device space for which colors are
* generated.
*/
public Raster getRaster(int x, int y, int w, int h) {
double rowrel = (x - x1) * dx + (y - y1) * dy;
Raster rast = saved;
if (rast == null || rast.getWidth() < w || rast.getHeight() < h) {
rast = getCachedRaster(model, w, h);
saved = rast;
}
IntegerComponentRaster irast = (IntegerComponentRaster) rast;
int off = irast.getDataOffset(0);
int adjust = irast.getScanlineStride() - w;
int[] pixels = irast.getDataStorage();
if (cyclic) {
cycleFillRaster(pixels, off, adjust, w, h, rowrel, dx, dy);
} else {
clipFillRaster(pixels, off, adjust, w, h, rowrel, dx, dy);
}
irast.markDirty();
return rast;
}
示例2: putCachedRaster
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 void putCachedRaster(ColorModel cm,
Raster ras)
{
if (cached != null) {
Raster cras = cached.get();
if (cras != null) {
int cw = cras.getWidth();
int ch = cras.getHeight();
int iw = ras.getWidth();
int ih = ras.getHeight();
if (cw >= iw && ch >= ih) {
return;
}
if (cw * ch >= iw * ih) {
return;
}
}
}
cachedModel = cm;
cached = new WeakReference<Raster>(ras);
}
示例3: putCachedRaster
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 void putCachedRaster(ColorModel cm,
Raster ras)
{
if (cached != null) {
Raster cras = (Raster) cached.get();
if (cras != null) {
int cw = cras.getWidth();
int ch = cras.getHeight();
int iw = ras.getWidth();
int ih = ras.getHeight();
if (cw >= iw && ch >= ih) {
return;
}
if (cw * ch >= iw * ih) {
return;
}
}
}
cachedModel = cm;
cached = new WeakReference<Raster>(ras);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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;
}
示例8: compose
import java.awt.image.Raster; //导入方法依赖的package包/类
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
int w = src.getWidth();
int h = src.getHeight();
DataBufferInt srcDB = (DataBufferInt) src.getDataBuffer();
DataBufferInt dstOutDB = (DataBufferInt) dstOut.getDataBuffer();
int srcRGB[] = srcDB.getBankData()[0];
int dstOutRGB[] = dstOutDB.getBankData()[0];
int srcOffset = srcDB.getOffset();
int dstOutOffset = dstOutDB.getOffset();
int srcScanStride = ((SinglePixelPackedSampleModel) src.getSampleModel()).getScanlineStride();
int dstOutScanStride = ((SinglePixelPackedSampleModel) dstOut.getSampleModel()).getScanlineStride();
int srcAdjust = srcScanStride - w;
int dstOutAdjust = dstOutScanStride - w;
int si = srcOffset;
int doi = dstOutOffset;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
dstOutRGB[doi] = srcRGB[si] ^ 0x00ffffff;
si++;
doi++;
}
si += srcAdjust;
doi += dstOutAdjust;
}
}
示例9: 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);
}
示例10: 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);
}
示例11: SingleTileRenderedImage
import java.awt.image.Raster; //导入方法依赖的package包/类
/**
* Constructs a SingleTileRenderedImage based on a Raster
* and a ColorModel.
*
* @param ras A Raster that will define tile (0, 0) of the image.
* @param colorModel A ColorModel that will serve as the image's
* ColorModel.
*/
public SingleTileRenderedImage(Raster ras, ColorModel colorModel) {
this.ras = ras;
this.tileGridXOffset = this.minX = ras.getMinX();
this.tileGridYOffset = this.minY = ras.getMinY();
this.tileWidth = this.width = ras.getWidth();
this.tileHeight = this.height = ras.getHeight();
this.sampleModel = ras.getSampleModel();
this.colorModel = colorModel;
}
示例12: 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);
}
示例13: 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);
}
示例14: 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);
}
示例15: createImage
import java.awt.image.Raster; //导入方法依赖的package包/类
private opj_image createImage(Raster img) {
int numBands = img.getSampleModel().getNumBands();
if (numBands != 3 && numBands != 1) {
throw new IllegalArgumentException("Image must be RGB or Greyscale");
}
if (!(img.getSampleModel() instanceof PixelInterleavedSampleModel)) {
throw new IllegalArgumentException("Image must be of the 3BYTE_BGR or BYTE_GRAY");
}
opj_image_comptparm parms[] = Struct.arrayOf(runtime, opj_image_comptparm.class, numBands);
for (int i=0; i < numBands; i++) {
parms[i].prec.set(8); // One byte per component
parms[i].bpp.set(8); // 8bit depth
parms[i].sgnd.set(0);
parms[i].dx.set(1);
parms[i].dy.set(1);
parms[i].w.set(img.getWidth());
parms[i].h.set(img.getHeight());
}
COLOR_SPACE cspace = numBands == 3 ? COLOR_SPACE.OPJ_CLRSPC_SRGB : COLOR_SPACE.OPJ_CLRSPC_GRAY;
opj_image outImg = new opj_image(runtime);
Pointer imgPtr = lib.opj_image_create(parms.length, Struct.getMemory(parms[0]), cspace);
outImg.useMemory(imgPtr);
outImg.x0.set(0);
outImg.y0.set(0);
outImg.x1.set(img.getWidth());
outImg.y1.set(img.getHeight());
byte[] imgData = ((DataBufferByte) img.getDataBuffer()).getData();
int numcomps = (int) outImg.numcomps.get();
opj_image_comp[] comps = outImg.comps.get(numcomps);
if (numcomps > 1) {
Pointer red = comps[0].data.get();
Pointer green = comps[1].data.get();
Pointer blue = comps[2].data.get();
int offset = 0;
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
red.putByte(offset * 4, imgData[offset * 3 + 2]);
green.putByte(offset * 4, imgData[offset * 3 + 1]);
blue.putByte(offset * 4, imgData[offset * 3]);
offset += 1;
}
}
} else {
Pointer ptr = comps[0].data.get();
for (int i=0; i < img.getWidth() * img.getHeight(); i++) {
ptr.putByte(i*4, imgData[i]);
}
}
return outImg;
}