lib/android: add more services to NativeBitmap
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 16 Nov 2015 22:18:47 +0000 (17:18 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 16 Nov 2015 22:45:00 +0000 (17:45 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/android/assets_and_resources.nit

index 897938a..624a03d 100644 (file)
@@ -304,9 +304,31 @@ private extern class NativeBitmap in "Java" `{ android.graphics.Bitmap `}
        # Create a NativeBitmap using a resource ID and the NativeResources
        # Called by the ResourceManager
        new from_resources(res: NativeResources, id: Int) in "Java" `{ return BitmapFactory.decodeResource(res, (int)id); `}
+
+       # Width in pixels
+       #
+       # Wraps Java: `int android.graphics.Bitmap.getWidth()`
        fun width: Int in "Java" `{ return self.getWidth(); `}
+
+       # Height in pixels
+       #
+       # Wraps Java: `int android.graphics.Bitmap.getHeight()`
        fun height: Int in "Java" `{ return self.getHeight(); `}
 
+       # Number of bytes per row
+       #
+       # Wraps Java: `int android.graphics.Bitmap.getRowBytes()`
+       fun row_bytes: Int in "Java" `{
+               return self.getRowBytes();
+       `}
+
+       # Does this bitmap has an alpha channel?
+       #
+       # Wraps Java: `boolean android.graphics.Bitmap.hasAlpha()`
+       fun has_alpha: Bool in "Java" `{
+               return self.hasAlpha();
+       `}
+
        # HACK for bug #845
        redef fun new_global_ref import sys, Sys.jni_env `{
                Sys sys = NativeBitmap_sys(self);
@@ -314,6 +336,9 @@ private extern class NativeBitmap in "Java" `{ android.graphics.Bitmap `}
                return (*env)->NewGlobalRef(env, self);
        `}
 
+       redef fun pop_from_local_frame_with_env(jni_env) `{
+               return (*jni_env)->PopLocalFrame(jni_env, self);
+       `}
 end
 
 # Android AssetFileDescriptor, can be retrieve by AssetManager and used to load a sound in a SoundPool