android :: NativeBitmap :: copy_pixels
Copy the pixel data into a newCByteArray
android :: NativeBitmap :: copy_pixels_to_buffer
Copy raw pixel data tobuffer
android :: NativeBitmap :: defaultinit
android :: NativeBitmap :: from_resources
Create a NativeBitmap using a resource ID and the NativeResourcesandroid :: NativeBitmap :: from_stream
Create a NativeBitmap from a NativeInputStream retrieved withopen
function of the AssetManager
android :: NativeBitmap :: from_stream_ex
Load frominput_stream
with optional premultiply_alpha
android :: NativeBitmap :: has_alpha
Does this bitmap has an alpha channel?android :: NativeBitmap :: recycle
android $ NativeBitmap :: SELF
Type of this instance, automatically specialized in every classandroid $ NativeBitmap :: pop_from_local_frame_with_env
Java implementation ofpop_from_local_frame
core :: Pointer :: address_is_null
Is the address behind this Object at NULL?jvm :: JavaObject :: as_exception
jvm :: JavaObject :: as_http_response
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
android :: NativeBitmap :: copy_pixels
Copy the pixel data into a newCByteArray
android :: NativeBitmap :: copy_pixels_to_buffer
Copy raw pixel data tobuffer
android :: NativeBitmap :: defaultinit
core :: Pointer :: defaultinit
jvm :: JavaObject :: defaultinit
core :: Object :: defaultinit
android :: NativeBitmap :: from_resources
Create a NativeBitmap using a resource ID and the NativeResourcesandroid :: NativeBitmap :: from_stream
Create a NativeBitmap from a NativeInputStream retrieved withopen
function of the AssetManager
android :: NativeBitmap :: from_stream_ex
Load frominput_stream
with optional premultiply_alpha
android :: NativeBitmap :: has_alpha
Does this bitmap has an alpha channel?jvm :: JavaObject :: is_exception
jvm :: JavaObject :: is_http_response
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Pointer :: native_equals
jvm :: JavaObject :: new_global_ref
Returns a global reference to the Java object behind this referencecore :: Object :: output_class_name
Display class name on stdout (debug only).jvm :: JavaObject :: pop_from_local_frame
Pops the current local reference frame and return a valid reference to selfjvm :: JavaObject :: pop_from_local_frame_with_env
Java implementation ofpop_from_local_frame
core :: Pointer :: premultiply_alpha
Multiply RGB values by their alpha valueandroid :: NativeBitmap :: recycle
jvm :: JavaObject :: to_java_string
JavaString
representation of self
using Java's toString
# An android Bitmap, get an instance using the AssetManager or the ResourceManager
private extern class NativeBitmap in "Java" `{ android.graphics.Bitmap `}
super JavaObject
# Create a NativeBitmap from a NativeInputStream retrieved with `open` function of the AssetManager
# Called by the AssetManager
new from_stream(input_stream: NativeInputStream) in "Java" `{ return BitmapFactory.decodeStream(input_stream); `}
# 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();
`}
fun recycle in "Java" `{
self.recycle();
`}
# HACK for bug #845
redef fun new_global_ref import sys, Sys.jni_env `{
Sys sys = NativeBitmap_sys(self);
JNIEnv *env = Sys_jni_env(sys);
return (*env)->NewGlobalRef(env, self);
`}
redef fun pop_from_local_frame_with_env(jni_env) `{
return (*jni_env)->PopLocalFrame(jni_env, self);
`}
end
lib/android/assets_and_resources.nit:294,1--344,3
redef extern class NativeBitmap
# Copy the pixel data into a new `CByteArray`
#
# If `pad_to_pow2` the new buffer contains artificial pixels used to make
# the width and the height powers of 2 for compatibility with older OpenGL.
#
# If `unmultiply`, extra work is done to revert the multiplication of color
# values per the alpha channel applied by the Android system.
fun copy_pixels(pad_to_pow2, unmultiply: nullable Bool): CByteArray
do
var height = height
var row_bytes = row_bytes
var bytes = row_bytes * height
var w2 = width.next_pow(2)
var h2 = height.next_pow(2)
var row_bytes2 = row_bytes * w2 / width
var capacity = bytes
if pad_to_pow2 == true then capacity = row_bytes2 * h2
var buf = new CByteArray(capacity)
var java_buf = buf.to_java_nio_buffer
copy_pixels_to_buffer java_buf
if has_alpha and unmultiply == true then buf.native_array.unmultiply(width, height)
if pad_to_pow2 == true then
for r in [height-1..0[.step(-1) do
var src_offset = row_bytes*r
var dst_offset = row_bytes2*r
buf.move(dst_offset, src_offset, row_bytes)
end
end
return buf
end
# Copy raw pixel data to `buffer`
#
# Wraps Java: `void android.graphics.Bitmap.copyPixelsToBuffer(java.nio.Buffer)`
fun copy_pixels_to_buffer(buffer: Java_nio_Buffer) in "Java" `{
self.copyPixelsToBuffer(buffer);
`}
end
lib/android/load_image.nit:29,1--74,3
redef class NativeBitmap
# Load from `input_stream` with optional `premultiply_alpha`
new from_stream_ex(input_stream: NativeInputStream, premultiply_alpha: Bool) in "Java" `{
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPremultiplied = premultiply_alpha; // API 19
return BitmapFactory.decodeStream(input_stream, null, opts);
`}
end
lib/gamnit/android19.nit:48,1--56,3