1
我正面临处理RGB_565位图的问题。我的代码工作正常ARGB_8888: 这里有一些代码段我用ARGB_8888(工作正常):在NDK中处理RGB_565位图
typedef struct
{
uint8_t red;
uint8_t green;
uint8_t blue;
uint8_t alpha;
} argb;
.....
.....
void* pixelscolor;
int ret;
int y;
int x;
uint32_t *pixel;
if ((ret = AndroidBitmap_getInfo(env, bmp, &infocolor)) < 0) {
//return null;
}
if ((ret = AndroidBitmap_lockPixels(env, bmp, &pixelscolor)) < 0) {
}
int width = infocolor.width;
int height = infocolor.height;
for (y = 0; y < height; y++) {
argb * line = (argb *) pixelscolor;
for (int n = 0; n < width; n++) {
int newValue = line[n].alpha+line[n].red+line[n].green+line[n].blue;
......
....
我得到这样 ARGB_8888 results结果。
但尝试RGB_565格式时:
typedef struct
{
uint8_t red;
uint8_t green;
uint8_t blue;
} rgb;
.....
.....
void* pixelscolor;
int ret;
int y;
int x;
uint32_t *pixel;
if ((ret = AndroidBitmap_getInfo(env, bmp, &infocolor)) < 0) {
//return null;
}
if ((ret = AndroidBitmap_lockPixels(env, bmp, &pixelscolor)) < 0) {
}
int width = infocolor.width;
int height = infocolor.height;
for (y = 0; y < height; y++) {
rgb * line = (rgb *) pixelscolor;
for (int n = 0; n < width; n++) {
int newValue = line[n].red+line[n].green+line[n].blue;
......
....
我得到以下结果:RGB_565 result
谢谢,这样可以解决重复问题。但结果的质量不如ARGB_8888格式。尽管我的程序从不使用alpha通道。无论如何,非常感谢:) – Thilleli
@Thilleli不客气:) – Sergio