Make scaler output truly pluggable, add an 8-bit greyscale output to

pluginlib for use with greylib, and add source for a test scaled bmp
viewer using greylib.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19593 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andrew Mahone 2008-12-26 07:05:13 +00:00
parent f7fa7e5ad5
commit 9058620849
17 changed files with 88 additions and 42 deletions

View file

@ -92,6 +92,7 @@ test_sampr,apps
test_scanrate,apps
test_touchscreen,apps
test_viewports,apps
test_greylib_bitmap_scale,viewers
text_editor,apps
vbrfix,viewers
video,viewers

View file

@ -106,6 +106,7 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y,
int stride, int x, int y, int width, int height);
void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width,
int height);
extern const struct custom_format format_grey;
/* Text */
void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str);

View file

@ -669,3 +669,22 @@ void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width,
{
grey_ub_gray_bitmap_part(src, 0, 0, width, x, y, width, height);
}
static void output_row_grey(uint32_t row, void * row_in, struct scaler_context *ctx)
{
int col;
uint32_t *qp = (uint32_t*)row_in;
uint8_t *dest = (uint8_t*)ctx->bm->data + ctx->bm->width * row;
for (col = 0; col < ctx->bm->width; col++)
*dest++ = ((*qp++) + ctx->round) * (uint64_t)ctx->divisor >> 32;
}
static unsigned int get_size_grey(struct bitmap *bm)
{
return bm->width * bm->height;
}
const struct custom_format format_grey = {
.output_row = output_row_grey,
.get_size = get_size_grey
};

View file

@ -636,7 +636,7 @@ bool create_albumart_cache(bool force)
input_bmp.data = (char *)input_bmp_buffer;
ret = rb->read_bmp_file(arlbumart_file, &input_bmp,
sizeof(fb_data)*MAX_IMG_WIDTH*MAX_IMG_HEIGHT,
FORMAT_NATIVE);
FORMAT_NATIVE, NULL);
if (ret <= 0) {
rb->splash(HZ, "Could not read bmp");
continue; /* skip missing/broken files */

View file

@ -2967,7 +2967,7 @@ static int load_bitmap( const char *file )
bm.data = (char*)save_buffer;
ret = rb->read_bmp_file( file, &bm, ROWS*COLS*sizeof( fb_data ),
FORMAT_NATIVE );
FORMAT_NATIVE, NULL );
if((bm.width > COLS ) || ( bm.height > ROWS ))
return -1;

View file

@ -340,7 +340,8 @@ static bool load_resize_bitmap(void)
rc = rb->read_bmp_file( filename, &main_bitmap,
sizeof(img_buf),
FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_DITHER);
FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_DITHER,
NULL);
if( rc > 0 )
{
puzzle_bmp_ptr = (const fb_data *)img_buf;

View file

@ -78,7 +78,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
output_bmp.data = (char*)output_bmp_data;
int ret = rb->read_bmp_file("/test.bmp", &input_bmp, sizeof(input_bmp_data),
FORMAT_NATIVE);
FORMAT_NATIVE, NULL);
if (ret < 0) {
rb->splash(HZ, "Could not load /test.bmp");

View file

@ -25,6 +25,7 @@ wav,viewers/mp3_encoder,-
wav,viewers/wavplay,9
wav,viewers/wavview,10
wav,viewers/test_codec,-
bmp,viewers/test_greylib_bitmap_scale,-
bmp,apps/rockpaint,11
bmp,games/sliding_puzzle,11
mpg,viewers/mpegplayer,4