안드로이드 ndk를 사용하여 간단한 이미지 필터링을 시도하고 비트 맵의 rgb 값을 가져 와서 설정하는 데 문제가있는 것 같습니다.Android NDK 세트 RGB 비트 맵 픽셀
나는 모든 실제 처리를 제거했으며 비트 맵의 모든 픽셀을 빨간색으로 설정하려고했지만 대신 파란색 이미지로 끝납니다. 내가 간과 해 왔던 간단한 것이 있다고 가정하지만, 어떤 도움을 주시면 감사하겠습니다.
static void changeIt(AndroidBitmapInfo* info, void* pixels){
int x, y, red, green, blue;
for (y=0;y<info->height;y++) {
uint32_t * line = (uint32_t *)pixels;
for (x=0;x<info->width;x++) {
//get the values
red = (int) ((line[x] & 0xFF0000) >> 16);
green = (int)((line[x] & 0x00FF00) >> 8);
blue = (int) (line[x] & 0x0000FF);
//just set it to all be red for testing
red = 255;
green = 0;
blue = 0;
//why is the image totally blue??
line[x] =
((red << 16) & 0xFF0000) |
((green << 8) & 0x00FF00) |
(blue & 0x0000FF);
}
pixels = (char *)pixels + info->stride;
}
}
각 픽셀의 rgb 값을 어떻게 설정해야합니까 ??
static void changeIt(AndroidBitmapInfo* info, void* pixels){
int x, y, red, green, blue;
for (y=0;y<info->height;y++) {
uint32_t * line = (uint32_t *)pixels;
for (x=0;x<info->width;x++) {
//get the values
blue = (int) ((line[x] & 0xFF0000) >> 16);
green = (int)((line[x] & 0x00FF00) >> 8);
red = (int) (line[x] & 0x0000FF);
//just set it to all be red for testing
red = 255;
green = 0;
blue = 0;
//why is the image totally blue??
line[x] =
((blue<< 16) & 0xFF0000) |
((green << 8) & 0x00FF00) |
(red & 0x0000FF);
}
pixels = (char *)pixels + info->stride;
}
}
내가 잘못하지 않는 한 비트 맵이 ARGB라고 생각합니다. 위의 코드는 SDK가 아닌 NDK (기본 개발 키트)이므로 실제로 C 코드입니다. –