• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ AndroidBitmap_lockPixels函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中AndroidBitmap_lockPixels函数的典型用法代码示例。如果您正苦于以下问题:C++ AndroidBitmap_lockPixels函数的具体用法?C++ AndroidBitmap_lockPixels怎么用?C++ AndroidBitmap_lockPixels使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了AndroidBitmap_lockPixels函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:anoop44,项目名称:platform_frameworks_support,代码行数:15,代码来源:android_renderscript_RenderScript.cpp


示例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;
}
开发者ID:anoop44,项目名称:platform_frameworks_support,代码行数:15,代码来源:android_renderscript_RenderScript.cpp


示例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);
}
开发者ID:Libvisual,项目名称:LibVisualAndroid,代码行数:49,代码来源:visual_bitmap_view.c


示例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();
}
开发者ID:anoop44,项目名称:platform_frameworks_support,代码行数:16,代码来源:android_renderscript_RenderScript.cpp


示例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;
}
开发者ID:batteryShin,项目名称:ccdevs,代码行数:47,代码来源:com_lge_ccdevs_tracker_CameraPreview.cpp


示例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;
}
开发者ID:thegraffter,项目名称:VisionAndroidStudio,代码行数:18,代码来源:vision_thegraffter_native.cpp


示例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);
    }
}
开发者ID:anoop44,项目名称:platform_frameworks_support,代码行数:17,代码来源:android_renderscript_RenderScript.cpp


示例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");
	//}
}
开发者ID:airoseFy,项目名称:BitalShader,代码行数:46,代码来源:MyRenderer.cpp


示例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);

}
开发者ID:Tobio1,项目名称:nuiCellCAM,代码行数:45,代码来源:ImageProc.c


示例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;
    }
开发者ID:happysir,项目名称:AndroidJniBitmapOperations,代码行数:45,代码来源:JniBitmapOperations.cpp


示例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;
}
开发者ID:renard314,项目名称:tess-two,代码行数:43,代码来源:readfile.cpp


示例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 );
    } 
开发者ID:Dhollmen,项目名称:Xtra_CoolReader,代码行数:19,代码来源:cr3java.cpp


示例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);
}
开发者ID:Haoxiqiang,项目名称:DrawSkill,代码行数:42,代码来源:applyAndSwap.c


示例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);
}
开发者ID:piratla,项目名称:tomahawk,代码行数:20,代码来源:filter.c


示例16: Java_com_jazzros_ffmpegtest_AVThread_nativeSetBitmapBuffer

JNIEXPORT jint JNICALL Java_com_jazzros_ffmpegtest_AVThread_nativeSetBitmapBuffer(JNIEnv* env, jobject thiz, jobject bitmap)
{
    __android_log_print(ANDROID_LOG_INFO, "com.jazzros.ffmpegtest", "nativeSetBitmapBuffer()");

    if ((*env)->IsSameObject(env, bitmap, NULL))
    {
        __android_log_print(ANDROID_LOG_ERROR, "com.jazzros.ffmpegtest", "invalid arguments");
        return -2;
    }
    // Do not forget release previous instance of resources
    releaseBitmap (env, thiz);

    gBitmapRef = (*env)->NewGlobalRef(env, bitmap); //lock the bitmap preventing the garbage collector from destructing it
    if (gBitmapRef == NULL)
    {
        __android_log_print(ANDROID_LOG_ERROR, "com.jazzros.ffmpegtest", "NewGlobalRef() failed");
        return -4;
    }

    int result = AndroidBitmap_lockPixels(env, gBitmapRef, &gBitmapRefPixelBuffer);
    if (result != 0)
    {
        __android_log_print(ANDROID_LOG_ERROR, "com.jazzros.ffmpegtest", "AndroidBitmap_lockPixels() failed with %d", result);
        gBitmapRefPixelBuffer = NULL;
        return -5;
    }

    if (AndroidBitmap_getInfo(env, gBitmapRef, &gAbi) != 0)
    {
        __android_log_print(ANDROID_LOG_ERROR, "com.jazzros.ffmpegtest", "AndroidBitmap_getInfo() failed");
        return -6;
    }

    __android_log_print(ANDROID_LOG_INFO, "com.jazzros.ffmpegtest", "bitmap width: %d", gAbi.width);
    __android_log_print(ANDROID_LOG_INFO, "com.jazzros.ffmpegtest", "bitmap height: %d", gAbi.height);
    __android_log_print(ANDROID_LOG_INFO, "com.jazzros.ffmpegtest", "bitmap stride: %d", gAbi.stride);
    __android_log_print(ANDROID_LOG_INFO, "com.jazzros.ffmpegtest", "bitmap format: %d", gAbi.format);
    __android_log_print(ANDROID_LOG_INFO, "com.jazzros.ffmpegtest", "bitmap flags: %d", gAbi.flags);

    return 0;
}
开发者ID:forbe,项目名称:MediaPlayer,代码行数:41,代码来源:avjni.c


