本文整理汇总了Java中sun.awt.image.IntegerComponentRaster.getDataOffset方法的典型用法代码示例。如果您正苦于以下问题:Java IntegerComponentRaster.getDataOffset方法的具体用法?Java IntegerComponentRaster.getDataOffset怎么用?Java IntegerComponentRaster.getDataOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.awt.image.IntegerComponentRaster
的用法示例。
在下文中一共展示了IntegerComponentRaster.getDataOffset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRaster
import sun.awt.image.IntegerComponentRaster; //导入方法依赖的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: getRaster
import sun.awt.image.IntegerComponentRaster; //导入方法依赖的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);
}
return rast;
}
示例3: getRaster
import sun.awt.image.IntegerComponentRaster; //导入方法依赖的package包/类
public Raster getRaster(int x, int y, int w, int h) {
double rowrel = (x - myX1) * myDx + (y - myY1) * myDy;
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();
clipFillRaster(pixels, off, adjust, w, h, rowrel, myDx, myDy);
return rast;
}
示例4: fromFXImage
import sun.awt.image.IntegerComponentRaster; //导入方法依赖的package包/类
/**
* Snapshots the specified JavaFX {@link Image} object and stores a copy of
* its pixels into a {@link BufferedImage} object, creating a new object if
* needed. The method will only convert a JavaFX {@code Image} that is
* readable as per the conditions on the {@link Image#getPixelReader()
* Image.getPixelReader()} method. If the {@code Image} is not readable, as
* determined by its {@code getPixelReader()} method, then this method will
* return null. If the {@code Image} is a writable, or other dynamic image,
* then the {@code BufferedImage} will only be set to the current state of
* the pixels in the image as determined by its {@link PixelReader}. Further
* changes to the pixels of the {@code Image} will not be reflected in the
* returned {@code BufferedImage}.
* <p>
* The optional {@code BufferedImage} parameter may be reused to store the
* copy of the pixels. A new {@code BufferedImage} will be created if the
* supplied object is null, is too small or of a type which the image pixels
* cannot be easily converted into.
*
* @param img
* the JavaFX {@code Image} to be converted
* @param bimg
* an optional {@code BufferedImage} object that may be used to
* store the returned pixel data
* @return a {@code BufferedImage} containing a snapshot of the JavaFX
* {@code Image}, or null if the {@code Image} is not readable.
* @since JavaFX 2.2
*/
public static BufferedImage fromFXImage(Image img, BufferedImage bimg) {
PixelReader pr = img.getPixelReader();
if (pr == null) {
return null;
}
int iw = (int) img.getWidth();
int ih = (int) img.getHeight();
int prefBimgType = getBestBufferedImageType(pr.getPixelFormat(), bimg);
if (bimg != null) {
int bw = bimg.getWidth();
int bh = bimg.getHeight();
if (bw < iw || bh < ih || bimg.getType() != prefBimgType) {
bimg = null;
} else if (iw < bw || ih < bh) {
Graphics2D g2d = bimg.createGraphics();
g2d.setComposite(AlphaComposite.Clear);
g2d.fillRect(0, 0, bw, bh);
g2d.dispose();
}
}
if (bimg == null) {
bimg = new BufferedImage(iw, ih, prefBimgType);
}
IntegerComponentRaster icr = (IntegerComponentRaster) bimg.getRaster();
int offset = icr.getDataOffset(0);
int scan = icr.getScanlineStride();
int data[] = icr.getDataStorage();
WritablePixelFormat<IntBuffer> pf = getAssociatedPixelFormat(bimg);
pr.getPixels(0, 0, iw, ih, pf, data, offset, scan);
return bimg;
}
示例5: getRaster
import sun.awt.image.IntegerComponentRaster; //导入方法依赖的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.
*/
@Override
public Raster getRaster(int x, int y, int w, int h) {
double rowrel = (x - x1) * dx + (y - y1) * dy;
WritableRaster rast = saved;
if (rast == null || rast.getWidth() < w || rast.getHeight() < h) {
rast = getColorModel().createCompatibleWritableRaster(w, h);
saved = rast;
}
//TODO: If this throws, it's probably because it can't do the gradient "flowing".
// Once we figure out a way not to use com.sun.*, we can fix this.
try {
IntegerComponentRaster irast = (IntegerComponentRaster) rast;
int off = irast.getDataOffset(0);
int adjust = irast.getScanlineStride() - w;
int[] pixels = irast.getDataStorage();
//Log it...
Logging.log("In getRaster(" + x + "," + y + "," + w + "," + h + "),"
+ " off=" + off + ", adjust=" + adjust + ", pixels.len=" + pixels.length);
if (cyclic) {
cycleFillRaster(pixels, off, adjust, w, h, rowrel, dx, dy);
} else {
clipFillRaster(pixels, off, adjust, w, h, rowrel, dx, dy);
}
} catch (Exception e) {
//Logging.log(e);
}
return rast;
}
示例6: Blit
import sun.awt.image.IntegerComponentRaster; //导入方法依赖的package包/类
public void Blit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int srcx, int srcy, int dstx, int dsty, int w, int h)
{
Raster srcRast = src.getRaster(srcx, srcy, w, h);
ColorModel srcCM = src.getColorModel();
Raster dstRast = dst.getRaster(dstx, dsty, w, h);
IntegerComponentRaster icr = (IntegerComponentRaster) dstRast;
int[] dstPix = icr.getDataStorage();
Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
srcx, srcy,
dstx, dsty, w, h);
SpanIterator si = roi.getSpanIterator();
Object srcPix = null;
int dstScan = icr.getScanlineStride();
// assert(icr.getPixelStride() == 1);
srcx -= dstx;
srcy -= dsty;
int span[] = new int[4];
while (si.nextSpan(span)) {
int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0];
for (int y = span[1]; y < span[3]; y++) {
int off = rowoff;
for (int x = span[0]; x < span[2]; x++) {
srcPix = srcRast.getDataElements(x+srcx, y+srcy, srcPix);
dstPix[off++] = srcCM.getRGB(srcPix);
}
rowoff += dstScan;
}
}
// Pixels in the dest were modified directly, we must
// manually notify the raster that it was modified
icr.markDirty();
// REMIND: We need to do something to make sure that dstRast
// is put back to the destination (as in the native Release
// function)
// src.releaseRaster(srcRast); // NOP?
// dst.releaseRaster(dstRast);
}