You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
libandroid: add bitmap.c
This commit is contained in:
@@ -1,18 +1,32 @@
|
|||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
typedef void JNIEnv;
|
// FIXME: put the header in a common place
|
||||||
typedef void AndroidBitmapInfo;
|
#include "../api-impl-jni/defines.h"
|
||||||
typedef void* jobject;
|
|
||||||
|
|
||||||
#define ANDROID_BITMAP_RESULT_SUCCESS 0
|
#define ANDROID_BITMAP_RESULT_SUCCESS 0
|
||||||
|
|
||||||
|
struct AndroidBitmapInfo {
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
uint32_t stride;
|
||||||
|
int32_t format;
|
||||||
|
uint32_t flags;
|
||||||
|
};
|
||||||
|
|
||||||
int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap,
|
int AndroidBitmap_getInfo(JNIEnv* env, jobject bitmap, struct AndroidBitmapInfo *info) {
|
||||||
AndroidBitmapInfo* info) {
|
GdkPixbuf *pixbuf = _PTR(_GET_LONG_FIELD(bitmap, "pixbuf"));
|
||||||
return ANDROID_BITMAP_RESULT_SUCCESS;
|
info->width = gdk_pixbuf_get_width(pixbuf);
|
||||||
|
info->height = gdk_pixbuf_get_height(pixbuf);
|
||||||
|
info->stride = gdk_pixbuf_get_rowstride(pixbuf);
|
||||||
|
info->format = 1; // ANDROID_BITMAP_FORMAT_RGBA_8888
|
||||||
|
return ANDROID_BITMAP_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr) {
|
int AndroidBitmap_lockPixels(JNIEnv* env, jobject bitmap, void** pixels) {
|
||||||
return ANDROID_BITMAP_RESULT_SUCCESS;
|
GdkPixbuf *pixbuf = _PTR(_GET_LONG_FIELD(bitmap, "pixbuf"));
|
||||||
|
*pixels = gdk_pixbuf_get_pixels(pixbuf);
|
||||||
|
return ANDROID_BITMAP_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap) {
|
int AndroidBitmap_unlockPixels(JNIEnv* env, jobject bitmap) {
|
||||||
return ANDROID_BITMAP_RESULT_SUCCESS;
|
return ANDROID_BITMAP_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user