diff options
author | Rolf W. Rasmussen <rolfwr@ii.uib.no> | 2000-10-22 19:46:09 +0200 |
---|---|---|
committer | Rolf Rasmussen <rolfwr@gcc.gnu.org> | 2000-10-22 17:46:09 +0000 |
commit | 2622c79d2d51f6bf9122a3b5f458daa50c0baf19 (patch) | |
tree | 1165199489e8bc851f2bb5c11ff0228f3667453e /libjava/gnu/gcj/xlib/XImage.java | |
parent | 9b95cc4a34af1148dc18c7912ab77f19a753bf80 (diff) | |
download | gcc-2622c79d2d51f6bf9122a3b5f458daa50c0baf19.zip gcc-2622c79d2d51f6bf9122a3b5f458daa50c0baf19.tar.gz gcc-2622c79d2d51f6bf9122a3b5f458daa50c0baf19.tar.bz2 |
Makefile.am: Added rules for libgcjx library.
* Makefile.am: Added rules for libgcjx library.
* Makefile.in: Rebuilt.
* configure.in: Added check for X.
* configure: Rebuilt.
* gnu/awt/LightweightRedirector.java: New file.
* gnu/awt/j2d/AbstractGraphicsState.java: New file.
* gnu/awt/j2d/DirectRasterGraphics.java: New file.
* gnu/awt/j2d/Graphics2DImpl.java: New file.
* gnu/awt/j2d/IntegerGraphicsState.java: New file.
* gnu/awt/j2d/MappedRaster.java: New file.
* gnu/awt/xlib/XCanvasPeer.java: New file.
* gnu/awt/xlib/XEventLoop.java: New file.
* gnu/awt/xlib/XEventQueue.java: New file.
* gnu/awt/xlib/XFontMetrics.java: New file.
* gnu/awt/xlib/XFramePeer.java: New file.
* gnu/awt/xlib/XGraphics.java: New file.
* gnu/awt/xlib/XGraphicsConfiguration.java: New file.
* gnu/awt/xlib/XPanelPeer.java: New file.
* gnu/awt/xlib/XToolkit.java: New file.
* gnu/gcj/xlib/Clip.java: New file.
* gnu/gcj/xlib/Colormap.java: New file.
* gnu/gcj/xlib/Display.java: New file.
* gnu/gcj/xlib/Drawable.java: New file.
* gnu/gcj/xlib/Font.java: New file.
* gnu/gcj/xlib/GC.java: New file.
* gnu/gcj/xlib/Pixmap.java: New file.
* gnu/gcj/xlib/Screen.java: New file.
* gnu/gcj/xlib/Visual.java: New file.
* gnu/gcj/xlib/WMSizeHints.java: New file.
* gnu/gcj/xlib/Window.java: New file.
* gnu/gcj/xlib/WindowAttributes.java: New file.
* gnu/gcj/xlib/XAnyEvent.java: New file.
* gnu/gcj/xlib/XButtonEvent.java: New file.
* gnu/gcj/xlib/XColor.java: New file.
* gnu/gcj/xlib/XConfigureEvent.java: New file.
* gnu/gcj/xlib/XConnectException.java: New file.
* gnu/gcj/xlib/XEvent.java: New file.
* gnu/gcj/xlib/XException.java: New file.
* gnu/gcj/xlib/XExposeEvent.java: New file.
* gnu/gcj/xlib/XID.java: New file.
* gnu/gcj/xlib/XImage.java: New file.
* gnu/gcj/xlib/XUnmapEvent.java: New file.
* gnu/gcj/xlib/natClip.cc: New file.
* gnu/gcj/xlib/natColormap.cc: New file.
* gnu/gcj/xlib/natDisplay.cc: New file.
* gnu/gcj/xlib/natDrawable.cc: New file.
* gnu/gcj/xlib/natFont.cc: New file.
* gnu/gcj/xlib/natGC.cc: New file.
* gnu/gcj/xlib/natPixmap.cc: New file.
* gnu/gcj/xlib/natScreen.cc: New file.
* gnu/gcj/xlib/natVisual.cc: New file.
* gnu/gcj/xlib/natWMSizeHints.cc: New file.
* gnu/gcj/xlib/natWindow.cc: New file.
* gnu/gcj/xlib/natWindowAttributes.cc: New file.
* gnu/gcj/xlib/natXAnyEvent.cc: New file.
* gnu/gcj/xlib/natXButtonEvent.cc: New file.
* gnu/gcj/xlib/natXColor.cc: New file.
* gnu/gcj/xlib/natXConfigureEvent.cc: New file.
* gnu/gcj/xlib/natXException.cc: New file.
* gnu/gcj/xlib/natXExposeEvent.cc: New file.
* gnu/gcj/xlib/natXImage.cc: New file.
* gnu/gcj/xlib/natXUnmapEvent.cc: New file.
* java/awt/EventDispatchThread.java: Start thead on creation.
From-SVN: r37005
Diffstat (limited to 'libjava/gnu/gcj/xlib/XImage.java')
-rw-r--r-- | libjava/gnu/gcj/xlib/XImage.java | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/libjava/gnu/gcj/xlib/XImage.java b/libjava/gnu/gcj/xlib/XImage.java new file mode 100644 index 0000000..25a8005 --- /dev/null +++ b/libjava/gnu/gcj/xlib/XImage.java @@ -0,0 +1,226 @@ +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.gcj.xlib; + +import gnu.gcj.RawData; + +/** + * Structure containing image data that resides on the client side. + * The format, depth and offset attributes of an XImage determines how + * bitfields are encoded in a raster image. However, it does not + * determine how a color is encoded into a bitfield. I.e. the XImage + * pixel values in a specific structure, but does not determine what + * colors that will be used to represent these pixel values on the + * screen. + * + * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> + */ +public class XImage +{ + /** This object reference points to the data, hindering garbage + collection of the data. */ + Object dataRef; + + // Must match definitions in X.h: + public static final int XYBITMAP_FORMAT = 0, + XYPIXMAP_FORMAT = 1, + ZPIXMAP_FORMAT = 2; + + // Must match definitions in X.h: + public static final int LEAST_SIGNIFICANT_B_FIRST_ORDER = 0, + MOST_SIGNIFICANT_B_FIRST_ORDER = 1; + + public XImage(Visual visual, int depth, int format, int xoffset, + int width, int height, int bitmapPad, + int bytesPerLine) + { + this(visual, depth, format, xoffset, width, height, bitmapPad, + bytesPerLine, + 0 // bitsPerPixel + ); + } + + public XImage(Visual visual, int depth, int format, int xoffset, + int width, int height, int bitmapPad, + int bytesPerLine, int bitsPerPixel) + { + if (visual == null) throw new + NullPointerException("a visual must be specified"); + + init(visual, depth, format, xoffset, width, height, + bitmapPad, bytesPerLine, bitsPerPixel); + } + + public native void init(Visual visual, int depth, int format, int xoffset, + int width, int height, int bitmapPad, + int bytesPerLine, int bitsPerPixel); + + private native void init(Visual visual, int width, int height); + + + public XImage(Visual visual, int width, int height) + { + this(visual, width, height, + true // Automatically allocate memory + ); + } + + /** + * Create a new XImage. + * + * @param allocate specifies whether to automatically allocate + * memory for the image. It is possible to create the data array + * elsewhere, so that we can for instance use a DataBufferUShort as + * data. Ie. not limit ourself to byte arrays. This is done by + * passing false and calling a setData() method manually after + * creation. + */ + public XImage(Visual visual, int width, int height, boolean allocate) + { + if (visual == null) + throw new NullPointerException("a visual must be specified"); + + init(visual, width, height); + + if (allocate) + { + /* Now that Xlib has figured out the appropriate bytes per + line, we can allocate memory for the image. */ + // FIXME: What about formats with several layers/bands? + byte[] data = new byte[getBytesPerLine()*height]; + + setData(data, 0); + } + } + + /** + * Attach image data to this XImage. + * + * @param offset the index of the first actual data element in the array. + */ + public void setData(byte[] data, int offset) + { + dataRef = data; + internalSetData(data, offset); + } + + /** + * Attach image data to this XImage. + * + * @param offset the index of the first actual data element in the + * array. Note: this is short offset, not a byte offset. + */ + public void setData(short[] data, int offset) + { + dataRef = data; + internalSetData(data, offset); + } + + /** + * Attach image data to this XImage + * + * @param offset the index of the first actual data element in the array. + * Note: this is not a byte offset. + */ + public void setData(int[] data, int offset) + { + dataRef = data; + internalSetData(data, offset); + } + + private native void internalSetData(byte[] data, int offset); + private native void internalSetData(short[] data, int offset); + private native void internalSetData(int[] data, int offset); + + protected native void finalize(); + + boolean ownsData = false; + RawData structure = 0; + + public final native int getWidth(); + public final native int getHeight(); + public final native int getDepth(); + public final native int getFormat(); + + public final boolean isZPixmapFormat() + { + return getFormat() == ZPIXMAP_FORMAT; + } + + + /** + * Get the xoffset. The xoffset avoids the need of shifting the + * scanlines into place. + */ + public final native int getXOffset(); + + public native final int getBytesPerLine(); + public native final int getBitsPerPixel(); + + public native final int getImageByteOrder(); + public native final int getBitmapBitOrder(); + public native final int getBitmapUnit(); + public native final int getBitmapPad(); + + + // True/Direct Color specific: + public native int getRedMask(); + public native int getGreenMask(); + public native int getBlueMask(); + + + /** + * Set a pixel value at a given position in the image. This method + * is slow. Don't use it, except as a fall-back. + */ + public native final void setPixel(int x, int y, int pixel); + + public String toString() + { + String format; + switch(getFormat()) + { + case ZPIXMAP_FORMAT: + format = "ZPixmapFormat"; + } + + String imageByteOrder; + switch(getImageByteOrder()) + { + case LEAST_SIGNIFICANT_B_FIRST_ORDER: + imageByteOrder = "leastSignificantByteFirst"; + break; + case MOST_SIGNIFICANT_B_FIRST_ORDER: + imageByteOrder = "mostSignificantByteFirst"; + } + + String bitmapBitOrder; + switch(getBitmapBitOrder()) + { + case LEAST_SIGNIFICANT_B_FIRST_ORDER: + bitmapBitOrder = "leastSignificantBitFirst"; + break; + case MOST_SIGNIFICANT_B_FIRST_ORDER: + bitmapBitOrder = "mostSignificantBitFirst"; + } + + return getClass().getName() + "[" + format + + ", width=" + getWidth() + + ", height=" + getHeight() + + ", bytesPerLine=" + getBytesPerLine() + + ", xoffset=" + getXOffset() + + ", depth=" + getDepth() + + ", bitsPerPixel=" + getBitsPerPixel() + + ", bitmapUnit=" + getBitmapUnit() + + ", bitmapPad=" + getBitmapPad() + + ", byteOrder=" + imageByteOrder + + ", bitOrder=" + bitmapBitOrder + + "]"; + } +} |