< prev index next >

src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  24  */
  25 
  26 package sun.lwawt.macosx;
  27 
  28 import java.awt.*;
  29 import java.awt.geom.Dimension2D;
  30 import java.awt.image.*;
  31 
  32 import java.util.Arrays;
  33 import java.util.List;
  34 import java.awt.image.MultiResolutionImage;
  35 import java.util.concurrent.atomic.AtomicReference;
  36 
  37 import sun.awt.image.MultiResolutionCachedImage;
  38 
  39 import sun.awt.image.SunWritableRaster;
  40 
  41 public class CImage extends CFRetainedResource {
  42     private static native long nativeCreateNSImageFromArray(int[] buffer, int w, int h);
  43     private static native long nativeCreateNSImageFromBytes(byte[] buffer);
  44     private static native long nativeCreateNSImageFromArrays(int[][] buffers, int w[], int h[]);
  45     private static native long nativeCreateNSImageFromFileContents(String file);
  46     private static native long nativeCreateNSImageOfFileFromLaunchServices(String file);
  47     private static native long nativeCreateNSImageFromImageName(String name);
  48     private static native long nativeCreateNSImageFromIconSelector(int selector);
  49     private static native byte[] nativeGetPlatformImageBytes(int[] buffer, int w, int h);
  50     private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int sw, int sh, int dw, int dh);
  51     private static native Dimension2D nativeGetNSImageSize(long image);
  52     private static native void nativeSetNSImageSize(long image, double w, double h);
  53     private static native void nativeResizeNSImageRepresentations(long image, double w, double h);
  54     private static native Dimension2D[] nativeGetNSImageRepresentationSizes(long image, double w, double h);
  55 
  56     static Creator creator = new Creator();
  57     static Creator getCreator() {
  58         return creator;
  59     }
  60 
  61     // This is used to create a CImage that represents the icon of the given file.
  62     public static Image createImageOfFile(String file, int width, int height) {
  63         return getCreator().createImageOfFile(file, width, height);
  64     }


   1 /*
   2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  24  */
  25 
  26 package sun.lwawt.macosx;
  27 
  28 import java.awt.*;
  29 import java.awt.geom.Dimension2D;
  30 import java.awt.image.*;
  31 
  32 import java.util.Arrays;
  33 import java.util.List;
  34 import java.awt.image.MultiResolutionImage;
  35 import java.util.concurrent.atomic.AtomicReference;
  36 
  37 import sun.awt.image.MultiResolutionCachedImage;
  38 
  39 import sun.awt.image.SunWritableRaster;
  40 
  41 public class CImage extends CFRetainedResource {
  42     private static native long nativeCreateNSImageFromArray(int[] buffer, int w, int h);
  43     private static native long nativeCreateNSImageFromBytes(byte[] buffer);
  44     private static native long nativeCreateNSImageFromArrays(int[][] buffers, int[] w, int[] h);
  45     private static native long nativeCreateNSImageFromFileContents(String file);
  46     private static native long nativeCreateNSImageOfFileFromLaunchServices(String file);
  47     private static native long nativeCreateNSImageFromImageName(String name);
  48     private static native long nativeCreateNSImageFromIconSelector(int selector);
  49     private static native byte[] nativeGetPlatformImageBytes(int[] buffer, int w, int h);
  50     private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int sw, int sh, int dw, int dh);
  51     private static native Dimension2D nativeGetNSImageSize(long image);
  52     private static native void nativeSetNSImageSize(long image, double w, double h);
  53     private static native void nativeResizeNSImageRepresentations(long image, double w, double h);
  54     private static native Dimension2D[] nativeGetNSImageRepresentationSizes(long image, double w, double h);
  55 
  56     static Creator creator = new Creator();
  57     static Creator getCreator() {
  58         return creator;
  59     }
  60 
  61     // This is used to create a CImage that represents the icon of the given file.
  62     public static Image createImageOfFile(String file, int width, int height) {
  63         return getCreator().createImageOfFile(file, width, height);
  64     }


< prev index next >