示例17: createBitmap

    jobject createBitmap(QImage img, JNIEnv *env)
    {
        if (img.format() != QImage::Format_ARGB32 && img.format() != QImage::Format_RGB16)
            img = img.convertToFormat(QImage::Format_ARGB32);

        jobject bitmap = env->CallStaticObjectMethod(m_bitmapClass,
                                                     m_createBitmapMethodID,
                                                     img.width(),
                                                     img.height(),
                                                     img.format() == QImage::Format_ARGB32
                                                        ? m_ARGB_8888_BitmapConfigValue
                                                        : m_RGB_565_BitmapConfigValue);
        if (!bitmap)
            return 0;

        AndroidBitmapInfo info;
        if (AndroidBitmap_getInfo(env, bitmap, &info) < 0) {
            env->DeleteLocalRef(bitmap);
            return 0;
        }

        void *pixels;
        if (AndroidBitmap_lockPixels(env, bitmap, &pixels) < 0) {
            env->DeleteLocalRef(bitmap);
            return 0;
        }

        if (info.stride == uint(img.bytesPerLine())
                && info.width == uint(img.width())
                && info.height == uint(img.height())) {
            memcpy(pixels, img.constBits(), info.stride * info.height);
        } else {
            uchar *bmpPtr = static_cast<uchar *>(pixels);
            const unsigned width = qMin(info.width, (uint)img.width()); //should be the same
            const unsigned height = qMin(info.height, (uint)img.height()); //should be the same
            for (unsigned y = 0; y < height; y++, bmpPtr += info.stride)
                memcpy(bmpPtr, img.constScanLine(y), width);
        }
        AndroidBitmap_unlockPixels(env, bitmap);
        return bitmap;
    }
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:41,代码来源:androidjnimain.cpp


示例18: Java_com_ly_widget_GifDrawable_updateFrame

JNIEXPORT jboolean JNICALL Java_com_ly_widget_GifDrawable_updateFrame(JNIEnv * env, jobject obj, jlong jgif_handle,  jobject bitmap, jint level)
{
  GifFileType* gif_handle = (GifFileType *)jgif_handle;

  int frame = getFrame(gif_handle, level);
  if (((GifAnimInfo *)gif_handle->UserData)->current_frame == frame) {
    return JNI_FALSE;
  }

  AndroidBitmapInfo  info;
  void*              pixels;
  int                ret;

  if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
    LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
    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);
  }

  //double now = now_ms();
  drawFrame(gif_handle, &info, (int*)pixels, frame, false);
  //now = now_ms() - now;
  //LOGE("Gif Time Taken : %.2f", now);
  AndroidBitmap_unlockPixels(env, bitmap);

  ((GifAnimInfo *)gif_handle->UserData)->current_frame = frame;

  /*
   * TODO : Check if you actually need to draw the frame, if not return JNI_FALSE
   */

  return JNI_TRUE;
}
开发者ID:ly20050516,项目名称:AndroidDemo,代码行数:41,代码来源:libgifdrawable.c


示例19: getJniBitmap

