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


C++ AndroidBitmap_unlockPixels函數代碼示例

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


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

示例1: 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

示例2: 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

示例3: JNIFUNCF

void JNIFUNCF(ImageFilterFx, nativeApplyFilter, jobject bitmap, jint width, jint height,
        jobject lutbitmap, jint lutwidth, jint lutheight,
        jint start, jint end)
{
    char* destination = 0;
    char* lut = 0;
    AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
    AndroidBitmap_lockPixels(env, lutbitmap, (void**) &lut);
    unsigned char * rgb = (unsigned char * )destination;
    unsigned char * lutrgb = (unsigned char * )lut;
    int lutdim_r   = lutheight;
    int lutdim_g   = lutheight;;
    int lutdim_b   = lutwidth/lutheight;;
    int STEP = 4;

    int off[8] =  {
            0,
            STEP*1,
            STEP*lutdim_r,
            STEP*(lutdim_r + 1),
            STEP*(lutdim_r*lutdim_b),
            STEP*(lutdim_r*lutdim_b+1),
            STEP*(lutdim_r*lutdim_b+lutdim_r),
            STEP*(lutdim_r*lutdim_b+lutdim_r + 1)
    };

    float scale_R = (lutdim_r-1.f)/256.f;
    float scale_G = (lutdim_g-1.f)/256.f;
    float scale_B = (lutdim_b-1.f)/256.f;

    int i;
    for (i = start; i < end; i+= STEP)
    {
        int r = rgb[RED];
        int g = rgb[GREEN];
        int b = rgb[BLUE];

        float fb = b*scale_B;
        float fg = g*scale_G;
        float fr = r*scale_R;
        int lut_b = (int)fb;
        int lut_g = (int)fg;
        int lut_r = (int)fr;
        int p = lut_r+lut_b*lutdim_r+lut_g*lutdim_r*lutdim_b;
        p*=STEP;
        float dr = fr-lut_r;
        float dg = fg-lut_g;
        float db = fb-lut_b;
        rgb[RED]   = clamp(interp(lutrgb,p  ,off,dr,dg,db));
        rgb[GREEN] = clamp(interp(lutrgb,p+1,off,dr,dg,db));
        rgb[BLUE]  = clamp(interp(lutrgb,p+2,off,dr,dg,db));

    }

    AndroidBitmap_unlockPixels(env, bitmap);
    AndroidBitmap_unlockPixels(env, lutbitmap);
}
開發者ID:AOSB,項目名稱:android_packages_apps_Gallery2,代碼行數:57,代碼來源:fx.c

示例4: JNIFUNCF

void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterCrop, jobject src, jint srcWidth, jint srcHeight, jobject dst, jint dstWidth, jint dstHeight, jint offsetWidth, jint offsetHeight) {
    char* destination = 0;
    char* source = 0;
    int len = dstWidth * dstHeight * 4;
    AndroidBitmap_lockPixels(env, src, (void**) &source);
    AndroidBitmap_lockPixels(env, dst, (void**) &destination);
    crop(source, srcWidth, srcHeight, destination, dstWidth, dstHeight, offsetWidth, offsetHeight);
    AndroidBitmap_unlockPixels(env, dst);
    AndroidBitmap_unlockPixels(env, src);
}
開發者ID:jituo666,項目名稱:CrazyPic,代碼行數:10,代碼來源:geometry.c

示例5: 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

示例6: AndroidBitmap_unlockPixels

BitmapPixelsLock::~BitmapPixelsLock() {
  if (ptr_) {
    jthrowable pendingException = env_->ExceptionOccurred();
    if (!pendingException) {
      AndroidBitmap_unlockPixels(env_, bitmap_);
      return;
    }
    // unlockPixels by itself should not throw, but it can't run if
    // there's an exception pending
    env_->ExceptionClear();
    AndroidBitmap_unlockPixels(env_, bitmap_);
    env_->Throw(pendingException);
  }
}
開發者ID:1032689332,項目名稱:fresco,代碼行數:14,代碼來源:bitmap_utils.cpp

示例7: Java_makemachine_android_examples_Nati_getrot

