Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing 使用ndk的Android位图操作_Image Processing_Bitmap_Android Ndk_Java Native Interface - Fatal编程技术网

Image processing 使用ndk的Android位图操作

Image processing 使用ndk的Android位图操作,image-processing,bitmap,android-ndk,java-native-interface,Image Processing,Bitmap,Android Ndk,Java Native Interface,目前我正在开发一个Android应用程序,它涉及一些图像处理。在我做了一些研究之后,我发现使用androidndk进行位图操作可以获得更好的性能。我找到了一些基本的例子,比如: 静态void myFunction(AndroidBitmapInfo*信息,void*像素){ int xx,yy,红色,绿色,蓝色; uint32_t*线; 用于(yy=0;yyheight;yy++){ 行=(uint32_t*)像素; 对于(xx=0;xxwidth;xx++){ //从像素中提取RGB值 蓝色=

目前我正在开发一个Android应用程序,它涉及一些图像处理。在我做了一些研究之后,我发现使用androidndk进行位图操作可以获得更好的性能。我找到了一些基本的例子,比如:

静态void myFunction(AndroidBitmapInfo*信息,void*像素){
int xx,yy,红色,绿色,蓝色;
uint32_t*线;
用于(yy=0;yyheight;yy++){
行=(uint32_t*)像素;
对于(xx=0;xxwidth;xx++){
//从像素中提取RGB值
蓝色=(int)((行[xx]&0x00FF0000)>>16);
绿色=(int)((第[xx]行和0x0000FF00)行>>8);
红色=(int)(第[xx]行和0x00000FF);
//更改RGB值
//重新设置新像素
第[xx]行=

((蓝色我对你的函数做了一些编辑,基本上是为了得到像素在数组中的位置,公式是:

位置=y*宽度+x

static void myFunction(AndroidBitmapInfo* info, void* pixels){
int xx, yy, red, green, blue;
uint32_t* px = pixels;

for(yy = 0; yy < info->height; yy++){
    for(xx =0; xx < info->width; xx++){

        int position = yy*info->width+xx;//this formula gives you the address of pixel with coordinates (xx; yy) in 'px' 

        //extract the RGB values from the pixel
        blue = (int) ((line[position] & 0x00FF0000) >> 16);
        green = (int)((line[position] & 0x0000FF00) >> 8);
        red = (int) (line[position] & 0x00000FF );

        //change the RGB values

        // set the new pixel back in
        line[position] =
                ((blue << 16) & 0x00FF0000) |
                ((green << 8) & 0x0000FF00) |
                (red & 0x000000FF);
         //so the position of the south pixel is (yy+1)*info->width+xx
         //and the one of the north is (yy-1)*info->width+xx
         //the left yy*info->width+xx-1
         //the right yy*info->width+xx+1
    }
}
静态void myFunction(AndroidBitmapInfo*信息,void*像素){
int xx,yy,红色,绿色,蓝色;
uint32_t*px=像素;
用于(yy=0;yyheight;yy++){
对于(xx=0;xxwidth;xx++){
int position=yy*info->width+xx;//这个公式给出了在“px”中坐标为(xx;yy)的像素的地址
//从像素中提取RGB值
蓝色=(int)((行[位置]&0x00FF0000)>>16);
绿色=(int)((行[位置]&0x0000FF00)>>8);
红色=(int)(行[位置]&0x00000FF);
//更改RGB值
//重新设置新像素
行[位置]=
((蓝色宽度+xx)
//左侧yy*info->宽度+xx-1
//右yy*信息->宽度+xx+1
}
}
假设要读取/编辑坐标为x,y的像素

您必须检查是否为0