JniBitmap* getJniBitmap(JNIEnv *env, jobject bitmap){
	AndroidBitmapInfo bitmapInfo;
	uint32_t* storedBitmapPixels = NULL;
	uint32_t* src = NULL;
	void* bitmapPixels;

	//LOGD("reading bitmap info...");
	int ret;
	if ((ret = AndroidBitmap_getInfo(env, bitmap, &bitmapInfo)) < 0){
		LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
		return NULL;
	}

	//LOGD("width:%d height:%d stride:%d", bitmapInfo.width, bitmapInfo.height, bitmapInfo.stride);
	if (bitmapInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888){
		LOGE("Bitmap format is not RGBA_8888!");
		return NULL;
	}

	//LOGD("reading bitmap pixels...");
	if ((ret = AndroidBitmap_lockPixels(env, bitmap, &bitmapPixels)) < 0){
		LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
		return NULL;
	}

	src = (uint32_t*) bitmapPixels;

	storedBitmapPixels = new uint32_t[bitmapInfo.height * bitmapInfo.width];
	int pixelsCount = bitmapInfo.height * bitmapInfo.width;
	memcpy(storedBitmapPixels, src, sizeof(uint32_t) * pixelsCount);
	AndroidBitmap_unlockPixels(
			env, bitmap);

	jniBitmap->_bitmapInfo = bitmapInfo;
	jniBitmap->_storedBitmapPixels = storedBitmapPixels;

	//delete(storedBitmapPixels);

	return jniBitmap;
}
开发者ID:flpeng00,项目名称:AndroidMultiseatSystem_Server,代码行数:40,代码来源:fbcon.cpp


示例20: mat_to_bitmap

void mat_to_bitmap(JNIEnv *env, Mat &srcMat, jobject &dstBitmap) {
    void *dstPixels = 0;
    AndroidBitmapInfo dstBitmapInfo;
    try {
        AndroidBitmap_getInfo(env, dstBitmap, &dstBitmapInfo);
        AndroidBitmap_lockPixels(env, dstBitmap, &dstPixels);
        uint32_t dstHeight = dstBitmapInfo.height;
        uint32_t dstWidth = dstBitmapInfo.width;
        if (dstBitmapInfo.format == ANDROID_BITMAP_FORMAT_RGBA_8888) {
            Mat tmp(dstHeight, dstWidth, CV_8UC4, dstPixels);
            if(srcMat.type() == CV_8UC1) {
                cvtColor(srcMat, tmp, COLOR_GRAY2RGBA);
            } else if (srcMat.type() == CV_8UC3) {
                cvtColor(srcMat, tmp, COLOR_RGB2RGBA);
            } else if (srcMat.type() == CV_8UC4) {
                srcMat.copyTo(tmp);
            }
        } else {
            Mat tmp = Mat(dstHeight, dstWidth, CV_8UC2, dstPixels);
            if(srcMat.type() == CV_8UC1) {
                cvtColor(srcMat, tmp, COLOR_GRAY2BGR565);
            } else if (srcMat.type() == CV_8UC3) {
                cvtColor(srcMat, tmp, COLOR_RGB2BGR565);
            } else if (srcMat.type() == CV_8UC4) {
                cvtColor(srcMat, tmp, COLOR_RGBA2BGR565);
            }
        }
        AndroidBitmap_unlockPixels(env, dstBitmap);
    }catch (cv::Exception &e) {
        AndroidBitmap_unlockPixels(env, dstBitmap);
        jclass je = env->FindClass("java/lang/Exception");
        env -> ThrowNew(je, e.what());
        return;
    } catch (...) {
        AndroidBitmap_unlockPixels(env, dstBitmap);
        jclass je = env->FindClass("java/lang/Exception");
        env -> ThrowNew(je, "unknown");
        return;
    }
}
开发者ID:Fuge2008,项目名称:SmartCropper,代码行数:40,代码来源:android_utils.cpp



注:本文中的AndroidBitmap_lockPixels函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AndroidBitmap_unlockPixels函数代码示例发布时间:2022-05-30
下一篇:
C++ AndroidBitmap_getInfo函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap