use different function to resize bitmap for greylib.
it is confusing that same function expects different data type (fb_data or unsigned char) depending on the target. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28233 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8ad85ba291
commit
38e88f35f4
3 changed files with 54 additions and 16 deletions
|
@ -27,8 +27,10 @@
|
|||
|
||||
#include "../imageviewer.h"
|
||||
|
||||
#if defined(HAVE_LCD_COLOR)
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
#define resize_bitmap smooth_resize_bitmap
|
||||
#elif defined(USEGSLIB)
|
||||
#define resize_bitmap grey_resize_bitmap
|
||||
#else
|
||||
#define resize_bitmap simple_resize_bitmap
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "file.h"
|
||||
#include "system.h"
|
||||
|
||||
#if defined(HAVE_LCD_COLOR) && LCD_DEPTH > 1
|
||||
#if defined(HAVE_LCD_COLOR)
|
||||
#define LE16(x) (htole16(x))&0xff, ((htole16(x))>>8)&0xff
|
||||
#define LE32(x) (htole32(x))&0xff, ((htole32(x))>>8)&0xff, ((htole32(x))>>16)&0xff, ((htole32(x))>>24)&0xff
|
||||
/**
|
||||
|
@ -90,18 +90,11 @@ int save_bmp_file( char* filename, struct bitmap *bm )
|
|||
/**
|
||||
Very simple image scale from src to dst (nearest neighbour).
|
||||
Source and destination dimensions are read from the struct bitmap.
|
||||
|
||||
FB_DATA define is to properly scale with greylib
|
||||
FIXME: this doesn't work well for LCD_DEPTH<4
|
||||
*/
|
||||
#if LCD_DEPTH > 8
|
||||
#define FB_DATA fb_data
|
||||
#else
|
||||
#define FB_DATA unsigned char
|
||||
#endif
|
||||
void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst)
|
||||
{
|
||||
#if defined(LCD_STRIDEFORMAT) && \
|
||||
(LCD_STRIDEFORMAT == VERTICAL_STRIDE)
|
||||
#if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE)
|
||||
const int srcw = src->height;
|
||||
const int srch = src->width;
|
||||
const int dstw = dst->height;
|
||||
|
@ -112,18 +105,18 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst)
|
|||
const int dstw = dst->width;
|
||||
const int dsth = dst->height;
|
||||
#endif
|
||||
const FB_DATA *srcd = (FB_DATA *)(src->data);
|
||||
const FB_DATA *dstd = (FB_DATA *)(dst->data);
|
||||
const fb_data *srcd = (fb_data *)(src->data);
|
||||
const fb_data *dstd = (fb_data *)(dst->data);
|
||||
const long xrstep = ((srcw-1) << 8) / (dstw-1);
|
||||
const long yrstep = ((srch-1) << 8) / (dsth-1);
|
||||
FB_DATA *src_row, *dst_row;
|
||||
fb_data *src_row, *dst_row;
|
||||
long xr, yr = 0;
|
||||
int src_x, src_y, dst_x, dst_y;
|
||||
for (dst_y=0; dst_y < dsth; dst_y++)
|
||||
{
|
||||
src_y = (yr >> 8);
|
||||
src_row = (FB_DATA *)&srcd[src_y * srcw];
|
||||
dst_row = (FB_DATA *)&dstd[dst_y * dstw];
|
||||
src_row = (fb_data *)&srcd[src_y * srcw];
|
||||
dst_row = (fb_data *)&dstd[dst_y * dstw];
|
||||
for (xr=0,dst_x=0; dst_x < dstw; dst_x++)
|
||||
{
|
||||
src_x = (xr >> 8);
|
||||
|
@ -134,6 +127,40 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst)
|
|||
}
|
||||
}
|
||||
|
||||
#if (LCD_DEPTH < 4)
|
||||
/**
|
||||
Same as simple_resize_bitmap except this is for use with greylib.
|
||||
*/
|
||||
void grey_resize_bitmap(struct bitmap *src, struct bitmap *dst)
|
||||
{
|
||||
const int srcw = src->width;
|
||||
const int srch = src->height;
|
||||
const int dstw = dst->width;
|
||||
const int dsth = dst->height;
|
||||
const long xrstep = ((srcw-1) << 8) / (dstw-1);
|
||||
const long yrstep = ((srch-1) << 8) / (dsth-1);
|
||||
unsigned char *srcd = src->data;
|
||||
unsigned char *dstd = dst->data;
|
||||
unsigned char *src_row, *dst_row;
|
||||
long xr, yr = 0;
|
||||
int src_x, src_y, dst_x, dst_y;
|
||||
for (dst_y=0; dst_y < dsth; dst_y++)
|
||||
{
|
||||
src_y = (yr >> 8);
|
||||
src_row = &srcd[src_y * srcw];
|
||||
dst_row = &dstd[dst_y * dstw];
|
||||
for (xr=0,dst_x=0; dst_x < dstw; dst_x++)
|
||||
{
|
||||
src_x = (xr >> 8);
|
||||
dst_row[dst_x] = src_row[src_x];
|
||||
xr += xrstep;
|
||||
}
|
||||
yr += yrstep;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#include "wrappers.h"
|
||||
|
||||
/* import the core bmp loader */
|
||||
|
|
|
@ -37,10 +37,19 @@ int save_bmp_file( char* filename, struct bitmap *bm );
|
|||
*/
|
||||
void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst);
|
||||
|
||||
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
|
||||
/**
|
||||
Same as simple_resize_bitmap except this is for use with greylib.
|
||||
*/
|
||||
void grey_resize_bitmap(struct bitmap *src, struct bitmap *dst);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
/**
|
||||
Advanced image scale from src to dst (bilinear) based on imlib2.
|
||||
Source and destination dimensions are read from the struct bitmap.
|
||||
*/
|
||||
void smooth_resize_bitmap(struct bitmap *src, struct bitmap *dst);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue