android Camera问题
JNIEXPORT void JNICALL Java_com_spore_CameraView_decodeframe(JNIEnv * pEnv,jclass pClass, jbyteArray pSource, jint width, jint height,
jbyteArray ydata, jbyteArray udata, jbyteArray vdata) {
jbyte* data = (jbyte*) pEnv->GetByteArrayElements(pSource, 0);
int32_t size = width * height;
int32_t offset = size;
int32_t lFrameSize = width * height;
int32_t lYIndex, lUVIndex;
int32_t lX, lY, lM, lN;
int8_t lColorY[lFrameSize];
int8_t lColorU[lFrameSize / 4];
int8_t lColorV[lFrameSize / 4];
// i along Y and the final pixels
// k along pixels U and V
lM=0;
lN=0;
for (int i = 0, k = 0; i < size; i += 2, k += 1) {
lColorY = data & 0xff;
lColorY[i+1] = data[i + 1] & 0xff;
lColorY[width + i] = data[width + i] & 0xff;
lColorY[width + i + 1] = data[width + i + 1] & 0xff;
lColorV[lN] = data[offset + k] & 0xff-128;
lColorU[lN] = data[offset + k + 1] & 0xff-128;
lN++;
if (i != 0 && (i + 2) % width == 0)
i += width;
}
pEnv->SetByteArrayRegion(ydata, 0, lFrameSize, lColorY);
pEnv->SetByteArrayRegion(udata, 0, lFrameSize / 4, lColorU);
pEnv->SetByteArrayRegion(vdata, 0, lFrameSize / 4, lColorV);
pEnv->ReleaseByteArrayElements(pSource, data, 0);
}
在jni层写的代码,显示出来是黑白的,请问这是怎么回事啊 android jni
补充:移动开发 , Android