forked from len0rd/rockbox
reduce casts between "unsinged char *" and "fb_data *". make calculation precise. maintain spaces.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28428 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
308936cd35
commit
d055ff4a94
4 changed files with 560 additions and 594 deletions
|
@ -31,19 +31,18 @@
|
|||
#include "lcd.h"
|
||||
#include <lib/pluginlib_bmp.h>
|
||||
#include "tinf.h"
|
||||
#include "png.h"
|
||||
#include "../imageviewer.h"
|
||||
#include "png_decoder.h"
|
||||
#include "bmp.h"
|
||||
|
||||
/* decoder context struct */
|
||||
static LodePNG_Decoder decoder;
|
||||
|
||||
/* my memory pool (from the mp3 buffer) */
|
||||
static char print[128]; /* use a common snprintf() buffer */
|
||||
static char print[32]; /* use a common snprintf() buffer */
|
||||
|
||||
/* decompressed image in the possible sizes (1,2,4,8), wasting the other */
|
||||
static fb_data *disp[9];
|
||||
static fb_data *disp_buf;
|
||||
static unsigned char *disp[9];
|
||||
static unsigned char *disp_buf;
|
||||
|
||||
#if defined(HAVE_LCD_COLOR)
|
||||
#define resize_bitmap smooth_resize_bitmap
|
||||
|
@ -64,16 +63,16 @@ bool img_ext(const char *ext)
|
|||
void draw_image_rect(struct image_info *info,
|
||||
int x, int y, int width, int height)
|
||||
{
|
||||
fb_data **pdisp = (fb_data**)info->data;
|
||||
unsigned char **pdisp = (unsigned char **)info->data;
|
||||
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
rb->lcd_bitmap_part(*pdisp, info->x + x, info->y + y,
|
||||
rb->lcd_bitmap_part((fb_data *)*pdisp, info->x + x, info->y + y,
|
||||
STRIDE(SCREEN_MAIN, info->width, info->height),
|
||||
x + MAX(0, (LCD_WIDTH-info->width)/2),
|
||||
y + MAX(0, (LCD_HEIGHT-info->height)/2),
|
||||
width, height);
|
||||
#else
|
||||
mylcd_ub_gray_bitmap_part((const unsigned char*)*pdisp,
|
||||
mylcd_ub_gray_bitmap_part(*pdisp,
|
||||
info->x + x, info->y + y, info->width,
|
||||
x + MAX(0, (LCD_WIDTH-info->width)/2),
|
||||
y + MAX(0, (LCD_HEIGHT-info->height)/2),
|
||||
|
@ -102,9 +101,8 @@ int load_image(char *filename, struct image_info *info,
|
|||
int w, h; /* used to center output */
|
||||
LodePNG_Decoder *p_decoder = &decoder;
|
||||
|
||||
unsigned char *memory, *memory_max;
|
||||
static size_t memory_size, file_size;
|
||||
static unsigned char *image;
|
||||
unsigned char *memory, *memory_max, *image;
|
||||
size_t memory_size, file_size;
|
||||
|
||||
/* cleanup */
|
||||
memset(&disp, 0, sizeof(disp));
|
||||
|
@ -239,16 +237,16 @@ int load_image(char *filename, struct image_info *info,
|
|||
info->x_size = p_decoder->infoPng.width;
|
||||
info->y_size = p_decoder->infoPng.height;
|
||||
|
||||
disp_buf = (fb_data *)(p_decoder->buf + p_decoder->native_img_size);
|
||||
disp_buf = (fb_data *)ALIGN_UP((uintptr_t)disp_buf,4);
|
||||
*buf_size = memory_max - (unsigned char*)disp_buf;
|
||||
p_decoder->native_img_size = (p_decoder->native_img_size + 3) & ~3;
|
||||
disp_buf = p_decoder->buf + p_decoder->native_img_size;
|
||||
*buf_size = memory_max - disp_buf;
|
||||
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
|
||||
int get_image(struct image_info *info, int ds)
|
||||
{
|
||||
fb_data **p_disp = &disp[ds]; /* short cut */
|
||||
unsigned char **p_disp = &disp[ds]; /* short cut */
|
||||
LodePNG_Decoder *p_decoder = &decoder;
|
||||
|
||||
info->width = p_decoder->infoPng.width / ds;
|
||||
|
@ -270,33 +268,28 @@ int get_image(struct image_info *info, int ds)
|
|||
}
|
||||
struct bitmap bmp_src, bmp_dst;
|
||||
|
||||
int size = info->width * info->height;
|
||||
int size = img_mem(ds);
|
||||
|
||||
if ((unsigned char *)(disp_buf + size) >= p_decoder->buf + p_decoder->buf_size) {
|
||||
if (disp_buf + size >= p_decoder->buf + p_decoder->buf_size) {
|
||||
/* have to discard the current */
|
||||
int i;
|
||||
for (i=1; i<=8; i++)
|
||||
disp[i] = NULL; /* invalidate all bitmaps */
|
||||
|
||||
/* start again from the beginning of the buffer */
|
||||
disp_buf = (fb_data *)(p_decoder->buf + p_decoder->native_img_size);
|
||||
disp_buf = (fb_data *)ALIGN_UP((uintptr_t)disp_buf,4);
|
||||
disp_buf = p_decoder->buf + p_decoder->native_img_size;
|
||||
}
|
||||
|
||||
*p_disp = disp_buf;
|
||||
#ifdef USEGSLIB
|
||||
disp_buf = (fb_data *)((unsigned char *)disp_buf + size);
|
||||
#else
|
||||
disp_buf += size;
|
||||
#endif
|
||||
|
||||
bmp_src.width = p_decoder->infoPng.width;
|
||||
bmp_src.height = p_decoder->infoPng.height;
|
||||
bmp_src.data = (unsigned char *)p_decoder->buf;
|
||||
bmp_src.data = p_decoder->buf;
|
||||
|
||||
bmp_dst.width = info->width;
|
||||
bmp_dst.height = info->height;
|
||||
bmp_dst.data = (unsigned char *)*p_disp;
|
||||
bmp_dst.data = *p_disp;
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
rb->cpu_boost(true);
|
||||
resize_bitmap(&bmp_src, &bmp_dst);
|
||||
|
@ -305,7 +298,7 @@ int get_image(struct image_info *info, int ds)
|
|||
resize_bitmap(&bmp_src, &bmp_dst);
|
||||
#endif /*HAVE_ADJUSTABLE_CPU_FREQ*/
|
||||
} else {
|
||||
*p_disp = (fb_data *)p_decoder->buf;
|
||||
*p_disp = p_decoder->buf;
|
||||
}
|
||||
|
||||
return PLUGIN_OK;
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$id $
|
||||
*
|
||||
* Copyright (C) 2009 by Christophe Gouiran <bechris13250 -at- gmail -dot- com>
|
||||
*
|
||||
* Based on lodepng, a lightweight png decoder/encoder
|
||||
* (c) 2005-2008 Lode Vandevenne
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "../imageviewer.h"
|
File diff suppressed because it is too large
Load diff
|
@ -148,7 +148,7 @@ TINF_TABLES tbl = {
|
|||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f},
|
||||
},
|
||||
|
||||
|
||||
.length_bits = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
|
||||
0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04,
|
||||
|
@ -494,7 +494,7 @@ int tinf_uncompress(void *dest, unsigned int *destLen,
|
|||
}
|
||||
|
||||
if (res != TINF_OK) return TINF_DATA_ERROR;
|
||||
|
||||
|
||||
if (d.source > (unsigned char *)source + sourceLen)
|
||||
return TINF_DATA_ERROR;
|
||||
} while (!bfinal);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue