本文整理汇总了C++中AndroidBitmap_lockPixels函数的典型用法代码示例。如果您正苦于以下问题:C++ AndroidBitmap_lockPixels函数的具体用法?C++ AndroidBitmap_lockPixels怎么用?C++ AndroidBitmap_lockPixels使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AndroidBitmap_lockPixels函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nAllocationCubeCreateFromBitmap
static int
nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage)
{
void *pixels = NULL;
AndroidBitmap_lockPixels(_env, jbitmap, &pixels);
jint id = 0;
if (pixels != NULL) {
id = (jint)dispatchTab.AllocationCubeCreateFromBitmap(con,
(RsType)type, (RsAllocationMipmapControl)mip,
pixels, GetBitmapSize(_env, jbitmap), usage);
AndroidBitmap_unlockPixels(_env, jbitmap);
}
return id;
}
示例2: nAllocationCreateBitmapBackedAllocation
static int
nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage)
{
jint id = 0;
void *pixels = NULL;
AndroidBitmap_lockPixels(_env, jbitmap, &pixels);
if (pixels != NULL) {
id = (jint)dispatchTab.AllocationCreateTyped(con,
(RsType)type, (RsAllocationMipmapControl)mip,
(uint32_t)usage, (uintptr_t)pixels);
AndroidBitmap_unlockPixels(_env, jbitmap);
}
return id;
}
示例3: Java_org_libvisual_android_LibVisualBitmapView_renderVisual
/** LibVisualBitmapView.renderVisual() */
JNIEXPORT void JNICALL Java_org_libvisual_android_LibVisualBitmapView_renderVisual(JNIEnv * env,
jobject obj,
jobject bitmap,
jint bin,
jint video)
{
VisBin *b = (VisBin *) bin;
VisVideo *bvideo = (VisVideo *) video;
if(!visual_is_initialized() ||
!bvideo ||
!b ||
!b->input ||
!b->actor ||
!b->actvideo)
{
LOGE("Not initialized properly");
return;
}
/* start fps timing */
fps_startFrame(&_v.fps);
/* run libvisual pipeline */
visual_bin_run(b);
/* lock bitmap for drawing */
int ret;
void *pixels;
if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0)
{
LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
}
/* set buffer to pixels */
visual_video_set_buffer(bvideo, pixels);
/* depth transform */
visual_video_convert_depth(bvideo, b->actvideo);
/* unlock bitmap */
AndroidBitmap_unlockPixels(env, bitmap);
/* stop fps timing */
fps_endFrame(&_v.fps);
}
示例4: nAllocationCopyToBitmap
static void
nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap)
{
AndroidBitmapInfo info;
memset(&info, 0, sizeof(info));
AndroidBitmap_getInfo(_env, jbitmap, &info);
void *pixels = NULL;
AndroidBitmap_lockPixels(_env, jbitmap, &pixels);
if (pixels != NULL) {
dispatchTab.AllocationCopyToBitmap(con, (RsAllocation)alloc, pixels, GetBitmapSize(_env, jbitmap));
AndroidBitmap_unlockPixels(_env, jbitmap);
}
//bitmap.notifyPixelsChanged();
}
示例5: LOGE
JNIEXPORT jfloatArray JNICALL Java_com_lge_ccdevs_tracker_CameraPreview_native_1cv_1match
(JNIEnv *env, jobject thiz, jobject srcimg) {
AndroidBitmapInfo bInfo;
char *bPixs;
int bRet;
// convert img
if ((bRet = AndroidBitmap_getInfo(env, srcimg, &bInfo)) < 0) {
LOGE("AndroidBitmap_getInfo failed(src)! error = %d", bRet);
return 0;
}
if (bInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
LOGE("Bitmap(src) format is not RGBA_8888!");
return 0;
}
if ((bRet = AndroidBitmap_lockPixels(env, srcimg, (void**)&bPixs)) < 0) {
LOGE("AndroidBitmap_lockPixels() failed(src)! error = %d", bRet);
return 0;
}
IplImage* bimg = cvCreateImage(cvSize(bInfo.width,bInfo.height), IPL_DEPTH_8U, 4);
memcpy(bimg->imageData, bPixs, bimg->imageSize);
AndroidBitmap_unlockPixels(env, srcimg);
IplImage* img = cvCreateImage(cvSize(bInfo.width,bInfo.height), IPL_DEPTH_8U, 3);
cvCvtColor(bimg, img, CV_RGBA2BGR);
res_pts = matcher->match(img);
// test capture
stringstream ss;
ss << "/sdcard/tracker/tracker_match" << ncount_match++ << ".jpg";
Converter::saveJPG(ss.str().c_str(), img);
LOGE("#### matched pts = (%f,%f), (%f,%f), (%f,%f), (%f,%f) )",
res_pts[0], res_pts[1], res_pts[2], res_pts[3],
res_pts[4], res_pts[5], res_pts[6], res_pts[7] );
cvReleaseImage( &bimg );
cvReleaseImage( &img );
jfloatArray result;
result = env->NewFloatArray(8);
env->SetFloatArrayRegion(result,0,8,res_pts);
return result;
}
示例6: readBitmapPixels
static void readBitmapPixels(JNIEnv* env, jclass /* clazz */, jobject jbitmap, jint fd) {
// Read the info.
AndroidBitmapInfo readInfo;
bool read = readAllBytes(fd, (void*) &readInfo, sizeof(AndroidBitmapInfo));
if (!read) {
throwIllegalStateException(env, (char*) "Cannot read bitmap info");
return;
}
// Get the info of the target bitmap.
AndroidBitmapInfo targetInfo;
int result = AndroidBitmap_getInfo(env, jbitmap, &targetInfo);
if (result < 0) {
throwIllegalStateException(env, (char*) "Cannot get bitmap info");
return;
}
// Enforce we can reuse the bitmap.
if (readInfo.width != targetInfo.width || readInfo.height != targetInfo.height
|| readInfo.stride != targetInfo.stride || readInfo.format != targetInfo.format
|| readInfo.flags != targetInfo.flags) {
throwIllegalArgumentException(env, (char*) "Cannot reuse bitmap");
return;
}
// Lock the pixels.
void* pixels;
result = AndroidBitmap_lockPixels(env, jbitmap, &pixels);
if (result < 0) {
throwIllegalStateException(env, (char*) "Cannot lock bitmap pixels");
return;
}
// Read the pixels.
size_t byteCount = readInfo.stride * readInfo.height;
read = readAllBytes(fd, (void*) pixels, byteCount);
if (!read) {
throwIllegalStateException(env, (char*) "Cannot read bitmap pixels");
return;
}
// Unlock the pixels.
result = AndroidBitmap_unlockPixels(env, jbitmap);
if (result < 0) {
throwIllegalStateException(env, (char*) "Cannot unlock bitmap pixels");
}
}
开发者ID:GarbledWang,项目名称:platform_frameworks_base,代码行数:47,代码来源:com_android_printspooler_util_BitmapSerializeUtils.cpp
示例7: getMatWrapper
/** Program having access to java Bitmap through JNI */
cv::Mat getMatWrapper(JNIEnv *env, jobject bmap)
{
AndroidBitmapInfo info;
CV_Assert( AndroidBitmap_getInfo(env, bmap, &info) >= 0 ); // Get info
CV_Assert( info.format == ANDROID_BITMAP_FORMAT_RGBA_8888 ); // Compatible format
void *pixels = 0;
CV_Assert( AndroidBitmap_lockPixels(env, bmap, &pixels) >= 0 ); // Get pixels
CV_Assert( pixels );
cv::Mat m(info.height, info.width, CV_8UC4, pixels);
cv::Mat frame; // CV_8UC3
cvtColor(m, frame, CV_RGBA2BGR);
AndroidBitmap_unlockPixels(env, bmap);
return frame;
}
示例8: nAllocationCopyFromBitmap
static void
nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap)
{
AndroidBitmapInfo info;
memset(&info, 0, sizeof(info));
AndroidBitmap_getInfo(_env, jbitmap, &info);
void *pixels = NULL;
AndroidBitmap_lockPixels(_env, jbitmap, &pixels);
if (pixels != NULL) {
dispatchTab.Allocation2DData(con, (RsAllocation)alloc, 0, 0,
0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
info.width, info.height, pixels, GetBitmapSize(_env, jbitmap), 0);
AndroidBitmap_unlockPixels(_env, jbitmap);
}
}
示例9: info
void MyRenderer::Render(JNIEnv *env, jobject bitmap) noexcept
{
int ret = 0;
AndroidBitmapInfo bitmapInfo;
if ((ret = AndroidBitmap_getInfo(env, bitmap, &bitmapInfo)) < 0)
{
info("MyRenderer", "AndroidBitmap_getInfo failed!");
return;
}
else {
info("MyRenderer", "bitmapInfo width = %d, height = %d", bitmapInfo.width, bitmapInfo.height);
}
GLuint textureId;
GLint location = glGetUniformLocation(m_Program->GetProgramId(), "s_texture");
glGenTextures(1, &textureId);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureId);
glUniform1i(location, 0);
void *pixels = nullptr;
AndroidBitmap_lockPixels(env, bitmap, &pixels);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bitmapInfo.width, bitmapInfo.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
this->OnRender(m_Width, m_Height);
AndroidBitmap_unlockPixels(env, bitmap);
//GLenum format = GL_RGB;
//if (bitmapInfo.format == ANDROID_BITMAP_FORMAT_RGBA_8888) {
// info("MyRenderer", "bitmapInfo format = ANDROID_BITMAP_FORMAT_RGBA_8888");
//}
//else if (bitmapInfo.format == ANDROID_BITMAP_FORMAT_RGB_565) {
// info("MyRenderer", "bitmapInfo format = ANDROID_BITMAP_FORMAT_RGB_565");
//}
//else if (bitmapInfo.format == ANDROID_BITMAP_FORMAT_RGBA_4444) {
// info("MyRenderer", "bitmapInfo format = ANDROID_BITMAP_FORMAT_RGBA_4444");
//}
//else if (bitmapInfo.format == ANDROID_BITMAP_FORMAT_A_8) {
// info("MyRenderer", "bitmapInfo format = ANDROID_BITMAP_FORMAT_A_8");
//}
}
示例10: Java_ch_nuicell_ecam_CameraPreview_pixeltobmp
void
Java_ch_nuicell_ecam_CameraPreview_pixeltobmp( JNIEnv* env,jobject thiz,jobject bitmap) {
jboolean bo;
AndroidBitmapInfo info;
void* pixels;
int ret;
int i;
int *colors;
int width=0;
int height=0;
if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
return;
}
width = info.width;
height = info.height;
if(!rgb || !ybuf) return;
if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
LOGE("Bitmap format is not RGBA_8888 !");
return;
}
if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
}
colors = (int*)pixels;
int *lrgb =NULL;
lrgb = &rgb[0];
for(i=0 ; i<width*height ; i++) {
*colors++ = *lrgb++;
}
AndroidBitmap_unlockPixels(env, bitmap);
}
示例11: Java_com_jni_bitmap_1operations_JniBitmapHolder_jniGetBitmapFromStoredBitmapData
JNIEXPORT jobject JNICALL Java_com_jni_bitmap_1operations_JniBitmapHolder_jniGetBitmapFromStoredBitmapData(
JNIEnv * env, jobject obj, jobject handle)
{
JniBitmap* jniBitmap = (JniBitmap*) env->GetDirectBufferAddress(handle);
if (jniBitmap->_storedBitmapPixels == NULL)
{
LOGD("no bitmap data was stored. returning null...");
return NULL;
}
//
//creating a new bitmap to put the pixels into it - using Bitmap Bitmap.createBitmap (int width, int height, Bitmap.Config config) :
//
jclass bitmapCls = env->FindClass("android/graphics/Bitmap");
jmethodID createBitmapFunction = env->GetStaticMethodID(bitmapCls,
"createBitmap",
"(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");
jstring configName = env->NewStringUTF("ARGB_8888");
jclass bitmapConfigClass = env->FindClass("android/graphics/Bitmap$Config");
jmethodID valueOfBitmapConfigFunction = env->GetStaticMethodID(
bitmapConfigClass, "valueOf",
"(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;");
jobject bitmapConfig = env->CallStaticObjectMethod(bitmapConfigClass,
valueOfBitmapConfigFunction, configName);
jobject newBitmap = env->CallStaticObjectMethod(bitmapCls,
createBitmapFunction, jniBitmap->_bitmapInfo.width,
jniBitmap->_bitmapInfo.height, bitmapConfig);
//
// putting the pixels into the new bitmap:
//
int ret;
void* bitmapPixels;
if ((ret = AndroidBitmap_lockPixels(env, newBitmap, &bitmapPixels)) < 0)
{
LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
return NULL;
}
uint32_t* newBitmapPixels = (uint32_t*) bitmapPixels;
int pixelsCount = jniBitmap->_bitmapInfo.height
* jniBitmap->_bitmapInfo.width;
memcpy(newBitmapPixels, jniBitmap->_storedBitmapPixels,
sizeof(uint32_t) * pixelsCount);
AndroidBitmap_unlockPixels(env, newBitmap);
//LOGD("returning the new bitmap");
return newBitmap;
}
示例12: Java_com_googlecode_leptonica_android_ReadFile_nativeReadBitmap
jlong Java_com_googlecode_leptonica_android_ReadFile_nativeReadBitmap(JNIEnv *env, jclass clazz,
jobject bitmap) {
LOGV(__FUNCTION__);
l_int32 w, h, d;
AndroidBitmapInfo info;
void* pixels;
int ret;
if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
return JNI_FALSE;
}
if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
LOGE("Bitmap format is not RGBA_8888 !");
return JNI_FALSE;
}
if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
return JNI_FALSE;
}
PIX *pixd = pixCreate(info.width, info.height, 32);
l_uint8 *src = (l_uint8 *) pixels;
l_uint8 *dst = (l_uint8 *) pixGetData(pixd);
l_int32 srcBpl = (info.stride);
l_int32 dstBpl = pixGetWpl(pixd)*4;
for (int dy = 0; dy < info.height; dy++) {
memcpy(dst, src, 4 * info.width);
dst += dstBpl;
src += srcBpl;
}
pixEndianByteSwap(pixd);
AndroidBitmap_unlockPixels(env, bitmap);
return (jlong) pixd;
}
示例13: lock
virtual LVDrawBuf * lock(JNIEnv* env, jobject jbitmap) {
AndroidBitmapInfo info;
if ( ANDROID_BITMAP_RESUT_SUCCESS!=AndroidBitmap_getInfo(env, jbitmap, &info) ) {
return NULL;
}
int width = info.width;
int height = info.height;
int stride = info.stride;
int format = info.format;
if ( format!=ANDROID_BITMAP_FORMAT_RGBA_8888 && format!=ANDROID_BITMAP_FORMAT_RGB_565 && format!=8 ) {
return NULL;
}
int bpp = (format==ANDROID_BITMAP_FORMAT_RGBA_8888) ? 32 : 16;
lUInt8 * pixels = NULL;
if ( ANDROID_BITMAP_RESUT_SUCCESS!=AndroidBitmap_lockPixels(env, jbitmap, (void**)&pixels) ) {
pixels = NULL;
}
return new LVColorDrawBufEx( width, height, pixels, bpp );
}
示例14: Java_org_opentalking_drawskill_SurfaceDiff_applyAndSwap
void Java_org_opentalking_drawskill_SurfaceDiff_applyAndSwap(JNIEnv *env, jobject obj, jobject dest, jint boundTop, jint boundBottom, jint boundLeft, jint boundRight, jbooleanArray bitmask, jintArray pixels) {
AndroidBitmapInfo info;
uint32_t* destPixels;
int ret;
if ((ret = AndroidBitmap_getInfo(env, dest, &info)) < 0) {
LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
return;
}
if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
LOGE("Destination bitmap format is not RGBA_8888!");
return;
}
AndroidBitmap_lockPixels(env, dest, (void*)&destPixels);
jint* pixelsPtr = (*env)->GetIntArrayElements(env, pixels, 0);
jboolean* bitmaskPtr = (*env)->GetBooleanArrayElements(env, bitmask, 0);
uint32_t* destPixelsPtr;
for (int y = boundTop; y <= boundBottom; y += 1) {
destPixelsPtr = destPixels + y * info.width + boundLeft;
for (int x = boundLeft; x <= boundRight; x += 1) {
if (*bitmaskPtr) {
int swapPixel = *destPixelsPtr;
*destPixelsPtr = *pixelsPtr;
*pixelsPtr = swapPixel;
pixelsPtr += 1;
}
destPixelsPtr += 1;
bitmaskPtr += 1;
}
}
(*env)->ReleaseIntArrayElements(env, pixels, pixelsPtr, 0);
(*env)->ReleaseBooleanArrayElements(env, bitmask, bitmaskPtr, 0);
AndroidBitmap_unlockPixels(env, dest);
}
示例15: filter_bitmap
static void filter_bitmap(JNIEnv* env, jobject obj, jobject bitmap,
float intensity, Filter t)
{
AndroidBitmapInfo info;
int ret = checkInfo(env, bitmap, &info);
if (ret < 0) {
return;
}
void* pixels;
if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
}
do_filter(&info, pixels, intensity, t);
AndroidBitmap_unlockPixels(env, bitmap);
}