本文整理汇总了Java中sun.awt.image.SunWritableRaster.stealData方法的典型用法代码示例。如果您正苦于以下问题:Java SunWritableRaster.stealData方法的具体用法?Java SunWritableRaster.stealData怎么用?Java SunWritableRaster.stealData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.awt.image.SunWritableRaster
的用法示例。
在下文中一共展示了SunWritableRaster.stealData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import sun.awt.image.SunWritableRaster; //导入方法依赖的package包/类
/**
* Updates the splash window with current contents of the overlay image.
*
* @throws IllegalStateException if the overlay image does not exist;
* for example, if {@code createGraphics} has never been called,
* or if the splash screen has already been closed
*/
public void update() throws IllegalStateException {
BufferedImage image;
synchronized (SplashScreen.class) {
checkVisible();
image = this.image;
}
if (image == null) {
throw new IllegalStateException("no overlay image available");
}
DataBuffer buf = image.getRaster().getDataBuffer();
if (!(buf instanceof DataBufferInt)) {
throw new AssertionError("Overlay image DataBuffer is of invalid type == "+buf.getClass().getName());
}
int numBanks = buf.getNumBanks();
if (numBanks!=1) {
throw new AssertionError("Invalid number of banks =="+numBanks+" in overlay image DataBuffer");
}
if (!(image.getSampleModel() instanceof SinglePixelPackedSampleModel)) {
throw new AssertionError("Overlay image has invalid sample model == "+image.getSampleModel().getClass().getName());
}
SinglePixelPackedSampleModel sm = (SinglePixelPackedSampleModel)image.getSampleModel();
int scanlineStride = sm.getScanlineStride();
Rectangle rect = image.getRaster().getBounds();
// Note that we steal the data array here, but just for reading
// so we do not need to mark the DataBuffer dirty...
int[] data = SunWritableRaster.stealData((DataBufferInt)buf, 0);
synchronized(SplashScreen.class) {
checkVisible();
_update(splashPtr, data, rect.x, rect.y, rect.width, rect.height, scanlineStride);
}
}
示例2: toImage
import sun.awt.image.SunWritableRaster; //导入方法依赖的package包/类
private BufferedImage toImage(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {
final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
final int[] buffer = SunWritableRaster.stealData(dbi, 0);
nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight);
SunWritableRaster.markDirty(dbi);
return bimg;
}
示例3: toImage
import sun.awt.image.SunWritableRaster; //导入方法依赖的package包/类
private BufferedImage toImage(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {
final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
final int[] buffer = SunWritableRaster.stealData(dbi, 0);
execute(ptr->nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight));
SunWritableRaster.markDirty(dbi);
return bimg;
}
示例4: toImage
import sun.awt.image.SunWritableRaster; //导入方法依赖的package包/类
private BufferedImage toImage(int dstWidth, int dstHeight) {
final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
final int[] buffer = SunWritableRaster.stealData(dbi, 0);
nativeCopyNSImageIntoArray(ptr, buffer, dstWidth, dstHeight);
SunWritableRaster.markDirty(dbi);
return bimg;
}
示例5: toImage
import sun.awt.image.SunWritableRaster; //导入方法依赖的package包/类
/** @return A BufferedImage created from nsImagePtr, or null. */
public BufferedImage toImage() {
if (ptr == 0) return null;
final Dimension2D size = nativeGetNSImageSize(ptr);
final int w = (int)size.getWidth();
final int h = (int)size.getHeight();
final BufferedImage bimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
final int[] buffer = SunWritableRaster.stealData(dbi, 0);
nativeCopyNSImageIntoArray(ptr, buffer, w, h);
SunWritableRaster.markDirty(dbi);
return bimg;
}
示例6: hasTransparentPixels
import sun.awt.image.SunWritableRaster; //导入方法依赖的package包/类
/**
* Return true if the BufferedImage argument has non-opaque
* bits in it and therefore can not be directly rendered by
* GDI. Return false if the image is opaque. If this function
* can not tell for sure whether the image has transparent
* pixels then it assumes that it does.
*/
protected boolean hasTransparentPixels(BufferedImage bufferedImage) {
ColorModel colorModel = bufferedImage.getColorModel();
boolean hasTransparency = colorModel == null
? true
: colorModel.getTransparency() != ColorModel.OPAQUE;
/*
* For the default INT ARGB check the image to see if any pixels are
* really transparent. If there are no transparent pixels then the
* transparency of the color model can be ignored.
* We assume that IndexColorModel images have already been
* checked for transparency and will be OPAQUE unless they actually
* have transparent pixels present.
*/
if (hasTransparency && bufferedImage != null) {
if (bufferedImage.getType()==BufferedImage.TYPE_INT_ARGB ||
bufferedImage.getType()==BufferedImage.TYPE_INT_ARGB_PRE) {
DataBuffer db = bufferedImage.getRaster().getDataBuffer();
SampleModel sm = bufferedImage.getRaster().getSampleModel();
if (db instanceof DataBufferInt &&
sm instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel psm =
(SinglePixelPackedSampleModel)sm;
// Stealing the data array for reading only...
int[] int_data =
SunWritableRaster.stealData((DataBufferInt) db, 0);
int x = bufferedImage.getMinX();
int y = bufferedImage.getMinY();
int w = bufferedImage.getWidth();
int h = bufferedImage.getHeight();
int stride = psm.getScanlineStride();
boolean hastranspixel = false;
for (int j = y; j < y+h; j++) {
int yoff = j * stride;
for (int i = x; i < x+w; i++) {
if ((int_data[yoff+i] & 0xff000000)!=0xff000000 ) {
hastranspixel = true;
break;
}
}
if (hastranspixel) {
break;
}
}
if (hastranspixel == false) {
hasTransparency = false;
}
}
}
}
return hasTransparency;
}