r = lastSnapshot.getRaster();
Object data;
AwtImageBackdoorAccessor dbAccess = AwtImageBackdoorAccessor.getInstance();
data = dbAccess.getData(r.getDataBuffer());
LockedArray lockedData = Utils.arraccess.lockArrayShort(data);
SampleModel sm = r.getSampleModel();
int scanlineStride;
if (sm instanceof ComponentSampleModel) {
scanlineStride = ((ComponentSampleModel) sm).getScanlineStride();
} else if (sm instanceof SinglePixelPackedSampleModel) {
scanlineStride = ((SinglePixelPackedSampleModel) sm).getScanlineStride();
} else if (sm instanceof MultiPixelPackedSampleModel) {
scanlineStride = ((MultiPixelPackedSampleModel) sm).getScanlineStride();
} else {
return;
}
int pad;
if (data instanceof byte[]) {
pad = 8;
} else if (data instanceof short[]) {
pad = 16;
scanlineStride *= 2;
} else if (data instanceof int[]) {
pad = 32;
scanlineStride *= 4;
} else {
return;
}
X11.Visual visual = g2d.xConfig.info.get_visual();
long xImagePtr = x11.XCreateImage(
g2d.display,
visual.lock(),
g2d.xConfig.info.get_depth(),
X11Defs.ZPixmap,
0,
lockedData.getAddress(),
r.getWidth(),
r.getHeight(),
pad,
scanlineStride
);
visual.unlock();
g2d.setXClip(clip, g2d.imageGC);
X11.XImage xImage = x11.createXImage(xImagePtr);
xImage.set_byte_order(X11Defs.LSBFirst); // Set byte order explicitly
x11.XPutImage(
g2d.display,
g2d.drawable,
g2d.imageGC,
xImagePtr,
0, 0,
dstX, dstY,
dstWidth, dstHeight
);
g2d.resetXClip(g2d.imageGC);
lockedData.release();
xImage.set_data(NativeBridge.getInstance().createInt8Pointer(0, true));
xImage.get_f().destroy_image(xImage);
}