add PNG support
Subsystems (4)
v4 cover add PNG support
Hi,
v4:
- fix comment
- reorder graphic_utilils adding
v3:
- fix comment
- add introduce image helper
while use the image renderer for multiple image support I found tis was missing
This even simplify png implemtation by not duplication the rendering
v2:
fix comment
fix missing select
drop logo (will be send in a seprated pull)
please pull
The following changes since commit 4271879e3b82e2e4d52a46f7c4ef01461a786b5e:
fsl TSEC: register map boundary (2012-09-11 10:06:09 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git tags/png
for you to fetch changes up to 7dad2c8a260282c07ada0c291a441a16563746ef:
png: add picoPNG lib support (2012-09-12 21:21:07 +0800)
----------------------------------------------------------------
Introduce PNG support
This will allow to reduce the binary size and support transparent image png + png8 is 50% less than lzo + bmp (same image)
- rename bmp to splash
- add background support (usefull for transparent image)
- add LodePNG and PicoPNG
PicoPNG only support PNG8 RGBA where LodePNG support most of the PNG (PNG24 & PNG8). PicoPNG is ~5KiB smaller than LodePNG.
Attention the coding style on both PicoPNG and LodePNG are untouched for maintainance purpose.
Use LodePNG version 20120729 from http://lodev.org/lodepng/
Use from http://forge.voodooprojects.org/
which is base on picoPNG C++ wrote by Lode Vandevenne. The same author as LodePNG.
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (11):
bmp: rename it to splash
bmp: split bmp rending in lib/bmp.c Introduce graphic utils
introduce image_renderer framework
filetype: add BMP support
splash/bmp: switch to image_renderer
splash: add support to set a background color
graphic_utils: add rgba support
filetype: add PNG support
add PNG support
png: add picoPNG lib support
Documentation/commands.dox | 2 +-
arch/arm/boards/eukrea_cpuimx25/env/bin/init_board | 4 +-
arch/arm/boards/eukrea_cpuimx27/env/bin/init | 4 +-
arch/arm/boards/eukrea_cpuimx35/env/bin/init_board | 4 +-
arch/arm/boards/eukrea_cpuimx51/env/bin/init_board | 4 +-
arch/arm/boards/karo-tx25/env/bin/init_board | 2 +-
arch/arm/boards/mioa701/env/bin/init | 2 +-
arch/arm/configs/chumbyone_defconfig | 2 +-
arch/arm/configs/cupid_defconfig | 2 +-
arch/arm/configs/eukrea_cpuimx25_defconfig | 2 +-
arch/arm/configs/eukrea_cpuimx27_defconfig | 2 +-
arch/arm/configs/eukrea_cpuimx35_defconfig | 2 +-
arch/arm/configs/freescale_mx35_3stack_defconfig | 2 +-
arch/arm/configs/imx28evk_defconfig | 2 +-
arch/arm/configs/mioa701_defconfig | 2 +-
arch/arm/configs/neso_defconfig | 2 +-
arch/arm/configs/pcm027_defconfig | 2 +-
arch/arm/configs/pcm038_defconfig | 2 +-
arch/arm/configs/tx25stk5_defconfig | 2 +-
arch/arm/configs/tx28stk5_defconfig | 2 +-
commands/Kconfig | 5 +-
commands/Makefile | 2 +-
commands/bmp.c | 221 ------
commands/splash.c | 133 ++++
common/filetype.c | 5 +
include/filetype.h | 2 +
include/graphic_utils.h | 17 +
include/image_renderer.h | 85 +++
lib/Kconfig | 36 +
lib/Makefile | 5 +
lib/bmp.c | 134 ++++
{include => lib}/bmp_layout.h | 11 +
lib/graphic_utils.c | 191 +++++
lib/image_renderer.c | 96 +++
lib/lodepng.c | 5928 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/lodepng.h | 1640 +++++++++++++++++++++++++++++++++++++++
lib/picopng.c | 810 ++++++++++++++++++++
lib/picopng.h | 34 +
lib/png.c | 89 +++
lib/png.h | 21 +
lib/png_lode.c | 90 +++
lib/png_pico.c | 85 +++
42 files changed, 9440 insertions(+), 248 deletions(-)
delete mode 100644 commands/bmp.c
create mode 100644 commands/splash.c
create mode 100644 include/graphic_utils.h
create mode 100644 include/image_renderer.h
create mode 100644 lib/bmp.c
rename {include => lib}/bmp_layout.h (85%)
create mode 100644 lib/graphic_utils.c
create mode 100644 lib/image_renderer.c
create mode 100644 lib/lodepng.c
create mode 100644 lib/lodepng.h
create mode 100644 lib/picopng.c
create mode 100644 lib/picopng.h
create mode 100644 lib/png.c
create mode 100644 lib/png.h
create mode 100644 lib/png_lode.c
create mode 100644 lib/png_pico.cBest Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 1/11 bmp: rename it to splash
so be can add more format support
---
Documentation/commands.dox | 2 +-
arch/arm/boards/eukrea_cpuimx25/env/bin/init_board | 4 ++--
arch/arm/boards/eukrea_cpuimx27/env/bin/init | 4 ++--
arch/arm/boards/eukrea_cpuimx35/env/bin/init_board | 4 ++--
arch/arm/boards/eukrea_cpuimx51/env/bin/init_board | 4 ++--
arch/arm/boards/karo-tx25/env/bin/init_board | 2 +-
arch/arm/boards/mioa701/env/bin/init | 2 +-
arch/arm/configs/chumbyone_defconfig | 2 +-
arch/arm/configs/cupid_defconfig | 2 +-
arch/arm/configs/eukrea_cpuimx25_defconfig | 2 +-
arch/arm/configs/eukrea_cpuimx27_defconfig | 2 +-
arch/arm/configs/eukrea_cpuimx35_defconfig | 2 +-
arch/arm/configs/freescale_mx35_3stack_defconfig | 2 +-
arch/arm/configs/imx28evk_defconfig | 2 +-
arch/arm/configs/mioa701_defconfig | 2 +-
arch/arm/configs/neso_defconfig | 2 +-
arch/arm/configs/pcm027_defconfig | 2 +-
arch/arm/configs/pcm038_defconfig | 2 +-
arch/arm/configs/tx25stk5_defconfig | 2 +-
arch/arm/configs/tx28stk5_defconfig | 2 +-
commands/Kconfig | 4 ++--
commands/Makefile | 2 +-
commands/{bmp.c => splash.c} | 12 ++++++------
23 files changed, 33 insertions(+), 33 deletions(-)
rename commands/{bmp.c => splash.c} (95%)Documentation/commands.dox +1 -1
@@ -18,7 +18,6 @@ available in @a Barebox: @li @subpage _name @li @subpage addpart_command @li @subpage alternate -@li @subpage bmp_command @li @subpage bootm_command @li @subpage bootu @li @subpage bootz
@@ -95,6 +94,7 @@ available in @a Barebox: @li @subpage sh @li @subpage sleep @li @subpage source +@li @subpage splash_command @li @subpage test @li @subpage timeout @li @subpage true
arch/arm/boards/eukrea_cpuimx25/env/bin/init_board +2 -2
@@ -1,11 +1,11 @@ #!/bin/sh if [ -f /env/logo.bmp ]; then - bmp /env/logo.bmp + splash /env/logo.bmp fb0.enable=1 elif [ -f /env/logo.bmp.lzo ]; then uncompress /env/logo.bmp.lzo /logo.bmp - bmp /logo.bmp + splash /logo.bmp fb0.enable=1 fi
arch/arm/boards/eukrea_cpuimx27/env/bin/init +2 -2
@@ -17,11 +17,11 @@ if [ -e /dev/nand0 ]; then fi if [ -f /env/logo.bmp ]; then - bmp /env/logo.bmp + splash /env/logo.bmp fb0.enable=1 elif [ -f /env/logo.bmp.lzo ]; then uncompress /env/logo.bmp.lzo /logo.bmp - bmp /logo.bmp + splash /logo.bmp fb0.enable=1 fi
arch/arm/boards/eukrea_cpuimx35/env/bin/init_board +2 -2
@@ -1,12 +1,12 @@ #!/bin/sh if [ -f /env/logo.bmp ]; then - bmp /env/logo.bmp + splash /env/logo.bmp fb0.enable=1 gpio_set_value 1 1 elif [ -f /env/logo.bmp.lzo ]; then uncompress /env/logo.bmp.lzo /logo.bmp - bmp /logo.bmp + splash /logo.bmp fb0.enable=1 gpio_set_value 1 1 fi
arch/arm/boards/eukrea_cpuimx51/env/bin/init_board +2 -2
@@ -1,12 +1,12 @@ #!/bin/sh if [ -f /env/logo.bmp ]; then - bmp /env/logo.bmp + splash /env/logo.bmp fb0.enable=1 gpio_set_value 1 1 elif [ -f /env/logo.bmp.lzo ]; then uncompress /env/logo.bmp.lzo /logo.bmp - bmp /logo.bmp + splash /logo.bmp fb0.enable=1 gpio_set_value 1 1 fi
arch/arm/boards/karo-tx25/env/bin/init_board +1 -1
@@ -1,6 +1,6 @@ if [ -e /dev/fb0 -a -e /env/splash.bmp ]; then - bmp /env/splash.bmp + splash /env/splash.bmp fb0.enable=1 fi
arch/arm/boards/mioa701/env/bin/init +1 -1
@@ -12,7 +12,7 @@ led keyboard 0 sdcard_override fb0.enable=1 -bmp /dev/mtd0.barebox-logo +splash /dev/mtd0.barebox-logo mtd_env_override if [ $? = 0 ]; then
arch/arm/configs/chumbyone_defconfig +1 -1
@@ -30,7 +30,7 @@ CONFIG_CMD_RESET=y CONFIG_CMD_GO=y CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_NET=y CONFIG_NET_DHCP=y
arch/arm/configs/cupid_defconfig +1 -1
@@ -45,7 +45,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_NET=y
arch/arm/configs/eukrea_cpuimx25_defconfig +1 -1
@@ -43,7 +43,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_CMD_I2C=y
arch/arm/configs/eukrea_cpuimx27_defconfig +1 -1
@@ -31,7 +31,7 @@ CONFIG_CMD_RESET=y CONFIG_CMD_GO=y CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_CMD_I2C=y
arch/arm/configs/eukrea_cpuimx35_defconfig +1 -1
@@ -44,7 +44,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_CMD_I2C=y
arch/arm/configs/freescale_mx35_3stack_defconfig +1 -1
@@ -42,7 +42,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_CMD_I2C=y
arch/arm/configs/imx28evk_defconfig +1 -1
@@ -33,7 +33,7 @@ CONFIG_CMD_RESET=y CONFIG_CMD_GO=y CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_NET=y CONFIG_NET_DHCP=y
arch/arm/configs/mioa701_defconfig +1 -1
@@ -38,7 +38,7 @@ CONFIG_CMD_BOOTM_INITRD=y CONFIG_CMD_RESET=y CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_CMD_LED=y
arch/arm/configs/neso_defconfig +1 -1
@@ -45,7 +45,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_NET=y
arch/arm/configs/pcm027_defconfig +1 -1
@@ -43,7 +43,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_NET=y
arch/arm/configs/pcm038_defconfig +1 -1
@@ -49,7 +49,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_NET=y
arch/arm/configs/tx25stk5_defconfig +1 -1
@@ -45,7 +45,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_NET=y
arch/arm/configs/tx28stk5_defconfig +1 -1
@@ -41,7 +41,7 @@ CONFIG_CMD_TIMEOUT=y CONFIG_CMD_PARTITION=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y -CONFIG_CMD_BMP=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_GPIO=y CONFIG_CMD_UNCOMPRESS=y CONFIG_NET=y
commands/Kconfig +2 -2
@@ -535,10 +535,10 @@ config CMD_LSMOD depends on MODULES prompt "lsmod" -config CMD_BMP +config CMD_SPLASH bool depends on VIDEO - prompt "bmp" + prompt "splash" help show bmp files on framebuffer devices
commands/Makefile +1 -1
@@ -49,7 +49,7 @@ obj-$(CONFIG_CMD_VERSION) += version.o obj-$(CONFIG_CMD_HELP) += help.o obj-$(CONFIG_CMD_LSMOD) += lsmod.o obj-$(CONFIG_CMD_INSMOD) += insmod.o -obj-$(CONFIG_CMD_BMP) += bmp.o +obj-$(CONFIG_CMD_SPLASH) += splash.o obj-$(CONFIG_USB_GADGET_DFU) += dfu.o obj-$(CONFIG_USB_GADGET_SERIAL) += usbserial.o obj-$(CONFIG_CMD_GPIO) += gpio.o
commands/splash.c renamed from commands/bmp.c +6 -6
@@ -30,7 +30,7 @@ static inline void set_pixel(struct fb_info *info, void *adr, int r, int g, int } } -static int do_bmp (int argc,char *argv[]) +static int do_splash (int argc,char *argv[]) {int ret, opt, fd;char *fbdev ="/dev/fb0" ;
@@ -194,8 +194,8 @@ failed_memmap:return 1 ; } -BAREBOX_CMD_HELP_START(bmp) -BAREBOX_CMD_HELP_USAGE("bmp [OPTIONS] FILE\n") +BAREBOX_CMD_HELP_START(splash) +BAREBOX_CMD_HELP_USAGE("splash [OPTIONS] FILE\n") BAREBOX_CMD_HELP_SHORT("Show the bitmap FILE on the framebuffer.\n") BAREBOX_CMD_HELP_OPT ("-f <fb>", "framebuffer device (/dev/fb0)\n")BAREBOX_CMD_HELP_OPT ("-x <xofs>" ,"x offset (default center)\n" )
@@ -214,8 +214,8 @@ color depth.*/ -BAREBOX_CMD_START (bmp) - .cmd = do_bmp, +BAREBOX_CMD_START (splash) + .cmd = do_splash, .usage = "show a bmp image", - BAREBOX_CMD_HELP(cmd_bmp_help) + BAREBOX_CMD_HELP(cmd_splash_help)BAREBOX_CMD_END
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 2/11 bmp: split bmp rending in lib/bmp.c
So we can add other format support
--- commands/Kconfig | 1 + commands/splash.c | 124 +++++------------------------------------------ include/bmp_layout.h | 11 +++++ lib/Kconfig | 3 ++ lib/Makefile | 1 + lib/bmp.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 159 insertions(+), 113 deletions(-) create mode 100644 lib/bmp.c
commands/Kconfig +1 -0
@@ -538,6 +538,7 @@ config CMD_LSMOD config CMD_SPLASH bool depends on VIDEO + select BMP prompt "splash" help show bmp files on framebuffer devices
commands/splash.c +11 -113
159 lines not on this page · raw message
include/bmp_layout.h +11 -0
@@ -74,4 +74,15 @@ struct bmp_image {#define BMP_BI_RLE8 1#define BMP_BI_RLE4 2 +#ifdef CONFIG_BMP +int bmp_render_file (struct fb_info *info,const char * bmpfile,void * fb, +int startx,int starty,int xres,int yres,void * offscreenbuf); +#else +static inline int bmp_render_file (struct fb_info *info,const char * bmpfile,void * fb, +int startx,int starty,int xres,int yres,void * offscreenbuf) +{ +return -ENOSYS ; +} +#endif +#endif /* _BMP_H_ */
lib/Kconfig +3 -0
@@ -38,4 +38,7 @@ config BITREV config QSORT bool +config BMP + bool + endmenu
lib/Makefile +1 -0
@@ -34,3 +34,4 @@ obj-$(CONFIG_UNCOMPRESS) += uncompress.o obj-$(CONFIG_BCH) += bch.o obj-$(CONFIG_BITREV) += bitrev.o obj-$(CONFIG_QSORT) += qsort.o +obj-$(CONFIG_BMP) += bmp.o
lib/bmp.c new file +132 -0
132 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 3/11 Introduce graphic utils
In reply to Jean-Christophe PLAGNIOL-VILLARDto Factorise pixel rendering
--- include/graphic_utils.h | 14 ++++++++ lib/Makefile | 2 +- lib/bmp.c | 25 ++----------- lib/graphic_utils.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 23 deletions(-) create mode 100644 include/graphic_utils.h create mode 100644 lib/graphic_utils.c
include/graphic_utils.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* GPL v2 +*/ + +#ifndef __GRAPHIC_UTILS_H__ +#define __GRAPHIC_UTILS_H__ + +void set_pixel (struct fb_info *info,void *adr,u32 px); +void set_rgb_pixel (struct fb_info *info,void *adr,u8 r,u8 g,u8 b); +void memset_pixel (struct fb_info *info,void * buf,u32 color,size_t size); + +#endif /* __GRAPHIC_UTILS_H__ */
lib/Makefile +1 -1
@@ -34,4 +34,4 @@ obj-$(CONFIG_UNCOMPRESS) += uncompress.o obj-$(CONFIG_BCH) += bch.o obj-$(CONFIG_BITREV) += bitrev.o obj-$(CONFIG_QSORT) += qsort.o -obj-$(CONFIG_BMP) += bmp.o +obj-$(CONFIG_BMP) += bmp.o graphic_utils.o
lib/bmp.c +3 -22
@@ -5,26 +5,7 @@#include <fb.h> #include <bmp_layout.h> #include <asm/byteorder.h> - -static inline void set_pixel (struct fb_info *info,void *adr,int r,int g,int b) -{ -u32 px; - - px = (r >> (8 - info->red.length)) << info->red.offset | - (g >> (8 - info->green.length)) << info->green.offset | - (b >> (8 - info->blue.length)) << info->blue.offset; - -switch (info->bits_per_pixel) { -case 8 : -break ; -case 16 : - *(u16 *)adr = px; -break ; -case 32 : - *(u32 *)adr = px; -break ; - } -} +#include <graphic_utils.h> int bmp_render_file (struct fb_info *info,const char * bmpfile,void * fb,int startx,int starty,int xres,int yres,void * offscreenbuf)
@@ -88,7 +69,7 @@ int bmp_render_file(struct fb_info *info, const char* bmpfile, void* fb, pixel = *image; -set_pixel (info, adr, color_table[pixel].red, +set_rgb_pixel (info, adr, color_table[pixel].red, color_table[pixel].green, color_table[pixel].blue); adr += info->bits_per_pixel >>3 ;
@@ -110,7 +91,7 @@ int bmp_render_file(struct fb_info *info, const char* bmpfile, void* fb, pixel = image; -set_pixel (info, adr, pixel[2 ], pixel[1 ], +set_rgb_pixel (info, adr, pixel[2 ], pixel[1 ], pixel[0 ]); adr += info->bits_per_pixel >>3 ;
lib/graphic_utils.c new file +89 -0
89 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 4/11 introduce image_renderer framework
In reply to Jean-Christophe PLAGNIOL-VILLARDThis will allow to support bmp and png
--- include/image_renderer.h | 85 ++++++++++++++++++++++++++++++++++++++++ lib/Kconfig | 5 +++ lib/Makefile | 1 + lib/image_renderer.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 187 insertions(+) create mode 100644 include/image_renderer.h create mode 100644 lib/image_renderer.c
include/image_renderer.h new file +85 -0
@@ -0,0 +1,85 @@ +/* +* Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* GPL v2 +*/ + +#ifndef __IMAGE_RENDER_H__ +#define __IMAGE_RENDER_H__ + +#include <filetype.h> +#include <linux/list.h> +#include <errno.h> +#include <linux/err.h> +#include <fb.h> + +struct image { +void *data; +struct image_renderer *ir; +int height; +int width; +int bits_per_pixel; +}; + +struct image_renderer { +enum filetype type; +struct image *(*open)(char *data,int size); +void (*close)(struct image *img); +int (*renderer)(struct fb_info *info,struct image *img,void * fb, +int startx,int starty,void * offscreenbuf); + +/* +* do not free the data read from the file +* needed by bmp support +*/ +int keep_file_data; + +struct list_head list; +}; + +#ifdef CONFIG_IMAGE_RENDERER +int image_renderer_register (struct image_renderer *ir); +void image_render_unregister (struct image_renderer *ir); + +int image_renderer_image (struct fb_info *info,struct image *img,void * fb, +int startx,int starty,void * offscreenbuf); + +struct image *image_renderer_open (const char * file); +void image_renderer_close (struct image *img); + +#else +static inline int image_renderer_register (struct image_renderer *ir) +{ +return -EINVAL ; +} +static inline void image_renderer_unregister (struct image_renderer *ir) {} + +static inline struct image *image_renderer_open (const char * file) +{ +return ERR_PTR (-EINVAL ); +} + +static inline void image_renderer_close (struct image *img) {} + +int image_renderer_image (struct fb_info *info,struct image *img,void * fb, +int startx,int starty,void * offscreenbuf); +#endif + +static inline int image_renderer_file (struct fb_info *info,const char * file,void * fb, +int startx,int starty,void * offscreenbuf) +{ +struct image * img =image_renderer_open (file); +int ret; + +if (IS_ERR (img)) +return PTR_ERR (img); + + ret =image_renderer_image (info, img, fb, startx, starty, + offscreenbuf); + +image_renderer_close (img); + +return ret; +} + +#endif /* __IMAGE_RENDERER_H__ */
lib/Kconfig +5 -0
@@ -38,6 +38,11 @@ config BITREV config QSORT bool +config IMAGE_RENDERER + bool + depends on VIDEO + select FILETYPE + config BMP bool
lib/Makefile +1 -0
@@ -35,3 +35,4 @@ obj-$(CONFIG_BCH) += bch.o obj-$(CONFIG_BITREV) += bitrev.o obj-$(CONFIG_QSORT) += qsort.o obj-$(CONFIG_BMP) += bmp.o graphic_utils.o +obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o
lib/image_renderer.c new file +96 -0
96 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 9/11 filetype: add PNG support
In reply to Jean-Christophe PLAGNIOL-VILLARD--- common/filetype.c | 3 +++ include/filetype.h | 1 + 2 files changed, 4 insertions(+)
common/filetype.c +3 -0
@@ -71,6 +71,7 @@ static int is_fat(u8 *buf)enum filetype file_detect_type (void *_buf) {u32 *buf = _buf; +u64 *buf64 = _buf;u8 *buf8 = _buf;if (strncmp (buf8,"#!/bin/sh" ,9 ) ==0 )
@@ -103,6 +104,8 @@ enum filetype file_detect_type(void *_buf)return filetype_fat;if (strncmp (buf8,"BM" ,2 ) ==0 )return filetype_bmp; +if (buf64[0 ] ==le64_to_cpu (0x0a1a0a0d474e5089ull )) +return filetype_png;return filetype_unknown; }
include/filetype.h +1 -0
@@ -20,6 +20,7 @@ enum filetype { filetype_mips_barebox, filetype_fat, filetype_bmp, + filetype_png, };const char *file_type_to_string (enum filetype f);
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 7/11 splash: add support to set a background color
In reply to Jean-Christophe PLAGNIOL-VILLARDThis will allow to reset the screen to a default color when using transparent PNG.
--- commands/splash.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
commands/splash.c +17 -3
@@ -8,6 +8,7 @@#include <fcntl.h> #include <fb.h> #include <image_renderer.h> +#include <graphic_utils.h> static int do_splash (int argc,char *argv[]) {
@@ -19,13 +20,19 @@ static int do_splash(int argc, char *argv[])int startx =-1 , starty =-1 ;int xres, yres;int offscreen =0 ; +u32 bg_color =0x00000000 ; +bool do_bg = false;void *offscreenbuf =NULL ; -while ((opt =getopt (argc, argv,"f:x:y:o" )) >0 ) { +while ((opt =getopt (argc, argv,"f:x:y:ob:" )) >0 ) {switch (opt) {case 'f' : fbdev = optarg;break ; +case 'b' : + bg_color =simple_strtoul (optarg,NULL ,0 ); + do_bg = true; +break ;case 'x' : startx =simple_strtoul (optarg,NULL ,0 );break ;
@@ -71,8 +78,14 @@ static int do_splash(int argc, char *argv[]) fbsize = xres * yres * (info.bits_per_pixel >>3 ); offscreenbuf =malloc (fbsize); -if (offscreenbuf) -memcpy (offscreenbuf, fb, fbsize); +if (offscreenbuf) { +if (do_bg) +memset_pixel (&info, offscreenbuf, bg_color, xres * yres); +else +memcpy (offscreenbuf, fb, fbsize); + } + }else if (do_bg) { +memset_pixel (&info, fb, bg_color, xres * yres); } if (image_renderer_file(&info, image_file, fb, startx, starty,
@@ -98,6 +111,7 @@ BAREBOX_CMD_HELP_SHORT("Show the bitmap FILE on the framebuffer.\n") BAREBOX_CMD_HELP_OPT ("-f <fb>", "framebuffer device (/dev/fb0)\n") BAREBOX_CMD_HELP_OPT ("-x <xofs>", "x offset (default center)\n") BAREBOX_CMD_HELP_OPT ("-y <yofs>", "y offset (default center)\n") +BAREBOX_CMD_HELP_OPT ("-b <color>", "background color in 0xttrrggbb\n") BAREBOX_CMD_HELP_OPT ("-o", "render offscreen\n")BAREBOX_CMD_HELP_END
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 8/11 graphic_utils: add rgba support
In reply to Jean-Christophe PLAGNIOL-VILLARDthis will allow to render rgba image with or without hw support
--- include/graphic_utils.h | 3 ++ lib/graphic_utils.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+)
include/graphic_utils.h +3 -0
@@ -7,8 +7,11 @@#ifndef __GRAPHIC_UTILS_H__#define __GRAPHIC_UTILS_H__ +void rgba_blend (struct fb_info *info,void *image,void * dest,int height, +int width,int startx,int starty,bool is_rgba);void set_pixel (struct fb_info *info,void *adr,u32 px);void set_rgb_pixel (struct fb_info *info,void *adr,u8 r,u8 g,u8 b); +void set_rgba_pixel (struct fb_info *info,void *adr,u8 r,u8 g,u8 b,u8 a);void memset_pixel (struct fb_info *info,void * buf,u32 color,size_t size);#endif /* __GRAPHIC_UTILS_H__ */
lib/graphic_utils.c +102 -0
111 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 5/11 filetype: add BMP support
In reply to Jean-Christophe PLAGNIOL-VILLARD--- common/filetype.c | 2 ++ include/filetype.h | 1 + 2 files changed, 3 insertions(+)
common/filetype.c +2 -0
@@ -101,6 +101,8 @@ enum filetype file_detect_type(void *_buf)return filetype_mips_barebox;if (is_fat (buf8))return filetype_fat; +if (strncmp (buf8,"BM" ,2 ) ==0 ) +return filetype_bmp;return filetype_unknown; }
include/filetype.h +1 -0
@@ -19,6 +19,7 @@ enum filetype { filetype_sh, filetype_mips_barebox, filetype_fat, + filetype_bmp, };const char *file_type_to_string (enum filetype f);
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 6/11 splash/bmp: switch to image_renderer
In reply to Jean-Christophe PLAGNIOL-VILLARD---
commands/Kconfig | 1 +
commands/splash.c | 10 ++---
lib/Kconfig | 1 +
lib/Makefile | 4 +-
lib/bmp.c | 91 +++++++++++++++++++++++++----------------
{include => lib}/bmp_layout.h | 0
6 files changed, 65 insertions(+), 42 deletions(-)
rename {include => lib}/bmp_layout.h (100%)commands/Kconfig +1 -0
@@ -538,6 +538,7 @@ config CMD_LSMOD config CMD_SPLASH bool depends on VIDEO + select IMAGE_RENDERER select BMP prompt "splash" help
commands/splash.c +5 -5
@@ -7,7 +7,7 @@#include <getopt.h> #include <fcntl.h> #include <fb.h> -#include <bmp_layout.h> +#include <image_renderer.h> static int do_splash (int argc,char *argv[]) {
@@ -15,7 +15,7 @@ static int do_splash(int argc, char *argv[])char *fbdev ="/dev/fb0" ;void *fb;struct fb_info info; -char *bmpfile; +char *image_file;int startx =-1 , starty =-1 ;int xres, yres;int offscreen =0 ;
@@ -40,7 +40,7 @@ static int do_splash(int argc, char *argv[])printf ("no filename given\n" );return 1 ; } - bmpfile = argv[optind]; + image_file = argv[optind]; fd =open (fbdev,O_RDWR );if (fd <0 ) {
@@ -75,8 +75,8 @@ static int do_splash(int argc, char *argv[])memcpy (offscreenbuf, fb, fbsize); } -if (bmp_render_file (&info, bmpfile, fb, startx, starty, xres, yres, - offscreenbuf) <0 ) +if (image_renderer_file (&info, image_file, fb, startx, starty, + offscreenbuf) <0 ) ret =1 ;if (offscreenbuf)
lib/Kconfig +1 -0
@@ -45,5 +45,6 @@ config IMAGE_RENDERER config BMP bool + depends on IMAGE_RENDERER endmenu
lib/Makefile +2 -2
@@ -34,5 +34,5 @@ obj-$(CONFIG_UNCOMPRESS) += uncompress.o obj-$(CONFIG_BCH) += bch.o obj-$(CONFIG_BITREV) += bitrev.o obj-$(CONFIG_QSORT) += qsort.o -obj-$(CONFIG_BMP) += bmp.o graphic_utils.o -obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o +obj-$(CONFIG_BMP) += bmp.o +obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o graphic_utils.o
lib/bmp.c +56 -35
135 lines not on this page · raw message
lib/bmp_layout.h renamed from include/bmp_layout.h +0 -0
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 11/11 png: add picoPNG lib support
In reply to Jean-Christophe PLAGNIOL-VILLARDThis is an alternative to LodePNG take from http://forge.voodooprojects.org/
which is base on picoPNG C++ wrote by Lode Vandevenne. The same author as LodePNG.
PicoPNG only support RGBA PNG8
The source code of picopng.c was just adapted to be compliant with C89 and drop the internal ZLIB support. Coding style untouched.
--- lib/Kconfig | 6 + lib/Makefile | 1 + lib/picopng.c | 810 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/picopng.h | 34 +++ lib/png_pico.c | 85 ++++++ 5 files changed, 936 insertions(+) create mode 100644 lib/picopng.c create mode 100644 lib/picopng.h create mode 100644 lib/png_pico.c
lib/Kconfig +6 -0
@@ -62,6 +62,12 @@ config LODEPNG help This PNG library supports most PNG formats. +config PICOPNG + bool "picoPNG" + help + This PNG library only supports RGBA PNG8 but is much smaller + in binary size than lodepng. + endchoice endif
lib/Makefile +1 -0
@@ -38,3 +38,4 @@ obj-$(CONFIG_BMP) += bmp.o obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o graphic_utils.o obj-$(CONFIG_PNG) += png.o obj-$(CONFIG_LODEPNG) += png_lode.o lodepng.o +obj-$(CONFIG_PICOPNG) += png_pico.o picopng.o
lib/picopng.c new file +810 -0
810 lines not on this page · raw message
lib/picopng.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef _PICOPNG_H +#define _PICOPNG_H + +typedef struct { +uint32_t *data; +size_t size; +size_t allocsize; +}vector32_t ; + +typedef struct { +uint8_t *data; +size_t size; +size_t allocsize; +}vector8_t ; + +typedef struct { +uint32_t width, height; +uint32_t colorType, bitDepth; +uint32_t compressionMethod, filterMethod, interlaceMethod; +uint32_t key_r, key_g, key_b; +bool key_defined;// is a transparent color key given? +vector8_t *palette; +vector8_t *image; +}PNG_info_t ; + +PNG_info_t *PNG_decode (const uint8_t *in,uint32_t size); +void png_alloc_free_all (void ); + +unsigned picopng_zlib_decompress (unsigned char * out,size_t outsize, +const unsigned char * in,size_t insize); + +extern int PNG_error; + +#endif
lib/png_pico.c new file +85 -0
85 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 10/11 add PNG support
In reply to Jean-Christophe PLAGNIOL-VILLARDuse LodePNG version 20120729 from http://lodev.org/lodepng/
The original coding style is keeped to simplify update.
--- commands/Kconfig | 1 - lib/Kconfig | 25 +- lib/Makefile | 2 + lib/lodepng.c | 5928 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/lodepng.h | 1640 +++++++++++++++ lib/png.c | 89 + lib/png.h | 21 + lib/png_lode.c | 90 + 8 files changed, 7793 insertions(+), 3 deletions(-) create mode 100644 lib/lodepng.c create mode 100644 lib/lodepng.h create mode 100644 lib/png.c create mode 100644 lib/png.h create mode 100644 lib/png_lode.c
commands/Kconfig +0 -1
@@ -539,7 +539,6 @@ config CMD_SPLASH bool depends on VIDEO select IMAGE_RENDERER - select BMP prompt "splash" help show bmp files on framebuffer devices
lib/Kconfig +23 -2
@@ -43,8 +43,29 @@ config IMAGE_RENDERER depends on VIDEO select FILETYPE +if IMAGE_RENDERER + config BMP - bool - depends on IMAGE_RENDERER + bool "bmp" + +config PNG + bool "png" + select ZLIB + +if PNG + +choice + prompt "PNG Lib" + +config LODEPNG + bool "lodePNG" + help + This PNG library supports most PNG formats. + +endchoice + +endif + +endif endmenu
lib/Makefile +2 -0
@@ -36,3 +36,5 @@ obj-$(CONFIG_BITREV) += bitrev.o obj-$(CONFIG_QSORT) += qsort.o obj-$(CONFIG_BMP) += bmp.o obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o graphic_utils.o +obj-$(CONFIG_PNG) += png.o +obj-$(CONFIG_LODEPNG) += png_lode.o lodepng.o
lib/lodepng.c new file +5928 -0
2,957 lines not on this page · raw message
lib/lodepng.h new file +1640 -0
1,640 lines not on this page · raw message
lib/png.c new file +89 -0
89 lines not on this page · raw message
lib/png_lode.c new file +90 -0
90 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Part of the diff is not shown here. View the raw message.
Sascha Hauer
maintainerRe: [PATCH 02/11] bmp: split bmp rending in lib/bmp.c
In reply to Jean-Christophe PLAGNIOL-VILLARDArgh!
Why am I writing mails anyway.
In Subject: s/rending/rendering/
Or better: Move bmp rendering to lib/bmp.c
Quoted 378 lines · Jean-Christophe PLAGNIOL-VILLARD
So we can add other format support
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- commands/Kconfig | 1 + commands/splash.c | 124 +++++------------------------------------------ include/bmp_layout.h | 11 +++++ lib/Kconfig | 3 ++ lib/Makefile | 1 + lib/bmp.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 159 insertions(+), 113 deletions(-) create mode 100644 lib/bmp.ccommands/Kconfig +1
-0@@ -538,6 +538,7 @@ config CMD_LSMOD config CMD_SPLASH bool depends on VIDEO + select BMP prompt "splash" help show bmp files on framebuffer devicescommands/splash.c +11
-113@@ -8,43 +8,18 @@#include <fcntl.h> #include <fb.h> #include <bmp_layout.h> -#include <asm/byteorder.h> - -static inline void set_pixel (struct fb_info *info,void *adr,int r,int g,int b) -{ -u32 px; - - px = (r >> (8 - info->red.length)) << info->red.offset | - (g >> (8 - info->green.length)) << info->green.offset | - (b >> (8 - info->blue.length)) << info->blue.offset; - -switch (info->bits_per_pixel) { -case 8 : -break ; -case 16 : - *(u16 *)adr = px; -break ; -case 32 : - *(u32 *)adr = px; -break ; - } -}static int do_splash (int argc,char *argv[]) {int ret, opt, fd;char *fbdev ="/dev/fb0" ; -void *fb, *offscreenbuf =NULL ; +void *fb;struct fb_info info; -struct bmp_image *bmp;char *bmpfile; -int bmpsize; -char *image; -int sw, sh, width, height, startx =-1 , starty =-1 ; -int bits_per_pixel, fbsize; +int startx =-1 , starty =-1 ;int xres, yres;int offscreen =0 ; -void *adr, *buf; +void *offscreenbuf =NULL ;while ((opt =getopt (argc, argv,"f:x:y:o" )) >0 ) {switch (opt) {@@ -88,105 +63,28 @@ static int do_splash(int argc, char *argv[]) xres = info.xres; yres = info.yres; - bmp =read_file (bmpfile, &bmpsize); -if (!bmp) { -printf ("unable to read %s\n" , bmpfile); - goto failed_memmap; - } - -if (bmp->header.signature[0 ] !='B' || - bmp->header.signature[1 ] !='M' ) { -printf ("No valid bmp file\n" ); - } - - sw =le32_to_cpu (bmp->header.width); - sh =le32_to_cpu (bmp->header.height); - -if (startx <0 ) { - startx = (xres - sw) /2 ; -if (startx <0 ) - startx =0 ; - } - -if (starty <0 ) { - starty = (yres - sh) /2 ; -if (starty <0 ) - starty =0 ; - } - - width =min (sw, xres - startx); - height =min (sh, yres - starty); - - bits_per_pixel =le16_to_cpu (bmp->header.bit_count); - fbsize = xres * yres * (info.bits_per_pixel >>3 ); -if (offscreen) { +int fbsize;/* Don't fail if malloc fails, just continue rendering directly * on the framebuffer */ + + fbsize = xres * yres * (info.bits_per_pixel >>3 ); offscreenbuf =malloc (fbsize);if (offscreenbuf)memcpy (offscreenbuf, fb, fbsize); } - buf = offscreenbuf ? offscreenbuf : fb; - -if (bits_per_pixel ==8 ) { -int x, y; -struct bmp_color_table_entry *color_table = bmp->color_table; - -for (y =0 ; y < height; y++) { - image = (char *)bmp + -le32_to_cpu (bmp->header.data_offset); - image += (sh - y -1 ) * sw * (bits_per_pixel >>3 ); - adr = buf + ((y + starty) * xres + startx) * - (info.bits_per_pixel >>3 ); -for (x =0 ; x < width; x++) { -int pixel; +if (bmp_render_file (&info, bmpfile, fb, startx, starty, xres, yres, + offscreenbuf) <0 ) + ret =1 ; - pixel = *image; - -set_pixel (&info, adr, color_table[pixel].red, - color_table[pixel].green, - color_table[pixel].blue); - adr += info.bits_per_pixel >>3 ; - - image += bits_per_pixel >>3 ; - } - } - }else if (bits_per_pixel ==24 ) { -int x, y; - -for (y =0 ; y < height; y++) { - image = (char *)bmp + -le32_to_cpu (bmp->header.data_offset); - image += (sh - y -1 ) * sw * (bits_per_pixel >>3 ); - adr = buf + ((y + starty) * xres + startx) * - (info.bits_per_pixel >>3 ); -for (x =0 ; x < width; x++) { -char *pixel; - - pixel = image; - -set_pixel (&info, adr, pixel[2 ], pixel[1 ], - pixel[0 ]); - adr += info.bits_per_pixel >>3 ; - - image += bits_per_pixel >>3 ; - } - } - }else -printf ("bmp: illegal bits per pixel value: %d\n" , bits_per_pixel); - -if (offscreenbuf) { -memcpy (fb, offscreenbuf, fbsize); +if (offscreenbuf)free (offscreenbuf); - } -free (bmp);close (fd); -return 0 ; +return ret; failed_memmap:close (fd);include/bmp_layout.h +11
-0@@ -74,4 +74,15 @@ struct bmp_image {#define BMP_BI_RLE8 1#define BMP_BI_RLE4 2 +#ifdef CONFIG_BMP +int bmp_render_file (struct fb_info *info,const char * bmpfile,void * fb, +int startx,int starty,int xres,int yres,void * offscreenbuf); +#else +static inline int bmp_render_file (struct fb_info *info,const char * bmpfile,void * fb, +int startx,int starty,int xres,int yres,void * offscreenbuf) +{ +return -ENOSYS ; +} +#endif +#endif /* _BMP_H_ */ lib/Kconfig +3
-0@@ -38,4 +38,7 @@ config BITREV config QSORT bool +config BMP + bool + endmenulib/Makefile +1
-0@@ -34,3 +34,4 @@ obj-$(CONFIG_UNCOMPRESS) += uncompress.o obj-$(CONFIG_BCH) += bch.o obj-$(CONFIG_BITREV) += bitrev.o obj-$(CONFIG_QSORT) += qsort.o +obj-$(CONFIG_BMP) += bmp.olib/bmp.c new file +132
-0@@ -0,0 +1,132 @@ +#include <common.h> +#include <fs.h> +#include <errno.h> +#include <malloc.h> +#include <fb.h> +#include <bmp_layout.h> +#include <asm/byteorder.h> + +static inline void set_pixel (struct fb_info *info,void *adr,int r,int g,int b) +{ +u32 px; + + px = (r >> (8 - info->red.length)) << info->red.offset | + (g >> (8 - info->green.length)) << info->green.offset | + (b >> (8 - info->blue.length)) << info->blue.offset; + +switch (info->bits_per_pixel) { +case 8 : +break ; +case 16 : + *(u16 *)adr = px; +break ; +case 32 : + *(u32 *)adr = px; +break ; + } +} + +int bmp_render_file (struct fb_info *info,const char * bmpfile,void * fb, +int startx,int starty,int xres,int yres,void * offscreenbuf) +{ +struct bmp_image *bmp; +int sw, sh, width, height; +int bits_per_pixel, fbsize; +int bmpsize; +int ret =0 ; +void *adr, *buf; +char *image; + + bmp =read_file (bmpfile, &bmpsize); +if (!bmp) { +printf ("unable to read %s\n" , bmpfile); +return -ENOMEM ; + } + +if (bmp->header.signature[0 ] !='B' || + bmp->header.signature[1 ] !='M' ) { +printf ("No valid bmp file\n" ); + ret = -EINVAL ; + goto err; + } + + sw =le32_to_cpu (bmp->header.width); + sh =le32_to_cpu (bmp->header.height); + +if (startx <0 ) { + startx = (xres - sw) /2 ; +if (startx <0 ) + startx =0 ; + } + +if (starty <0 ) { + starty = (yres - sh) /2 ; +if (starty <0 ) + starty =0 ; + } + + width =min (sw, xres - startx); + height =min (sh, yres - starty); + + bits_per_pixel =le16_to_cpu (bmp->header.bit_count); + fbsize = xres * yres * (info->bits_per_pixel >>3 ); + + buf = offscreenbuf ? offscreenbuf : fb; + +if (bits_per_pixel ==8 ) { +int x, y; +struct bmp_color_table_entry *color_table = bmp->color_table; + +for (y =0 ; y < height; y++) { + image = (char *)bmp + +le32_to_cpu (bmp->header.data_offset); + image += (sh - y -1 ) * sw * (bits_per_pixel >>3 ); + adr = buf + ((y + starty) * xres + startx) * + (info->bits_per_pixel >>3 ); +for (x =0 ; x < width; x++) { +int pixel; + + pixel = *image; + +set_pixel (info, adr, color_table[pixel].red, + color_table[pixel].green, + color_table[pixel].blue); + adr += info->bits_per_pixel >>3 ; + + image += bits_per_pixel >>3 ; + } + } + }else if (bits_per_pixel ==24 ) { +int x, y; + +for (y =0 ; y < height; y++) { + image = (char *)bmp + +le32_to_cpu (bmp->header.data_offset); + image += (sh - y -1 ) * sw * (bits_per_pixel >>3 ); + adr = buf + ((y + starty) * xres + startx) * + (info->bits_per_pixel >>3 ); +for (x =0 ; x < width; x++) { +char *pixel; + + pixel = image; + +set_pixel (info, adr, pixel[2 ], pixel[1 ], + pixel[0 ]); + adr += info->bits_per_pixel >>3 ; + + image += bits_per_pixel >>3 ; + } + } + }else +printf ("bmp: illegal bits per pixel value: %d\n" , bits_per_pixel); + +if (offscreenbuf) +memcpy (fb, offscreenbuf, fbsize); + +free (bmp); +return sh; + +err: +free (bmp); +return ret; +}Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH 05/11] filetype: add BMP support
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- common/filetype.c | 2 ++ include/filetype.h | 1 + 2 files changed, 3 insertions(+)common/filetype.c +0
-0
common/filetype.c enum filetype file_detect_type(void *_buf) · line 105
Quoted 5 lines
common/filetype.c +2
-0@@ -101,6 +101,8 @@ enum filetype file_detect_type(void *_buf)return filetype_mips_barebox;if (is_fat (buf8))return filetype_fat; +if (strncmp (buf8,"BM" ,2 ) ==0 ) +return filetype_bmp;
The corresponding string in filetype_str is missing
Quoted 24 lines
common/filetype.c +0
-0return filetype_unknown; }include/filetype.h +1
-0@@ -19,6 +19,7 @@ enum filetype { filetype_sh, filetype_mips_barebox, filetype_fat, + filetype_bmp, };const char *file_type_to_string (enum filetype f);Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH 09/11] filetype: add PNG support
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 19 lines · Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- common/filetype.c | 3 +++ include/filetype.h | 1 + 2 files changed, 4 insertions(+)common/filetype.c +1
-0@@ -71,6 +71,7 @@ static int is_fat(u8 *buf)enum filetype file_detect_type (void *_buf) {u32 *buf = _buf; +u64 *buf64 = _buf;u8 *buf8 = _buf;if (strncmp (buf8,"#!/bin/sh" ,9 ) ==0 )
common/filetype.c enum filetype file_detect_type(void *_buf) · line 108
Quoted 5 lines
common/filetype.c +2
-0@@ -103,6 +104,8 @@ enum filetype file_detect_type(void *_buf)return filetype_fat;if (strncmp (buf8,"BM" ,2 ) ==0 )return filetype_bmp; +if (buf64[0 ] ==le64_to_cpu (0x0a1a0a0d474e5089ull )) +return filetype_png;
The corresponding string in filetype_str is missing
Quoted 24 lines
common/filetype.c +0
-0return filetype_unknown; }include/filetype.h +1
-0@@ -20,6 +20,7 @@ enum filetype { filetype_mips_barebox, filetype_fat, filetype_bmp, + filetype_png, };const char *file_type_to_string (enum filetype f);Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH 02/11] bmp: split bmp rending in lib/bmp.c
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 7 lines · Sascha Hauer
Argh!
Why am I writing mails anyway.
In Subject: s/rending/rendering/
Or better: Move bmp rendering to
lib/bmp.csorry forget
You won. I fixed this up myself and applied this series.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 02/11] bmp: split bmp rending in lib/bmp.c
In reply to Sascha HauerQuoted 7 lines · Sascha Hauer
Argh!
Why am I writing mails anyway.
In Subject: s/rending/rendering/
Or better: Move bmp rendering to
lib/bmp.c
sorry forget
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox