當前位置: 首頁>>代碼示例>>C++>>正文


C++ AndroidBitmap_getInfo函數代碼示例

本文整理匯總了C++中AndroidBitmap_getInfo函數的典型用法代碼示例。如果您正苦於以下問題:C++ AndroidBitmap_getInfo函數的具體用法?C++ AndroidBitmap_getInfo怎麽用?C++ AndroidBitmap_getInfo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AndroidBitmap_getInfo函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: Java_com_jiangpeng_android_antrace_Utils_unsharpMask

JNIEXPORT void JNICALL Java_com_jiangpeng_android_antrace_Utils_unsharpMask(JNIEnv* env, jobject thiz, jobject input, jobject output)
{
	AndroidBitmapInfo inputInfo;
	AndroidBitmapInfo outputInfo;
	void* src_pixels = 0;
	void* dst_pixels = 0;
	int ret = 0;

	if ((ret = AndroidBitmap_getInfo(env, input, &inputInfo)) < 0) {
		return;
	}

	if (inputInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
		return;
	}
	if ((ret = AndroidBitmap_lockPixels(env, input, &src_pixels)) < 0) {
		return;
	}

	if ((ret = AndroidBitmap_getInfo(env, output, &outputInfo)) < 0) {
		return;
	}

	if (outputInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
		return;
	}
	if ((ret = AndroidBitmap_lockPixels(env, output, &dst_pixels)) < 0) {
		return;
	}

	unsharpMask(src_pixels, dst_pixels, outputInfo.width, outputInfo.height, inputInfo.stride, 5);
	AndroidBitmap_unlockPixels(env, input);
	AndroidBitmap_unlockPixels(env, output);
}
開發者ID:larscwallin,項目名稱:antrace,代碼行數:34,代碼來源:antrace.cpp

示例2: LOGI

JNIEXPORT void JNICALL Java_com_leth_convertimage_MainActivity_convertImage
	(JNIEnv *env, jobject  obj, jobject origbm,jobject graybm)
{

		AndroidBitmapInfo  infocolor;
	    void				*pixelscolor;
	    AndroidBitmapInfo  infogray;
	    void 				*pixelsgray;
	    int 			    y;
	    int          	    x;

	    LOGI("Before convert");

	    AndroidBitmap_getInfo(env, origbm, &infocolor);
	    LOGI("infocolor :: width-%d height-%d format-%d stride-%ld"
	    				   ,infocolor.width
						   ,infocolor.height
						   ,infocolor.stride);
	    AndroidBitmap_getInfo(env, graybm, &infogray);
	    AndroidBitmap_lockPixels(env, origbm, &pixelscolor);
	    AndroidBitmap_lockPixels(env, graybm, &pixelsgray);

	    LOGI("Start convert");
	    uint8_t tmp;
	    for ( y=0; y<infocolor.height; y++) {
	    	rgba * line = (rgba *) pixelscolor;
	    	uint32_t * grayline = (uint32_t *) pixelsgray;
	    	for ( x=0; x < infocolor.width; x++){
	    		tmp =
	    				line[x].red * 0.33
	    				+ line[x].green  * 0.33
						+ line[x].blue * 0.33
						;
	    		grayline[x] =
	    					  (line[x].alpha & 0xff) << 24
							| (tmp & 0xff) << 16
							| (tmp & 0xff) << 8
							| (tmp & 0xff)
							//| line[x].red << 16
							//| line[x].green << 8
	    					//| line[x].blue
							;
	    	}
	    	pixelscolor = (int8_t *)pixelscolor + infocolor.stride;
	    	pixelsgray = (int8_t *) pixelsgray + infogray.stride;
	    }

	    LOGI("Finish convert");
	    AndroidBitmap_unlockPixels(env, origbm);
	    AndroidBitmap_unlockPixels(env, graybm);
}
開發者ID:frzleaf,項目名稱:imageprocessing,代碼行數:51,代碼來源:convertimage.c

示例3: bitmap_to_mat

void bitmap_to_mat(JNIEnv *env, jobject &srcBitmap, Mat &srcMat) {
    void *srcPixels = 0;
    AndroidBitmapInfo srcBitmapInfo;
    try {
        AndroidBitmap_getInfo(env, srcBitmap, &srcBitmapInfo);
        AndroidBitmap_lockPixels(env, srcBitmap, &srcPixels);
        uint32_t srcHeight = srcBitmapInfo.height;
        uint32_t srcWidth = srcBitmapInfo.width;
        srcMat.create(srcHeight, srcWidth, CV_8UC4);
        if (srcBitmapInfo.format == ANDROID_BITMAP_FORMAT_RGBA_8888) {
            Mat tmp(srcHeight, srcWidth, CV_8UC4, srcPixels);
            tmp.copyTo(srcMat);
        } else {
            Mat tmp = Mat(srcHeight, srcWidth, CV_8UC2, srcPixels);
            cvtColor(tmp, srcMat, COLOR_BGR5652RGBA);
        }
        AndroidBitmap_unlockPixels(env, srcBitmap);
        return;
    } catch (cv::Exception &e) {
        AndroidBitmap_unlockPixels(env, srcBitmap);
        jclass je = env->FindClass("java/lang/Exception");
        env -> ThrowNew(je, e.what());
        return;
    } catch (...) {
        AndroidBitmap_unlockPixels(env, srcBitmap);
        jclass je = env->FindClass("java/lang/Exception");
        env -> ThrowNew(je, "unknown");
        return;
    }
}
開發者ID:Fuge2008,項目名稱:SmartCropper,代碼行數:30,代碼來源:android_utils.cpp

示例4: Java_makemachine_android_examples_Nati_greyscale

JNIEXPORT void JNICALL Java_makemachine_android_examples_Nati_greyscale(JNIEnv * env, jclass klass, jobject bitmap,jint wind){
      void * raw;
      uint32_t * pixels;
      int ret,j;
      int grey;
      AndroidBitmapInfo  info;
      if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) return;
      if ((ret = AndroidBitmap_lockPixels(env, bitmap, &raw)) < 0) return;
      pixels=(uint32_t*) raw;
#define USE_CONTRAST STRETCH
#ifdef USE_CONTRAST_STRETCH
      determine_contrast(&pixels,info.height,info.width);
#else
      Qwe::mingrey=0;
      Qwe::maxgrey=255;
#endif
      greyscale(&pixels,info.height,info.width);
      make_mean(info.height,info.width,wind);
#ifdef USE_DEVIATION
      make_dev(info.height,info.width,wind);
#endif
      imtoin(info.height,info.width);
      thresh(info.height,info.width);
      close(info.height,info.width,2);
      open(info.height,info.width,2);

      AndroidBitmap_unlockPixels(env, bitmap);

}
開發者ID:arpheno,項目名稱:receiptKeeper,代碼行數:29,代碼來源:test.cpp

示例5: StackBlur

JNIEXPORT void JNICALL Java_com_daemon_aroundcircleviewdemo_ImageBlur_blurBitMap
(JNIEnv *env, jclass obj, jobject bitmapIn, jint r)
{
AndroidBitmapInfo infoIn;
void* pixelsIn;
int ret;

// Get image info
if ((ret = AndroidBitmap_getInfo(env, bitmapIn, &infoIn)) < 0)
return;
// Check image
if (infoIn.format != ANDROID_BITMAP_FORMAT_RGBA_8888)
return;
// Lock all images
if ((ret = AndroidBitmap_lockPixels(env, bitmapIn, &pixelsIn)) < 0) {
//AndroidBitmap_lockPixels failed!
}
//height width
int h = infoIn.height;
int w = infoIn.width;

//Start
pixelsIn = StackBlur((int*)pixelsIn, w, h, r);
//End

// Unlocks everything
AndroidBitmap_unlockPixels(env, bitmapIn);
}
開發者ID:dalong982242260,項目名稱:AroundCircleView,代碼行數:28,代碼來源:com_daemon_aroundcircleviewdemo_ImageBlur.cpp

示例6: RAW_Setup

GF_Err RAW_Setup(GF_VideoOutput *dr, void *os_handle, void *os_display, u32 init_flags)
{
	AndroidBitmapInfo  info;
	RAWCTX;
	void * pixels;
	int ret;

	GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("Android vout RAW_Setup\n"));

	if (!rc->width)
	{
		rc->env = (JNIEnv *)os_handle;
		rc->bitmap = (jobject *)os_display;

		AndroidBitmap_getInfo(rc->env, *(rc->bitmap), &info);
		rc->width = info.width;
		rc->height = info.height;
		rc->locked_data = NULL;
	}
	else
	{
		rc->env = (JNIEnv *)os_handle;
		rc->bitmap = (jobject *)os_display;
	}

	GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("Android vout rc dims: %d:%d\n", rc->height, rc->width));

	return GF_OK;
}
開發者ID:jnorthrup,項目名稱:gpac,代碼行數:29,代碼來源:droid_vout-bitmap.c

示例7: Java_si_majcn_frameoffame_MainActivity_applyEffect

JNIEXPORT void JNICALL
Java_si_majcn_frameoffame_MainActivity_applyEffect(JNIEnv  *env,
                                                   jobject  obj,
                                                   jobject  bitmap,
                                                   jint     effectNumber)
{
    AndroidBitmapInfo  info;
    int ret;
    void *pixels;

    if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0)
    {
        LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
        return;
    }
    if (info.format != ANDROID_BITMAP_FORMAT_RGB_565)
    {
        LOGE("Bitmap format is not RGBA_565 !");
        return;
    }

    if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0)
    {
        LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
    }

    applyEffect(&info, pixels, effectNumber);

    AndroidBitmap_unlockPixels(env, bitmap);
}
開發者ID:HairyFotr,項目名稱:FrameOfFame,代碼行數:30,代碼來源:imageprocessing.c

示例8: lockPixels

int lockPixels(JNIEnv *env, jobject jbitmap, GifInfo *info, void **pixels) {
    AndroidBitmapInfo bitmapInfo;
    if (AndroidBitmap_getInfo(env, jbitmap, &bitmapInfo) == ANDROID_BITMAP_RESULT_SUCCESS)
        info->stride = bitmapInfo.width;
    else {
        throwException(env, ILLEGAL_STATE_EXCEPTION_BARE, "Could not get bitmap info");
        return -2;
    }

    const int lockPixelsResult = AndroidBitmap_lockPixels(env, jbitmap, pixels);
    if (lockPixelsResult == ANDROID_BITMAP_RESULT_SUCCESS)
        return 0;

    char *message;
    switch (lockPixelsResult) {
        case ANDROID_BITMAP_RESULT_ALLOCATION_FAILED:
#ifdef DEBUG
            LOGE("bitmap lock allocation failed");
#endif
            return -1; //#122 workaround
        case ANDROID_BITMAP_RESULT_BAD_PARAMETER:
            message = "Lock pixels error, bad parameter";
            break;
        case ANDROID_BITMAP_RESULT_JNI_EXCEPTION:
            message = "Lock pixels error, JNI exception";
            break;
        default:
            message = "Lock pixels error";
    }
    throwException(env, ILLEGAL_STATE_EXCEPTION_BARE, message);
    return -2;
}
開發者ID:551780457,項目名稱:android-gif-drawable,代碼行數:32,代碼來源:bitmap.c

示例9: nativeGetFrame

static jlong JNICALL nativeGetFrame(
        JNIEnv* env, jobject clazz, jlong frameSequenceStateLong, jint frameNr,
        jobject bitmap, jint previousFrameNr) {
    FrameSequenceState* frameSequenceState =
            reinterpret_cast<FrameSequenceState*>(frameSequenceStateLong);
    int ret;
    AndroidBitmapInfo info;
    void* pixels;
    if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {

        jniThrowException(env, ILLEGAL_STATE_EXEPTION,
                "Couldn't get info from Bitmap ");
        return 0;
    }

    if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
        jniThrowException(env, ILLEGAL_STATE_EXEPTION,
                "Bitmap pixels couldn't be locked");
        return 0;
    }

    int pixelStride = info.stride >> 2;
    jlong delayMs = frameSequenceState->drawFrame(frameNr,
            (Color8888*) pixels, pixelStride, previousFrameNr);

    AndroidBitmap_unlockPixels(env, bitmap);
    return delayMs;
}
開發者ID:DARKPOP,項目名稱:frameworks_ex,代碼行數:28,代碼來源:FrameSequenceJNI.cpp

示例10: Java_feipeng_andzop_render_RenderView_naRenderAFrame

/*fill in data for a bitmap*/
JNIEXPORT jint JNICALL Java_feipeng_andzop_render_RenderView_naRenderAFrame(JNIEnv * pEnv, jobject pObj, jobject pBitmap, int _width, int _height, float _roiSh, float _roiSw, float _roiEh, float _roiEw) {
    AndroidBitmapInfo lInfo;
    //void* lPixels;
    int lRet;
    int li, lj, lk;
    int lPos;
    unsigned char* ltmp;
    LOGI(3, "start of render_a_frame");    
    //1. retrieve information about the bitmap
    if ((lRet = AndroidBitmap_getInfo(pEnv, pBitmap, &lInfo)) < 0) {
        LOGE(1, "AndroidBitmap_getInfo failed! error = %d", lRet);
        return;
    }
    if (lInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
        LOGE(1, "Bitmap format is not RGBA_8888!");
        return;
    }
    //2. lock the pixel buffer and retrieve a pointer to it
    if ((lRet = AndroidBitmap_lockPixels(pEnv, pBitmap, &gBitmap)) < 0) {
        LOGE(1, "AndroidBitmap_lockPixels() failed! error = %d", lRet);
    }
    //3. modify the pixel buffer
    //decode a video frame: the pBitmap will be filled with decoded pixels
    lRet = decode_a_frame(_width, _height, _roiSh, _roiSw, _roiEh, _roiEw);
    AndroidBitmap_unlockPixels(pEnv, pBitmap);
    LOGI(3, "~~~~~~~~~~end of rendering a frame~~~~~~~~~~~~~~~~~`");
    return lRet;
}
開發者ID:AbdunNurTomal,項目名稱:AndZop,代碼行數:29,代碼來源:android_specific.c

示例11:

jobject Java_com_packpublishing_asynchronousandroid_chapter9_GrayImageLoader_convertImageToGray
        (JNIEnv *env, jobject obj, jobject bitmap) {

    AndroidBitmapInfo info;
    void *pixels;
    int ret;

    if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
        jclass clazz = env->FindClass("java/lang/RuntimeException");
        env->ThrowNew(clazz, "Failed to get Information from the Bitmap!");
        return 0;
    }

    if ((ret = AndroidBitmap_lockPixels(env, bitmap, (void **) &pixels)) < 0) {
        jclass clazz = env->FindClass("java/lang/RuntimeException");
        env->ThrowNew(clazz, "Failed to lock Bitmap pixels !");
        return 0;
    }

    rgba *rgba_pixels = (rgba *) pixels;

    for (int i = 0; i < (info.width * info.height); i++) {
        uint8_t red = rgba_pixels[i].red;
        uint8_t green = rgba_pixels[i].green;
        uint8_t blue = rgba_pixels[i].blue;
        uint8_t gray = red * 0.3 + green * 0.59 + blue * 0.11;
        rgba_pixels[i].red = gray;
        rgba_pixels[i].green = gray;
        rgba_pixels[i].blue = gray;
    }

    AndroidBitmap_unlockPixels(env, bitmap);

    return bitmap;
}
開發者ID:PacktPublishing,項目名稱:Asynchronous-Android-Programming,代碼行數:35,代碼來源:image.cpp

示例12: stackBlur

JNIEXPORT void JNICALL Java_net_qiujuer_genius_app_BlurNative_fastBlurBitmap
(JNIEnv *env, jclass obj, jobject bitmapIn, jint r)
{
	AndroidBitmapInfo infoIn;
	void* pixelsIn;
	int ret;

	// Get image info
	if ((ret = AndroidBitmap_getInfo(env, bitmapIn, &infoIn)) < 0)
		return;
	// Check image
	if (infoIn.format != ANDROID_BITMAP_FORMAT_RGBA_8888)
		return;
	// Lock all images
	if ((ret = AndroidBitmap_lockPixels(env, bitmapIn, &pixelsIn)) < 0) {
		//AndroidBitmap_lockPixels failed!
	}
	// height width
	int h = infoIn.height;
	int w = infoIn.width;

	// Start
	pixelsIn = stackBlur((int*)pixelsIn, w, h, r);
	// End

	// Unlocks everything
	AndroidBitmap_unlockPixels(env, bitmapIn);
}
開發者ID:343829084,項目名稱:Genius-Android,代碼行數:28,代碼來源:BlurNative.c

示例13: jni_freerdp_update_graphics

JNIEXPORT jboolean JNICALL jni_freerdp_update_graphics(
	JNIEnv *env, jclass cls, jint instance, jobject bitmap, jint x, jint y, jint width, jint height)
{

	int ret;
	void* pixels;
	AndroidBitmapInfo info;
	freerdp* inst = (freerdp*)instance;
	rdpGdi *gdi = inst->context->gdi;

	if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0)
	{
		DEBUG_ANDROID("AndroidBitmap_getInfo() failed ! error=%d", ret);
		return JNI_FALSE;
	}

	if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0)
	{
		DEBUG_ANDROID("AndroidBitmap_lockPixels() failed ! error=%d", ret);
		return JNI_FALSE;
	}

	copy_pixel_buffer(pixels, gdi->primary_buffer, x, y, width, height, gdi->width, gdi->height, gdi->bytesPerPixel);

	AndroidBitmap_unlockPixels(env, bitmap);

	return JNI_TRUE;
}
開發者ID:bceverly,項目名稱:FreeRDP,代碼行數:28,代碼來源:android_freerdp.c

示例14: Java_org_yabause_android_YabauseRunnable_stateSlotScreenshot

void
Java_org_yabause_android_YabauseRunnable_stateSlotScreenshot( JNIEnv* env, jobject obj, jobject dirpath, jobject itemnum, int slot, jobject bitmap )
{
    int outputwidth, outputheight;
    u32 * buffer, * cur;
    AndroidBitmapInfo info;
    void * pixels;
    int x, y;
    jboolean dummy;
    const char * dp = (*env)->GetStringUTFChars(env, dirpath, &dummy);
    const char * in = (*env)->GetStringUTFChars(env, itemnum, &dummy);

    if (0 != LoadStateSlotScreenshot(dp, in, slot, &outputwidth, &outputheight, &buffer)) return;

    AndroidBitmap_getInfo(env, bitmap, &info);

    AndroidBitmap_lockPixels(env, bitmap, &pixels);

    cur = buffer;
    for(y = 0;y < info.height;y++) {
        for(x = 0;x < info.width;x++) {
            *((uint32_t *) pixels + x) = *(cur + x);
        }
        pixels += info.stride;
        cur += outputwidth;
    }

    free(buffer);

    AndroidBitmap_unlockPixels(env, bitmap);
}
開發者ID:Amon-X,項目名稱:yabause,代碼行數:31,代碼來源:yui.c

示例15: Java_jp_dego_sample_ipcv_MainActivity_getHairArea

JNIEXPORT void JNICALL Java_jp_dego_sample_ipcv_MainActivity_getHairArea(JNIEnv *env, jobject obj, jobject bmp,
        jint eyes_cp, jint eyes_w)
{
    AndroidBitmapInfo info;
    void* pixels;

    // Bitmapの情報を取得
    if (AndroidBitmap_getInfo(env, bmp, &info) < 0)
        return;
    // Bitmapのフォーマットをチェック
    if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888)
        return;
    // Bitmapをロック
    if (AndroidBitmap_lockPixels(env, bmp, &pixels) < 0)
        return;

    jint *p = pixels;
    int w = info.width;
    int h = info.height;

    // サンプルカラーの取得
    LAB *sc;
    sc = getSampleColor(p, w, h, (int)eyes_cp, (int)eyes_w);

    // 髪色強度マップの作成
    float *map;
    map = getHairIntensity(p, w, h, sc);

    int i, j;

    // Get Maximum and Minimum Value
    float max, min;
    max = *map;
    min = *map;
    for (i = 1; i < info.width * info.height; i++) {
        if (max < *(map + i))
            max = *(map + i);
        if (min > *(map + i))
            min = *(map + i);
    }
    // 256段階でグレースケール化
    unsigned char gray;
    int s;
    jint col;
    for (j = 0; j < info.height; j++) {
        for (i = 0; i < info.width; i++) {
            s = (int)((*(map + j * info.width + i) - (float)min) / ((float)max - min) * 255.0f);
            if (s > 255)
                gray = 255;
            else if (s < 1)
                gray = 0;
            else
                gray = (unsigned char)s;
            col = createColor(0xFF, gray, gray, gray);
            p[j * info.width + i] = col;
        }
    }

    free(map);
}
開發者ID:dego-96,項目名稱:SampleIPCV,代碼行數:60,代碼來源:ipcv.c


注:本文中的AndroidBitmap_getInfo函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。