Loading...
Searching...
No Matches
BitmapRegionDecoder.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
14public abstract class BitmapRegionDecoder {
31 public abstract android.graphics.Bitmap decodeRegion(Rectangle rect, float sampleSize);
32
46 public abstract int getWidth();
47
61 public abstract int getHeight();
62
78 public static BitmapRegionDecoder newInstance(byte[] data)
79 {
80 return CppProxy.newInstance(data);
81 }
82
99 {
100 return CppProxy.newInstanceFromImage(data);
101 }
102
103 private static final class CppProxy extends BitmapRegionDecoder
104 {
105 private final long nativeRef;
106 private final AtomicBoolean destroyed = new AtomicBoolean(false);
107
108 private CppProxy(long nativeRef)
109 {
110 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
111 this.nativeRef = nativeRef;
112 }
113
114 private native void nativeDestroy(long nativeRef);
115 public void _djinni_private_destroy()
116 {
117 boolean destroyed = this.destroyed.getAndSet(true);
118 if (!destroyed) nativeDestroy(this.nativeRef);
119 }
120 protected void finalize() throws java.lang.Throwable
121 {
122 _djinni_private_destroy();
123 super.finalize();
124 }
125
126 // BitmapRegionDecoder methods
127
128 @Override
129 public android.graphics.Bitmap decodeRegion(Rectangle rect, float sampleSize)
130 {
131 assert !this.destroyed.get() : "trying to use a destroyed object";
132 return native_decodeRegion(this.nativeRef, rect, sampleSize);
133 }
134 private native android.graphics.Bitmap native_decodeRegion(long _nativeRef, Rectangle rect, float sampleSize);
135
136 @Override
137 public int getWidth()
138 {
139 assert !this.destroyed.get() : "trying to use a destroyed object";
140 return native_getWidth(this.nativeRef);
141 }
142 private native int native_getWidth(long _nativeRef);
143
144 @Override
145 public int getHeight()
146 {
147 assert !this.destroyed.get() : "trying to use a destroyed object";
148 return native_getHeight(this.nativeRef);
149 }
150 private native int native_getHeight(long _nativeRef);
151
152 public static native BitmapRegionDecoder newInstance(byte[] data);
153
154 public static native BitmapRegionDecoder newInstanceFromImage(Image data);
155 }
156}