diff options
Diffstat (limited to 'libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java')
-rw-r--r-- | libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java | 71 |
1 files changed, 22 insertions, 49 deletions
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java index 2e3eee4..58b2dec 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java @@ -247,12 +247,23 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder public static ImageFormatSpec registerFormat(String name, boolean writable) { ImageFormatSpec ifs = new ImageFormatSpec(name, writable); - synchronized(GdkPixbufDecoder.class) + + // GCJ LOCAL: workaround a GCJ problem accessing + // GdkPixbufDecoder.class + try + { + synchronized(Class.forName ("gnu.java.awt.peer.gtk.GdkPixbufDecoder")) { if (imageFormatSpecs == null) imageFormatSpecs = new ArrayList(); imageFormatSpecs.add(ifs); } + } + catch (Exception e) + { + e.printStackTrace(); + } + return ifs; } @@ -502,19 +513,19 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder int width = ras.getWidth(); int height = ras.getHeight(); ColorModel model = image.getColorModel(); - int[] pixels = GdkGraphics2D.findSimpleIntegerArray (image.getColorModel(), ras); + int[] pixels = CairoGraphics2D.findSimpleIntegerArray (image.getColorModel(), ras); if (pixels == null) { - BufferedImage img = new BufferedImage(width, height, - (model != null && model.hasAlpha() ? - BufferedImage.TYPE_INT_ARGB - : BufferedImage.TYPE_INT_RGB)); + BufferedImage img; + if(model != null && model.hasAlpha()) + img = CairoSurface.getBufferedImage(width, height); + img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int[] pix = new int[4]; for (int y = 0; y < height; ++y) for (int x = 0; x < width; ++x) img.setRGB(x, y, model.getRGB(ras.getPixel(x, y, pix))); - pixels = GdkGraphics2D.findSimpleIntegerArray (img.getColorModel(), + pixels = CairoGraphics2D.findSimpleIntegerArray (img.getColorModel(), img.getRaster()); model = img.getColorModel(); } @@ -584,9 +595,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder if (bufferedImage == null) { - bufferedImage = new BufferedImage (width, height, (model != null && model.hasAlpha() ? - BufferedImage.TYPE_INT_ARGB - : BufferedImage.TYPE_INT_RGB)); + if(model != null && model.hasAlpha()) + bufferedImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_ARGB); + else + bufferedImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB); } int pixels2[]; @@ -680,43 +692,4 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder return getBufferedImage (); } } - - // remaining helper class and static method is a convenience for the Gtk - // peers, for loading a BufferedImage in off a disk file without going - // through the whole imageio system. - - public static BufferedImage createBufferedImage (String filename) - { - GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(), - "png", // reader auto-detects, doesn't matter - new GdkPixbufDecoder (filename)); - return r.getBufferedImage (); - } - - public static BufferedImage createBufferedImage (URL u) - { - GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(), - "png", // reader auto-detects, doesn't matter - new GdkPixbufDecoder (u)); - return r.getBufferedImage (); - } - - public static BufferedImage createBufferedImage (byte[] imagedata, int imageoffset, - int imagelength) - { - GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(), - "png", // reader auto-detects, doesn't matter - new GdkPixbufDecoder (imagedata, - imageoffset, - imagelength)); - return r.getBufferedImage (); - } - - public static BufferedImage createBufferedImage (ImageProducer producer) - { - GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(), "png" /* ignored */, null); - producer.startProduction(r); - return r.getBufferedImage (); - } - } |