JNIEXPORT void JNICALL Java_makemachine_android_examples_Nati_getrot(JNIEnv * env, jclass klass, jobject bitmap){
    int ret,j;
      uint32_t * pixels;
      void * raw;
      AndroidBitmapInfo  info;
      if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) return;
      if ((ret = AndroidBitmap_lockPixels(env, bitmap, &raw)) < 0) return;
      pixels=(uint32_t*)raw;
       for(j=0;j<info.height*info.width;j++){
          *(pixels+j)=*(Qwe::image+j);
      }
     int h,w,oH,oW,nW;
     oH=info.width;
     oW=info.height;
     nW=info.width;
      for(w=0;w<oW;w++){
	      for(h=0;h<oH;h++){
		      *(pixels+nW-h-1+nW*w)=*(Qwe::image+oW*h+w);
	      }
      }
      AndroidBitmap_unlockPixels(env, bitmap);
      free(Qwe::image);
      free(Qwe::integral);
      free(Qwe::mean);
      free(Qwe::dev);
#ifdef USE_DEVIATION
      free(Qwe::intsquare);
#endif
}
開發者ID:arpheno,項目名稱:receiptKeeper,代碼行數:29,代碼來源:test.cpp

示例8: Java_app_ssm_duck_duckapp_CropActivity_seperateLetter

JNIEXPORT void JNICALL Java_app_ssm_duck_duckapp_CropActivity_seperateLetter(JNIEnv *env, jobject obj, jobject bitmap) {
    AndroidBitmapInfo info;
    void* pixels;

    //get information for bitmap object
    if(0>AndroidBitmap_getInfo(env, bitmap,&info)){
        LOGE("AndroidBitmap_getInfo() failed!");
        return;
    }

    LOGI("imagesize(%d,%d)\n",info.width,info.height);

    if(info.format != ANDROID_BITMAP_FORMAT_RGB_565){
        LOGE("Bitmap format is not RGB_565:%d\n",info.format);
        //return;
    }

    //attemp to lock the pixel address.
    if(0> AndroidBitmap_lockPixels(env,bitmap,&pixels)){
        LOGE("AndroidBitmap_lockPixels() failed!");
        return;
    }

    //함수

    AndroidBitmap_unlockPixels(env,bitmap);

}
開發者ID:DuckYoo,項目名稱:SSMemo,代碼行數:28,代碼來源:letterConvert.cpp

示例9: JNIFUNCF

void JNIFUNCF(ImageFilterSaturated, nativeApplyFilter, jobject bitmap, jint width, jint height, jfloat saturation)
{
    char* destination = 0;
    AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
    int i;
    int len = width * height * 4;
    float Rf = 0.2999f;
    float Gf = 0.587f;
    float Bf = 0.114f;
    float S = saturation;;
    float MS = 1.0f - S;
    float Rt = Rf * MS;
    float Gt = Gf * MS;
    float Bt = Bf * MS;
    float R, G, B;
    for (i = 0; i < len; i+=4)
    {
        int r = destination[RED];
        int g = destination[GREEN];
        int b = destination[BLUE];
        int t = (r + g) / 2;
        R = r;
        G = g;
        B = b;

        float Rc = R * (Rt + S) + G * Gt + B * Bt;
        float Gc = R * Rt + G * (Gt + S) + B * Bt;
        float Bc = R * Rt + G * Gt + B * (Bt + S);

        destination[RED] = CLAMP(Rc);
        destination[GREEN] = CLAMP(Gc);
        destination[BLUE] = CLAMP(Bc);
    }
    AndroidBitmap_unlockPixels(env, bitmap);
}
開發者ID:AOSB,項目名稱:android_packages_apps_Gallery2,代碼行數:35,代碼來源:saturated.c

示例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: memcpy

/*
 * Class:     org_opencv_android_Utils
 * Method:    nBitmapToMat(long m, Bitmap b)
 * Signature: (JL)Z
 */
JNIEXPORT jboolean JNICALL Java_org_opencv_android_Utils_nMatToBitmap
  (JNIEnv * env, jclass cls, jlong m, jobject bitmap)
{
    AndroidBitmapInfo  info;
    void*              pixels;
    cv::Mat* mat = (cv::Mat*) m;

    if ( mat == 0 || mat->data == 0)
        return false; // no native Mat behind

    if ( AndroidBitmap_getInfo(env, bitmap, &info) < 0 )
        return false; // can't get info

    if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888)
        return false; // incompatible format

    if ( AndroidBitmap_lockPixels(env, bitmap, &pixels) < 0 )
        return false; // can't get pixels

    if(mat->data && pixels)
        memcpy(pixels, mat->data, info.height * info.width * 4);

    AndroidBitmap_unlockPixels(env, bitmap);

    return true;
}
開發者ID:dgiunchi,項目名稱:OpenCV,代碼行數:31,代碼來源:utils.cpp

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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