I am trying to convert an open cv mat of type CV_8UC3 (RGB) to an integer array.
void copyMatToJIntArray(Mat m,jint* jia)
{
Mat tempMat;
cvtColor(m,tempMat,CV_BGRA2RGB);
jint size = tempMat.rows*tempMat.cols* tempMat.elemSize();
u_char * uchars = new u_char[size];
for(int r=0;r<tempMat.rows;r++)
{
for(int c=0;c<tempMat.cols;c++)
{
u_char r=*(tempMat.data+ r*tempMat.step + c);
u_char g=*(tempMat.data+ r*tempMat.step + c+1);
u_char b=*(tempMat.data+ r*tempMat.step + c+2);
uchars[r*tempMat.step+c]=r;
uchars[r*tempMat.step+c+1]=g;
uchars[r*tempMat.step+c+2]=b;
}
}
for (int i = 0; i < tempMat.rows*tempMat.cols; i++)
{
jia[i] = uchars[i];
}
}
I pass this inteher array via JNI to android java where it is converted into an a bitmap
croppedImageBitmap.setPixels(BGRA, 0, width, 0, 0, width, height);
imageView1.setImageBitmap(croppedImageBitmap);
But when I view it on my android test phone, there is a blue tint over the image