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 {
23 public abstract android.graphics.Bitmap decodeRegion(Rectangle rect, int sampleSize);
24
32 public static BitmapRegionDecoder newInstance(byte[] data)
33 {
34 return CppProxy.newInstance(data);
35 }
36
37 private static final class CppProxy extends BitmapRegionDecoder
38 {
39 private final long nativeRef;
40 private final AtomicBoolean destroyed = new AtomicBoolean(false);
41
42 private CppProxy(long nativeRef)
43 {
44 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
45 this.nativeRef = nativeRef;
46 }
47
48 private native void nativeDestroy(long nativeRef);
49 public void _djinni_private_destroy()
50 {
51 boolean destroyed = this.destroyed.getAndSet(true);
52 if (!destroyed) nativeDestroy(this.nativeRef);
53 }
54 protected void finalize() throws java.lang.Throwable
55 {
56 _djinni_private_destroy();
57 super.finalize();
58 }
59
60 // BitmapRegionDecoder methods
61
62 @Override
63 public android.graphics.Bitmap decodeRegion(Rectangle rect, int sampleSize)
64 {
65 assert !this.destroyed.get() : "trying to use a destroyed object";
66 return native_decodeRegion(this.nativeRef, rect, sampleSize);
67 }
68 private native android.graphics.Bitmap native_decodeRegion(long _nativeRef, Rectangle rect, int sampleSize);
69
70 public static native BitmapRegionDecoder newInstance(byte[] data);
71 }
72}