Create convert_argb888_rgba4444

This commit is contained in:
twinaphex 2015-08-31 14:08:22 +02:00
parent d8ef051f57
commit 0b4ba8443f
3 changed files with 38 additions and 0 deletions
libretro-common
gfx/scaler
include/gfx/scaler

View File

@ -253,6 +253,34 @@ void conv_rgb565_argb8888(void *output_, const void *input_,
}
}
void conv_argb8888_rgba4444(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
const uint32_t *input = (const uint32_t*)input_;
uint16_t *output = (uint16_t*)output_;
for (h = 0; h < height;
h++, output += out_stride >> 2, input += in_stride >> 1)
{
for (w = 0; w < width; w++)
{
uint32_t col = input[w];
uint32_t r = (col >> 16) & 0xf;
uint32_t g = (col >> 8) & 0xf;
uint32_t b = (col) & 0xf;
uint32_t a = (col >> 24) & 0xf;
r = (r >> 4) | r;
g = (g >> 4) | g;
b = (b >> 4) | b;
a = (a >> 4) | a;
output[w] = (r << 12) | (g << 8) | (b << 4) | a;
}
}
}
void conv_rgba4444_argb8888(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)

View File

@ -142,6 +142,8 @@ static bool set_direct_pix_conv(struct scaler_ctx *ctx)
ctx->direct_pixconv = conv_argb8888_bgr24;
else if (ctx->out_fmt == SCALER_FMT_ABGR8888)
ctx->direct_pixconv = conv_argb8888_abgr8888;
else if (ctx->out_fmt == SCALER_FMT_RGBA4444)
ctx->direct_pixconv = conv_argb8888_rgba4444;
break;
case SCALER_FMT_YUYV:
if (ctx->out_fmt == SCALER_FMT_ARGB8888)
@ -198,6 +200,10 @@ static bool set_pix_conv(struct scaler_ctx *ctx)
/* No need to convert :D */
break;
case SCALER_FMT_RGBA4444:
ctx->out_pixconv = conv_argb8888_rgba4444;
break;
case SCALER_FMT_0RGB1555:
ctx->out_pixconv = conv_argb8888_0rgb1555;
break;

View File

@ -57,6 +57,10 @@ void conv_argb8888_0rgb1555(void *output, const void *input,
int width, int height,
int out_stride, int in_stride);
void conv_argb8888_rgba4444(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride);
void conv_argb8888_rgb565(void *output, const void *input,
int width, int height,
int out_stride, int in_stride);