Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Can't Display SWT Image on Linux (Large Image)(Can display same images fine on windows, but not Linux. In the Oil and Gas business we have these images called Rasers. They are narrow and LONG. One I am looking at now in IrfanView is 1698 x 138)
Can't Display SWT Image on Linux (Large Image) [message #1564073] Wed, 14 January 2015 15:39 Go to next message
Chris Grant is currently offline Chris GrantFriend
Messages: 45
Registered: July 2009
Member
ECLIPSE (SWT Forum):

We are trying to display an SWT Image on a canvas that is large. We have no problems on Windows but do with Linux. The code is below from the method where we make the Image. There are no errors, no exceptions thrown, and the Image returned is non-null, but it is blank.

I have also attached an image to help you reproduce the problem.

Thanks

Chris Grant
Geology Product Manager
Drillinginfo
Cell: 303-725-8323






private static ImageData makeImageData(String fileName, ImageInputStream iis)
throws StatusException {
try {
BufferedImage bufferedImage = null;
if (iis == null) {
int len = fileName.length();
int dotLoc = fileName.lastIndexOf(".");
String suffix = fileName.substring(dotLoc + 1, len);
Iterator<ImageReader> ir = ImageIO
.getImageReadersByFormatName(suffix);
ImageReader tifReader = ir.next();
File f = new File(fileName);
ImageInputStream imageInputStream = new FileImageInputStream(f);
tifReader.setInput(imageInputStream);
bufferedImage = tifReader.read(0);
imageInputStream.close();
} else {
bufferedImage = ImageIO.read(iis);
}

int w = bufferedImage.getWidth();
int h = bufferedImage.getHeight();
if (Util.isLinux()) {
//
// What is this? It seems the SWT Image has problems displaying
// large images
// on linux. This limits the size of the generated image and
// creates a warning.
// This sucks. We need to keep testing this when we get newer
// versions of SWT
// to see if the problem gets fixed.

final int maxP = 0x0c000000;
if (w * h > maxP) {
_clipPerc = Math.sqrt((double) maxP / (double) (w * h));
w = (int) (_clipPerc * w);
h = (int) (_clipPerc * h);
}
}

ColorModel colorModel = bufferedImage.getColorModel();

if (colorModel instanceof DirectColorModel) {
DirectColorModel dcm = (DirectColorModel) colorModel;
PaletteData palette = new PaletteData(dcm.getRedMask(),
dcm.getGreenMask(), dcm.getBlueMask());

ImageData data = new ImageData(w, h, colorModel.getPixelSize(),
palette);

WritableRaster raster = bufferedImage.getRaster();
int[] pixelArray = new int[3];
for (int y = 0; y < data.height; y++) {
for (int x = 0; x < data.width; x++) {
raster.getPixel(x, y, pixelArray);
int pixel = palette.getPixel(new RGB(pixelArray[0],
pixelArray[1], pixelArray[2]));
data.setPixel(x, y, pixel);
}
}

return data;
} else if (colorModel instanceof IndexColorModel) {
IndexColorModel icm = (IndexColorModel) colorModel;
int size = icm.getMapSize();
byte[] reds = new byte[size];
byte[] greens = new byte[size];
byte[] blues = new byte[size];
icm.getReds(reds);
icm.getGreens(greens);
icm.getBlues(blues);
RGB[] rgbs = new RGB[size];
for (int i = 0; i < rgbs.length; i++) {
rgbs[i] = new RGB(reds[i] & 0xFF, greens[i] & 0xFF,
blues[i] & 0xFF);
}
PaletteData palette = new PaletteData(rgbs);
ImageData data = new ImageData(w, h, colorModel.getPixelSize(),
palette);

data.transparentPixel = icm.getTransparentPixel();
WritableRaster raster = bufferedImage.getRaster();
int width = data.width;
int height = data.height;
int[] pixelArray = new int[width];
for (int y = 0; y < height; y++) {
raster.getPixels(0, y, width, 1, pixelArray);
data.setPixels(0, y, width, pixelArray, 0);
}
return data;
} else {
Image i = new Image(_shell.getDisplay(), fileName);
return i.getImageData();
}
} catch (IOException exp) {
Status status = new DefaultStatus("com.x4m.rasterloader",
StatusSeverity.ERROR, 18002, exp,
"Error loading raster image file.");
throw new StatusException(status);
} catch (IllegalArgumentException exp) {
Status status = new DefaultStatus("com.x4m.rasterloader",
StatusSeverity.ERROR, 18002, exp,
"Error loading raster image file. Please contact DrillingInfo support.");
throw new StatusException(status);

}
}
Re: Can't Display SWT Image on Linux (Large Image) [message #1564081 is a reply to message #1564073] Wed, 14 January 2015 15:45 Go to previous message
Chris Grant is currently offline Chris GrantFriend
Messages: 45
Registered: July 2009
Member
Sorry, error in the pixel length.

The dimensions of the image are: 1698 x 138,331

Chris
Previous Topic:Mars M4 - SWT Display problem with Linux Mint 17 ?
Next Topic:SWT modal dialog overlapped by non-modal dialog on Mac OS X
Goto Forum:
  


Current Time: Thu Apr 25 15:07:33 GMT 2024

Powered by FUDForum. Page generated in 0.02849 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top