본문 바로가기
프로그래밍 놀이터/안드로이드, Java

[JNI] bitmap handling source code frame.

by 돼지왕 왕돼지 2014. 4. 16.
반응형


 JNI, bitmap handling source code frame.

 

[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;

}






반응형

댓글