当前位置: 首页>>代码示例>>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;未经允许,请勿转载。