JNI, bitmap handling source code frame. |
<header>
#include <jni.h>
/* Header for class com_example_coloring_utils_FloodFillUtils */
#include <android/bitmap.h>
#include <android/log.h>
#define LOG_TAG "DEBUG"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
#ifndef _Included_com_example_coloring_utils_FloodFillUtils
#define _Included_com_example_coloring_utils_FloodFillUtils
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jobject JNICALL Java_com_example_coloring_utils_FloodFillUtils_getFloodFilledBitmap
(JNIEnv *, jobject, jobject, jint, jint, jint, jint, jint, jint );
#ifdef __cplusplus
}
#endif
#endif
<c++>
#include "FloodFillUtils.h"
JNIEXPORT jobject JNICALL Java_com_example_coloring_utils_FloodFillUtils_getFloodFilledBitmap (JNIEnv * env, jobject obj, jobject bitmap, jint width, jint height, jint x, jint y, jint targetColor, jint replacementColor ){
AndroidBitmapInfo info;
void* pixels;
int ret;
if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
return NULL;
}
if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
return NULL;
}
AndroidBitmap_unlockPixels(env, bitmap);
return bitmap;
}
'프로그래밍 놀이터 > 안드로이드, Java' 카테고리의 다른 글
[android] findViewById casting bolierplate removal. (0) | 2014.04.17 |
---|---|
android 에서 gif 재생하기 - GifDrawable. ( Open Source LIbrary ) (0) | 2014.04.16 |
[android] support v4 에 추가된 SwipeRefreshLayout. (0) | 2014.04.15 |
[android] ellipsize="marquee" not working (0) | 2014.04.15 |
android:foreground 속성은 언제 쓰이는가? (0) | 2014.04.14 |
댓글