< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/nimbus/EffectUtils.java

Print this page

        

*** 231,253 **** // ================================================================================================================= // Get/Set Pixels helper methods /** ! * <p>Returns an array of pixels, stored as integers, from a <code>BufferedImage</code>. The pixels are grabbed from * a rectangular area defined by a location and two dimensions. Calling this method on an image of type different ! * from <code>BufferedImage.TYPE_INT_ARGB</code> and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the * image.</p> * * @param img the source image * @param x the x location at which to start grabbing pixels * @param y the y location at which to start grabbing pixels * @param w the width of the rectangle of pixels to grab * @param h the height of the rectangle of pixels to grab * @param pixels a pre-allocated array of pixels of size w*h; can be null ! * @return <code>pixels</code> if non-null, a new array of integers otherwise ! * @throws IllegalArgumentException is <code>pixels</code> is non-null and of length &lt; w*h */ static byte[] getPixels(BufferedImage img, int x, int y, int w, int h, byte[] pixels) { if (w == 0 || h == 0) { return new byte[0]; --- 231,253 ---- // ================================================================================================================= // Get/Set Pixels helper methods /** ! * <p>Returns an array of pixels, stored as integers, from a {@code BufferedImage}. The pixels are grabbed from * a rectangular area defined by a location and two dimensions. Calling this method on an image of type different ! * from {@code BufferedImage.TYPE_INT_ARGB} and {@code BufferedImage.TYPE_INT_RGB} will unmanage the * image.</p> * * @param img the source image * @param x the x location at which to start grabbing pixels * @param y the y location at which to start grabbing pixels * @param w the width of the rectangle of pixels to grab * @param h the height of the rectangle of pixels to grab * @param pixels a pre-allocated array of pixels of size w*h; can be null ! * @return {@code pixels} if non-null, a new array of integers otherwise ! * @throws IllegalArgumentException is {@code pixels} is non-null and of length &lt; w*h */ static byte[] getPixels(BufferedImage img, int x, int y, int w, int h, byte[] pixels) { if (w == 0 || h == 0) { return new byte[0];
*** 267,287 **** throw new IllegalArgumentException("Only type BYTE_GRAY is supported"); } } /** ! * <p>Writes a rectangular area of pixels in the destination <code>BufferedImage</code>. Calling this method on an ! * image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> and <code>BufferedImage.TYPE_INT_RGB</code> * will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers ! * @throws IllegalArgumentException is <code>pixels</code> is non-null and of length &lt; w*h */ static void setPixels(BufferedImage img, int x, int y, int w, int h, byte[] pixels) { if (pixels == null || w == 0 || h == 0) { return; --- 267,287 ---- throw new IllegalArgumentException("Only type BYTE_GRAY is supported"); } } /** ! * <p>Writes a rectangular area of pixels in the destination {@code BufferedImage}. Calling this method on an ! * image of type different from {@code BufferedImage.TYPE_INT_ARGB} and {@code BufferedImage.TYPE_INT_RGB} * will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers ! * @throws IllegalArgumentException is {@code pixels} is non-null and of length &lt; w*h */ static void setPixels(BufferedImage img, int x, int y, int w, int h, byte[] pixels) { if (pixels == null || w == 0 || h == 0) { return;
*** 297,320 **** } } /** * <p>Returns an array of pixels, stored as integers, from a ! * <code>BufferedImage</code>. The pixels are grabbed from a rectangular * area defined by a location and two dimensions. Calling this method on ! * an image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> ! * and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the source image * @param x the x location at which to start grabbing pixels * @param y the y location at which to start grabbing pixels * @param w the width of the rectangle of pixels to grab * @param h the height of the rectangle of pixels to grab * @param pixels a pre-allocated array of pixels of size w*h; can be null ! * @return <code>pixels</code> if non-null, a new array of integers * otherwise ! * @throws IllegalArgumentException is <code>pixels</code> is non-null and * of length &lt; w*h */ public static int[] getPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (w == 0 || h == 0) { --- 297,320 ---- } } /** * <p>Returns an array of pixels, stored as integers, from a ! * {@code BufferedImage}. The pixels are grabbed from a rectangular * area defined by a location and two dimensions. Calling this method on ! * an image of type different from {@code BufferedImage.TYPE_INT_ARGB} ! * and {@code BufferedImage.TYPE_INT_RGB} will unmanage the image.</p> * * @param img the source image * @param x the x location at which to start grabbing pixels * @param y the y location at which to start grabbing pixels * @param w the width of the rectangle of pixels to grab * @param h the height of the rectangle of pixels to grab * @param pixels a pre-allocated array of pixels of size w*h; can be null ! * @return {@code pixels} if non-null, a new array of integers * otherwise ! * @throws IllegalArgumentException is {@code pixels} is non-null and * of length &lt; w*h */ public static int[] getPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (w == 0 || h == 0) {
*** 339,359 **** return img.getRGB(x, y, w, h, pixels, 0, w); } /** * <p>Writes a rectangular area of pixels in the destination ! * <code>BufferedImage</code>. Calling this method on ! * an image of type different from <code>BufferedImage.TYPE_INT_ARGB</code> ! * and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers ! * @throws IllegalArgumentException is <code>pixels</code> is non-null and * of length &lt; w*h */ public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { --- 339,359 ---- return img.getRGB(x, y, w, h, pixels, 0, w); } /** * <p>Writes a rectangular area of pixels in the destination ! * {@code BufferedImage}. Calling this method on ! * an image of type different from {@code BufferedImage.TYPE_INT_ARGB} ! * and {@code BufferedImage.TYPE_INT_RGB} will unmanage the image.</p> * * @param img the destination image * @param x the x location at which to start storing pixels * @param y the y location at which to start storing pixels * @param w the width of the rectangle of pixels to store * @param h the height of the rectangle of pixels to store * @param pixels an array of pixels, stored as integers ! * @throws IllegalArgumentException is {@code pixels} is non-null and * of length &lt; w*h */ public static void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) {
*** 373,391 **** img.setRGB(x, y, w, h, pixels, 0, w); } } /** ! * <p>Returns a new <code>BufferedImage</code> using the same color model * as the image passed as a parameter. The returned image is only compatible * with the image passed as a parameter. This does not mean the returned * image is compatible with the hardware.</p> * * @param image the reference image from which the color model of the new * image is obtained ! * @return a new <code>BufferedImage</code>, compatible with the color model ! * of <code>image</code> */ public static BufferedImage createColorModelCompatibleImage(BufferedImage image) { ColorModel cm = image.getColorModel(); return new BufferedImage(cm, cm.createCompatibleWritableRaster(image.getWidth(), --- 373,391 ---- img.setRGB(x, y, w, h, pixels, 0, w); } } /** ! * <p>Returns a new {@code BufferedImage} using the same color model * as the image passed as a parameter. The returned image is only compatible * with the image passed as a parameter. This does not mean the returned * image is compatible with the hardware.</p> * * @param image the reference image from which the color model of the new * image is obtained ! * @return a new {@code BufferedImage}, compatible with the color model ! * of {@code image} */ public static BufferedImage createColorModelCompatibleImage(BufferedImage image) { ColorModel cm = image.getColorModel(); return new BufferedImage(cm, cm.createCompatibleWritableRaster(image.getWidth(),
*** 393,410 **** cm.isAlphaPremultiplied(), null); } /** * <p>Returns a new translucent compatible image of the specified width and ! * height. That is, the returned <code>BufferedImage</code> is compatible with * the graphics hardware. If the method is called in a headless * environment, then the returned BufferedImage will be compatible with * the source image.</p> * * @param width the width of the new image * @param height the height of the new image ! * @return a new translucent compatible <code>BufferedImage</code> of the * specified width and height */ public static BufferedImage createCompatibleTranslucentImage(int width, int height) { return isHeadless() ? --- 393,410 ---- cm.isAlphaPremultiplied(), null); } /** * <p>Returns a new translucent compatible image of the specified width and ! * height. That is, the returned {@code BufferedImage} is compatible with * the graphics hardware. If the method is called in a headless * environment, then the returned BufferedImage will be compatible with * the source image.</p> * * @param width the width of the new image * @param height the height of the new image ! * @return a new translucent compatible {@code BufferedImage} of the * specified width and height */ public static BufferedImage createCompatibleTranslucentImage(int width, int height) { return isHeadless() ?
< prev index next >