MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / Image

Class Image

CodenameOne/src/com/codename1/ui/Image.java:48–2138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46///
47/// @author Chen Fishbein
48public class Image implements ActionSource {
49 private static boolean simdOptimizationsEnabled = Simd.get().isSupported();
50 int transform;
51 private EventDispatcher listeners;
52 private Object rgbCache;
53 private Object image;
54 private boolean opaqueTested = false;
55 private boolean opaque;
56 private Object scaleCache;
57 private boolean animated;
58 private long imageTime = -1;
59 private String svgBaseURL;
60 private byte[] svgData;
61 private String imageName;
62
63 /// Indicates whether Image SIMD optimizations are enabled. When unset this defaults
64 /// to the current platform SIMD support.
65 public static boolean isSimdOptimizationsEnabled() {
66 return simdOptimizationsEnabled;
67 }
68
69 /// Enables or disables Image SIMD optimizations explicitly.
70 public static void setSimdOptimizationsEnabled(boolean enabled) {
71 simdOptimizationsEnabled = enabled;
72 }
73
74 /// Clears the explicit Image SIMD override and restores the default behavior of
75 /// using SIMD whenever it is supported by the current platform.
76 public static void resetSimdOptimizationsEnabled() {
77 simdOptimizationsEnabled = Simd.get().isSupported();
78 }
79
80 /// Subclasses may use this and point to an underlying native image which might be
81 /// null for a case of an image that doesn't use native drawing
82 ///
83 /// #### Parameters
84 ///
85 /// - `image`: native image object passed to the Codename One implementation
86 protected Image(Object image) {
87 this.image = image;
88 animated = Display.impl.isAnimation(image);
89 }
90
91 /// Creates a new instance of ImageImpl
92 Image(int[] imageArray, int w, int h) {
93 this(Display.impl.createImage(imageArray, w, h));
94 }
95
96 /// Creates an image while preserving the supplied RGB array in the weak RGB cache
97 /// so follow-up SIMD image operations can reuse it without extracting pixels again.
98 private static Image createImageWithRgbCache(int[] imageArray, int w, int h) {
99 Image out = new Image(imageArray, w, h);
100 out.rgbCache = Display.getInstance().createSoftWeakRef(imageArray);
101 return out;
102 }
103
104 /// Indicates whether the underlying platform supports creating an SVG Image
105 ///

Callers

nothing calls this directly

Calls 2

getMethod · 0.95
isSupportedMethod · 0.65

Tested by

no test coverage detected