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
48 public static BitmapRegionDecoder newInstance(byte[] data)
49 {
50 return CppProxy.newInstance(data);
51 }
52
53 private static final class CppProxy extends BitmapRegionDecoder
54 {
55 private final long nativeRef;
56 private final AtomicBoolean destroyed = new AtomicBoolean(false);
57
58 private CppProxy(long nativeRef)
59 {
60 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
61 this.nativeRef = nativeRef;
62 }
63
64 private native void nativeDestroy(long nativeRef);
65 public void _djinni_private_destroy()
66 {
67 boolean destroyed = this.destroyed.getAndSet(true);
68 if (!destroyed) nativeDestroy(this.nativeRef);
69 }
70 protected void finalize() throws java.lang.Throwable
71 {
72 _djinni_private_destroy();
73 super.finalize();
74 }
75
76 // BitmapRegionDecoder methods
77
78 @Override
79 public android.graphics.Bitmap decodeRegion(Rectangle rect, float sampleSize)
80 {
81 assert !this.destroyed.get() : "trying to use a destroyed object";
82 return native_decodeRegion(this.nativeRef, rect, sampleSize);
83 }
84 private native android.graphics.Bitmap native_decodeRegion(long _nativeRef, Rectangle rect, float sampleSize);
85
86 public static native BitmapRegionDecoder newInstance(byte[] data);
87 }
88}