add PNG support
Subsystems (4)
cover add PNG support
Hi,
please pull
The following changes since commit f77269a819b1306aa9e0721a2159693fe307142d:
Merge branch 'for-next/usb' (2012-09-05 12:59:59 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git tags/png
for you to fetch changes up to 8e19449313dd5f5c8d78194485901a5533961726:
png: add picoPNG lib support (2012-09-06 13:56:59 +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.
This patch series also include the barebox logo
in logo/ you will found the barebox logo with color or white in:
- bmp (black background)
- png24 (transparent or black background)
- png8 (black background)
for the following size
- 100x100
- 200x200
- 400x400
- 600x600
- 800x800
- 900x900
The logo are origanize in a way to be able to include them in the envfs by just point as it.
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (12):
add barebox logo
bmp: rename it to splash
bmp: split bmp rending in lib/bmp.c introduce image_renderer framework
filetype: add BMP support
splash/bmp: switch to image_renderer
splash: add support to set a background color Introduce graphic utils
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 | 42 +
lib/Kconfig | 34 +
lib/Makefile | 5 +
lib/bmp.c | 108 +++
{include => lib}/bmp_layout.h | 11 +
lib/graphic_utils.c | 191 +++++
lib/image_renderer.c | 73 ++
lib/lodepng.c | 5928 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/lodepng.h | 1640 +++++++++++++++++++++++++++++++++++++++
lib/picopng.c | 810 +++++++++++++++++++
lib/picopng.h | 34 +
lib/png_lode.c | 181 +++++
lib/png_pico.c | 152 ++++
logo/bmp/100x100/color/blackbg/barebox.bmp | Bin 0 -> 30056 bytes
logo/bmp/100x100/white/blackbg/barebox.bmp | Bin 0 -> 30056 bytes
logo/bmp/200x200/color/blackbg/barebox.bmp | Bin 0 -> 120056 bytes
logo/bmp/200x200/white/blackbg/barebox.bmp | Bin 0 -> 120056 bytes
logo/bmp/400x400/color/blackbg/barebox.bmp | Bin 0 -> 480056 bytes
logo/bmp/400x400/white/blackbg/barebox.bmp | Bin 0 -> 480056 bytes
logo/bmp/600x600/color/blackbg/barebox.bmp | Bin 0 -> 1080056 bytes
logo/bmp/600x600/while/blackbg/barebox.bmp | Bin 0 -> 1080056 bytes
logo/bmp/800x800/color/blackbg/barebox.bmp | Bin 0 -> 1920056 bytes
logo/bmp/800x800/white/blackbg/barebox.bmp | Bin 0 -> 1920056 bytes
logo/bmp/900x900/color/blackbg/barebox.bmp | Bin 0 -> 2430056 bytes
logo/bmp/900x900/white/blackbg/barebox.bmp | Bin 0 -> 2430056 bytes
logo/png24/100x100/color/barebox.png | Bin 0 -> 22724 bytes
logo/png24/100x100/color/blackbg/barebox.png | Bin 0 -> 19254 bytes
logo/png24/100x100/white/barebox.png | Bin 0 -> 12053 bytes
logo/png24/100x100/white/blackbg/barebox.png | Bin 0 -> 10940 bytes
logo/png24/200x200/color/barebox.png | Bin 0 -> 71557 bytes
logo/png24/200x200/color/blackbg/barebox.png | Bin 0 -> 60836 bytes
logo/png24/200x200/white/barebox.png | Bin 0 -> 31132 bytes
logo/png24/200x200/white/blackbg/barebox.png | Bin 0 -> 28578 bytes
logo/png24/400x400/color/barebox.png | Bin 0 -> 217170 bytes
logo/png24/400x400/color/blackbg/barebox.png | Bin 0 -> 188172 bytes
logo/png24/400x400/white/barebox.png | Bin 0 -> 78591 bytes
logo/png24/400x400/white/blackbg/barebox.png | Bin 0 -> 72957 bytes
logo/png24/600x600/color/barebox.png | Bin 0 -> 406788 bytes
logo/png24/600x600/color/blackbg/barebox.png | Bin 0 -> 353328 bytes
logo/png24/600x600/while/barebox.png | Bin 0 -> 137235 bytes
logo/png24/600x600/while/blackbg/barebox.png | Bin 0 -> 130454 bytes
logo/png24/800x800/color/barebox.png | Bin 0 -> 627433 bytes
logo/png24/800x800/color/blackbg/barebox.png | Bin 0 -> 547772 bytes
logo/png24/800x800/white/barebox.png | Bin 0 -> 210397 bytes
logo/png24/800x800/white/blackbg/barebox.png | Bin 0 -> 198356 bytes
logo/png24/900x900/color/barebox.png | Bin 0 -> 713120 bytes
logo/png24/900x900/color/blackbg/barebox.png | Bin 0 -> 611586 bytes
logo/png24/900x900/white/barebox.png | Bin 0 -> 204449 bytes
logo/png24/900x900/white/blackbg/barebox.png | Bin 0 -> 190770 bytes
logo/png8/100x100/color/blackbg/barebox.png | Bin 0 -> 8279 bytes
logo/png8/100x100/white/blackbg/barebox.png | Bin 0 -> 6089 bytes
logo/png8/200x200/color/blackbg/barebox.png | Bin 0 -> 23616 bytes
logo/png8/200x200/white/blackbg/barebox.png | Bin 0 -> 14838 bytes
logo/png8/400x400/color/blackbg/barebox.png | Bin 0 -> 71295 bytes
logo/png8/400x400/white/blackbg/barebox.png | Bin 0 -> 38480 bytes
logo/png8/600x600/color/blackbg/barebox.png | Bin 0 -> 130709 bytes
logo/png8/600x600/while/blackbg/barebox.png | Bin 0 -> 68648 bytes
logo/png8/800x800/color/blackbg/barebox.png | Bin 0 -> 205281 bytes
logo/png8/800x800/white/blackbg/barebox.png | Bin 0 -> 104173 bytes
logo/png8/900x900/color/blackbg/barebox.png | Bin 0 -> 236679 bytes
logo/png8/900x900/white/blackbg/barebox.png | Bin 0 -> 106472 bytes
88 files changed, 9394 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_lode.c
create mode 100644 lib/png_pico.c
create mode 100644 logo/bmp/100x100/color/blackbg/barebox.bmp
create mode 100644 logo/bmp/100x100/white/blackbg/barebox.bmp
create mode 100644 logo/bmp/200x200/color/blackbg/barebox.bmp
create mode 100644 logo/bmp/200x200/white/blackbg/barebox.bmp
create mode 100644 logo/bmp/400x400/color/blackbg/barebox.bmp
create mode 100644 logo/bmp/400x400/white/blackbg/barebox.bmp
create mode 100644 logo/bmp/600x600/color/blackbg/barebox.bmp
create mode 100644 logo/bmp/600x600/while/blackbg/barebox.bmp
create mode 100644 logo/bmp/800x800/color/blackbg/barebox.bmp
create mode 100644 logo/bmp/800x800/white/blackbg/barebox.bmp
create mode 100644 logo/bmp/900x900/color/blackbg/barebox.bmp
create mode 100644 logo/bmp/900x900/white/blackbg/barebox.bmp
create mode 100644 logo/png24/100x100/color/barebox.png
create mode 100644 logo/png24/100x100/color/blackbg/barebox.png
create mode 100644 logo/png24/100x100/white/barebox.png
create mode 100644 logo/png24/100x100/white/blackbg/barebox.png
create mode 100644 logo/png24/200x200/color/barebox.png
create mode 100644 logo/png24/200x200/color/blackbg/barebox.png
create mode 100644 logo/png24/200x200/white/barebox.png
create mode 100644 logo/png24/200x200/white/blackbg/barebox.png
create mode 100644 logo/png24/400x400/color/barebox.png
create mode 100644 logo/png24/400x400/color/blackbg/barebox.png
create mode 100644 logo/png24/400x400/white/barebox.png
create mode 100644 logo/png24/400x400/white/blackbg/barebox.png
create mode 100644 logo/png24/600x600/color/barebox.png
create mode 100644 logo/png24/600x600/color/blackbg/barebox.png
create mode 100644 logo/png24/600x600/while/barebox.png
create mode 100644 logo/png24/600x600/while/blackbg/barebox.png
create mode 100644 logo/png24/800x800/color/barebox.png
create mode 100644 logo/png24/800x800/color/blackbg/barebox.png
create mode 100644 logo/png24/800x800/white/barebox.png
create mode 100644 logo/png24/800x800/white/blackbg/barebox.png
create mode 100644 logo/png24/900x900/color/barebox.png
create mode 100644 logo/png24/900x900/color/blackbg/barebox.png
create mode 100644 logo/png24/900x900/white/barebox.png
create mode 100644 logo/png24/900x900/white/blackbg/barebox.png
create mode 100644 logo/png8/100x100/color/blackbg/barebox.png
create mode 100644 logo/png8/100x100/white/blackbg/barebox.png
create mode 100644 logo/png8/200x200/color/blackbg/barebox.png
create mode 100644 logo/png8/200x200/white/blackbg/barebox.png
create mode 100644 logo/png8/400x400/color/blackbg/barebox.png
create mode 100644 logo/png8/400x400/white/blackbg/barebox.png
create mode 100644 logo/png8/600x600/color/blackbg/barebox.png
create mode 100644 logo/png8/600x600/while/blackbg/barebox.png
create mode 100644 logo/png8/800x800/color/blackbg/barebox.png
create mode 100644 logo/png8/800x800/white/blackbg/barebox.png
create mode 100644 logo/png8/900x900/color/blackbg/barebox.png
create mode 100644 logo/png8/900x900/white/blackbg/barebox.pngBest Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/12 introduce image_renderer framework
In reply to Jean-Christophe PLAGNIOL-VILLARDThis will allow to support bmp and png
--- include/image_renderer.h | 62 +++++++++++++++++++++++++++++++++++++++ lib/Kconfig | 3 ++ lib/Makefile | 1 + lib/image_renderer.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 include/image_renderer.h create mode 100644 lib/image_renderer.c
include/image_renderer.h new file +62 -0
@@ -0,0 +1,62 @@ +/* +* 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> + +struct image_renderer { +enum filetype type; +int (*renderer)(struct fb_info *info,void * data,int size,void * fb, +int startx,int starty,void * offscreenbuf); + +struct list_head list; +}; + +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 ; + } +} + +#ifdef CONFIG_IMAGE_RENDERER +int image_renderer_register (struct image_renderer *ir); +void image_render_unregister (struct image_renderer *ir); + +int image_renderer_file (struct fb_info *info,const char * bmpfile,void * fb, +int startx,int starty,void * offscreenbuf); +#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 int image_renderer_file (struct fb_info *info,const char * file,void * fb, +int startx,int starty,void * offscreenbuf) +{ +return -EINVAL ; +} +#endif + +#endif /* __IMAGE_RENDERER_H__ */
lib/Kconfig +3 -0
@@ -38,6 +38,9 @@ config BITREV config QSORT bool +config IMAGE_RENDERER + bool + 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 +obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o
lib/image_renderer.c new file +73 -0
73 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 5/12 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 1/12 add barebox logo
In reply to Jean-Christophe PLAGNIOL-VILLARDin logo/ you will found the barebox logo with color or white in:
- bmp (black background)
- png24 (transparent or black background)
- png8 (black background)
for the following size
- 100x100
- 200x200
- 400x400
- 600x600
- 800x800
- 900x900
The logo are origanize in a way to be able to include them in the envfs by just point as it.
--- logo/bmp/100x100/color/blackbg/barebox.bmp | Bin 0 -> 30056 bytes logo/bmp/100x100/white/blackbg/barebox.bmp | Bin 0 -> 30056 bytes logo/bmp/200x200/color/blackbg/barebox.bmp | Bin 0 -> 120056 bytes logo/bmp/200x200/white/blackbg/barebox.bmp | Bin 0 -> 120056 bytes logo/bmp/400x400/color/blackbg/barebox.bmp | Bin 0 -> 480056 bytes logo/bmp/400x400/white/blackbg/barebox.bmp | Bin 0 -> 480056 bytes logo/bmp/600x600/color/blackbg/barebox.bmp | Bin 0 -> 1080056 bytes logo/bmp/600x600/while/blackbg/barebox.bmp | Bin 0 -> 1080056 bytes logo/bmp/800x800/color/blackbg/barebox.bmp | Bin 0 -> 1920056 bytes logo/bmp/800x800/white/blackbg/barebox.bmp | Bin 0 -> 1920056 bytes logo/bmp/900x900/color/blackbg/barebox.bmp | Bin 0 -> 2430056 bytes logo/bmp/900x900/white/blackbg/barebox.bmp | Bin 0 -> 2430056 bytes logo/png24/100x100/color/barebox.png | Bin 0 -> 22724 bytes logo/png24/100x100/color/blackbg/barebox.png | Bin 0 -> 19254 bytes logo/png24/100x100/white/barebox.png | Bin 0 -> 12053 bytes logo/png24/100x100/white/blackbg/barebox.png | Bin 0 -> 10940 bytes logo/png24/200x200/color/barebox.png | Bin 0 -> 71557 bytes logo/png24/200x200/color/blackbg/barebox.png | Bin 0 -> 60836 bytes logo/png24/200x200/white/barebox.png | Bin 0 -> 31132 bytes logo/png24/200x200/white/blackbg/barebox.png | Bin 0 -> 28578 bytes logo/png24/400x400/color/barebox.png | Bin 0 -> 217170 bytes logo/png24/400x400/color/blackbg/barebox.png | Bin 0 -> 188172 bytes logo/png24/400x400/white/barebox.png | Bin 0 -> 78591 bytes logo/png24/400x400/white/blackbg/barebox.png | Bin 0 -> 72957 bytes logo/png24/600x600/color/barebox.png | Bin 0 -> 406788 bytes logo/png24/600x600/color/blackbg/barebox.png | Bin 0 -> 353328 bytes logo/png24/600x600/while/barebox.png | Bin 0 -> 137235 bytes logo/png24/600x600/while/blackbg/barebox.png | Bin 0 -> 130454 bytes logo/png24/800x800/color/barebox.png | Bin 0 -> 627433 bytes logo/png24/800x800/color/blackbg/barebox.png | Bin 0 -> 547772 bytes logo/png24/800x800/white/barebox.png | Bin 0 -> 210397 bytes logo/png24/800x800/white/blackbg/barebox.png | Bin 0 -> 198356 bytes logo/png24/900x900/color/barebox.png | Bin 0 -> 713120 bytes logo/png24/900x900/color/blackbg/barebox.png | Bin 0 -> 611586 bytes logo/png24/900x900/white/barebox.png | Bin 0 -> 204449 bytes logo/png24/900x900/white/blackbg/barebox.png | Bin 0 -> 190770 bytes logo/png8/100x100/color/blackbg/barebox.png | Bin 0 -> 8279 bytes logo/png8/100x100/white/blackbg/barebox.png | Bin 0 -> 6089 bytes logo/png8/200x200/color/blackbg/barebox.png | Bin 0 -> 23616 bytes logo/png8/200x200/white/blackbg/barebox.png | Bin 0 -> 14838 bytes logo/png8/400x400/color/blackbg/barebox.png | Bin 0 -> 71295 bytes logo/png8/400x400/white/blackbg/barebox.png | Bin 0 -> 38480 bytes logo/png8/600x600/color/blackbg/barebox.png | Bin 0 -> 130709 bytes logo/png8/600x600/while/blackbg/barebox.png | Bin 0 -> 68648 bytes logo/png8/800x800/color/blackbg/barebox.png | Bin 0 -> 205281 bytes logo/png8/800x800/white/blackbg/barebox.png | Bin 0 -> 104173 bytes logo/png8/900x900/color/blackbg/barebox.png | Bin 0 -> 236679 bytes logo/png8/900x900/white/blackbg/barebox.png | Bin 0 -> 106472 bytes 48 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 logo/bmp/100x100/color/blackbg/barebox.bmp create mode 100644 logo/bmp/100x100/white/blackbg/barebox.bmp create mode 100644 logo/bmp/200x200/color/blackbg/barebox.bmp create mode 100644 logo/bmp/200x200/white/blackbg/barebox.bmp create mode 100644 logo/bmp/400x400/color/blackbg/barebox.bmp create mode 100644 logo/bmp/400x400/white/blackbg/barebox.bmp create mode 100644 logo/bmp/600x600/color/blackbg/barebox.bmp create mode 100644 logo/bmp/600x600/while/blackbg/barebox.bmp create mode 100644 logo/bmp/800x800/color/blackbg/barebox.bmp create mode 100644 logo/bmp/800x800/white/blackbg/barebox.bmp create mode 100644 logo/bmp/900x900/color/blackbg/barebox.bmp create mode 100644 logo/bmp/900x900/white/blackbg/barebox.bmp create mode 100644 logo/png24/100x100/color/barebox.png create mode 100644 logo/png24/100x100/color/blackbg/barebox.png create mode 100644 logo/png24/100x100/white/barebox.png create mode 100644 logo/png24/100x100/white/blackbg/barebox.png create mode 100644 logo/png24/200x200/color/barebox.png create mode 100644 logo/png24/200x200/color/blackbg/barebox.png create mode 100644 logo/png24/200x200/white/barebox.png create mode 100644 logo/png24/200x200/white/blackbg/barebox.png create mode 100644 logo/png24/400x400/color/barebox.png create mode 100644 logo/png24/400x400/color/blackbg/barebox.png create mode 100644 logo/png24/400x400/white/barebox.png create mode 100644 logo/png24/400x400/white/blackbg/barebox.png create mode 100644 logo/png24/600x600/color/barebox.png create mode 100644 logo/png24/600x600/color/blackbg/barebox.png create mode 100644 logo/png24/600x600/while/barebox.png create mode 100644 logo/png24/600x600/while/blackbg/barebox.png create mode 100644 logo/png24/800x800/color/barebox.png create mode 100644 logo/png24/800x800/color/blackbg/barebox.png create mode 100644 logo/png24/800x800/white/barebox.png create mode 100644 logo/png24/800x800/white/blackbg/barebox.png create mode 100644 logo/png24/900x900/color/barebox.png create mode 100644 logo/png24/900x900/color/blackbg/barebox.png create mode 100644 logo/png24/900x900/white/barebox.png create mode 100644 logo/png24/900x900/white/blackbg/barebox.png create mode 100644 logo/png8/100x100/color/blackbg/barebox.png create mode 100644 logo/png8/100x100/white/blackbg/barebox.png create mode 100644 logo/png8/200x200/color/blackbg/barebox.png create mode 100644 logo/png8/200x200/white/blackbg/barebox.png create mode 100644 logo/png8/400x400/color/blackbg/barebox.png create mode 100644 logo/png8/400x400/white/blackbg/barebox.png create mode 100644 logo/png8/600x600/color/blackbg/barebox.png create mode 100644 logo/png8/600x600/while/blackbg/barebox.png create mode 100644 logo/png8/800x800/color/blackbg/barebox.png create mode 100644 logo/png8/800x800/white/blackbg/barebox.png create mode 100644 logo/png8/900x900/color/blackbg/barebox.png create mode 100644 logo/png8/900x900/white/blackbg/barebox.png
skip as too big
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/12 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 7/12 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 | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 3 deletions(-)
commands/splash.c +76 -3
@@ -9,6 +9,66 @@#include <fb.h> #include <image_renderer.h> +static u32 get_pixel (struct fb_info *info,u32 color) +{ +u32 px; +u8 t = (color >>24 ) &0xff ; +u8 r = (color >>16 ) &0xff ; +u8 g = (color >>8 ) &0xff ; +u8 b = (color >>0 ) &0xff ; + +if (info->grayscale) { + px = (r | g | b) ?0xffffffff :0x0 ; +return px; + } + + px = (t >> (8 - info->transp.length)) << info->transp.offset | + (r >> (8 - info->red.length)) << info->red.offset | + (g >> (8 - info->green.length)) << info->green.offset | + (b >> (8 - info->blue.length)) << info->blue.offset; + +return px; +} + +static void memsetw (void *s,u16 c,size_t n) +{ +size_t i; +u16 * tmp = s; + +for (i =0 ; i < n; i++) + *tmp++ = c; +} + +static void memsetl (void *s,u32 c,size_t n) +{ +size_t i; +u32 * tmp = s; + +for (i =0 ; i < n; i++) + *tmp++ = c; +} + +static void memset_pixel (struct fb_info *info,void * buf,u32 color,size_t size) +{ +u32 px; +u8 *screen = buf; + + px =get_pixel (info, color); + +switch (info->bits_per_pixel) { +case 8 : +memset (screen, (uint8_t )px, size); +break ; +case 16 : +memsetw (screen, (uint16_t )px, size); +break ; +case 32 : +case 24 : +memsetl (screen, px, size); +break ; + } +} +static int do_splash (int argc,char *argv[]) {int ret, opt, fd;
@@ -19,13 +79,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 +137,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 +170,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 <backgroung>", "backgroung color\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 2/12 bmp: rename it to splash
In reply to Jean-Christophe PLAGNIOL-VILLARDso 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 6/12 splash/bmp: switch to image_renderer
In reply to Jean-Christophe PLAGNIOL-VILLARD---
commands/Kconfig | 1 +
commands/splash.c | 10 +++----
lib/Kconfig | 1 +
lib/bmp.c | 63 +++++++++++++----------------------------
{include => lib}/bmp_layout.h | 0
5 files changed, 26 insertions(+), 49 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
@@ -43,5 +43,6 @@ config IMAGE_RENDERER config BMP bool + depends on IMAGE_RENDERER endmenu
lib/bmp.c +19 -44
83 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 10/12 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 8/12 Introduce graphic utils
In reply to Jean-Christophe PLAGNIOL-VILLARDto Factorise pixel rendering
--- commands/splash.c | 61 +--------------------------------- include/graphic_utils.h | 13 ++++++++ include/image_renderer.h | 20 ----------- lib/Makefile | 1 + lib/bmp.c | 5 +-- lib/graphic_utils.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 101 insertions(+), 82 deletions(-) create mode 100644 include/graphic_utils.h create mode 100644 lib/graphic_utils.c
commands/splash.c +1 -60
@@ -8,66 +8,7 @@#include <fcntl.h> #include <fb.h> #include <image_renderer.h> - -static u32 get_pixel (struct fb_info *info,u32 color) -{ -u32 px; -u8 t = (color >>24 ) &0xff ; -u8 r = (color >>16 ) &0xff ; -u8 g = (color >>8 ) &0xff ; -u8 b = (color >>0 ) &0xff ; - -if (info->grayscale) { - px = (r | g | b) ?0xffffffff :0x0 ; -return px; - } - - px = (t >> (8 - info->transp.length)) << info->transp.offset | - (r >> (8 - info->red.length)) << info->red.offset | - (g >> (8 - info->green.length)) << info->green.offset | - (b >> (8 - info->blue.length)) << info->blue.offset; - -return px; -} - -static void memsetw (void *s,u16 c,size_t n) -{ -size_t i; -u16 * tmp = s; - -for (i =0 ; i < n; i++) - *tmp++ = c; -} - -static void memsetl (void *s,u32 c,size_t n) -{ -size_t i; -u32 * tmp = s; - -for (i =0 ; i < n; i++) - *tmp++ = c; -} - -static void memset_pixel (struct fb_info *info,void * buf,u32 color,size_t size) -{ -u32 px; -u8 *screen = buf; - - px =get_pixel (info, color); - -switch (info->bits_per_pixel) { -case 8 : -memset (screen, (uint8_t )px, size); -break ; -case 16 : -memsetw (screen, (uint16_t )px, size); -break ; -case 32 : -case 24 : -memsetl (screen, px, size); -break ; - } -} +#include <graphic_utils.h> static int do_splash (int argc,char *argv[]) {
include/graphic_utils.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* GPL v2 +*/ + +#ifndef __GRAPHIC_UTILS_H__ +#define __GRAPHIC_UTILS_H__ + +void set_rgb_pixel (struct fb_info *info,void *adr,int r,int g,int b); +void memset_pixel (struct fb_info *info,void * buf,u32 color,size_t size); + +#endif /* __GRAPHIC_UTILS_H__ */
include/image_renderer.h +0 -20
@@ -19,26 +19,6 @@ struct image_renderer {struct list_head list; }; -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 ; - } -} -#ifdef CONFIG_IMAGE_RENDERER int image_renderer_register (struct image_renderer *ir);void image_render_unregister (struct image_renderer *ir);
lib/Makefile +1 -0
@@ -35,4 +35,5 @@ obj-$(CONFIG_BCH) += bch.o 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_IMAGE_RENDERER) += image_renderer.o
lib/bmp.c +3 -2
@@ -5,6 +5,7 @@#include <asm/byteorder.h> #include <init.h> #include <image_renderer.h> +#include <graphic_utils.h> static int bmp_renderer (struct fb_info *info,void * data,int size,void * fb,int startx,int starty,void * offscreenbuf)
@@ -57,7 +58,7 @@ static int bmp_renderer(struct fb_info *info, void* data, int size, 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 ;
@@ -79,7 +80,7 @@ static int bmp_renderer(struct fb_info *info, void* data, int size, 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 +83 -0
83 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 12/12 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 adapat to be compliant to C89 and drop the interanal ZLIB support. Coding style untouched.
--- lib/Kconfig | 19 ++ lib/Makefile | 3 +- lib/picopng.c | 810 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/picopng.h | 34 +++ lib/png_pico.c | 152 +++++++++++ 5 files changed, 1017 insertions(+), 1 deletion(-) create mode 100644 lib/picopng.c create mode 100644 lib/picopng.h create mode 100644 lib/png_pico.c
lib/Kconfig +19 -0
@@ -51,6 +51,25 @@ config PNG bool "png" select ZLIB +if PNG + +choice + prompt "PNG Lib" + +config LODEPNG + bool "lodePNG" + help + Mostly PNG support + +config PICOPNG + bool "picoPNG" + help + Support only RGBA PNG8 + +endchoice + +endif + endif endmenu
lib/Makefile +2 -1
@@ -37,4 +37,5 @@ obj-$(CONFIG_QSORT) += qsort.o obj-$(CONFIG_BMP) += bmp.o obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o graphic_utils.o obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o -obj-$(CONFIG_PNG) += png.o lodepng.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 +152 -0
152 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 11/12 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 | 12 +- lib/Makefile | 1 + lib/lodepng.c | 5928 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/lodepng.h | 1640 +++++++++++++++ lib/png_lode.c | 181 ++ 6 files changed, 7760 insertions(+), 3 deletions(-) create mode 100644 lib/lodepng.c create mode 100644 lib/lodepng.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 +10 -2
@@ -40,9 +40,17 @@ config QSORT config IMAGE_RENDERER bool + depends on VIDEO + +if IMAGE_RENDERER config BMP - bool - depends on IMAGE_RENDERER + bool "bmp" + +config PNG + bool "png" + select ZLIB + +endif endmenu
lib/Makefile +1 -0
@@ -37,3 +37,4 @@ obj-$(CONFIG_QSORT) += qsort.o obj-$(CONFIG_BMP) += bmp.o obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o graphic_utils.o obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o +obj-$(CONFIG_PNG) += png.o lodepng.o
lib/lodepng.c new file +5928 -0
2,970 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_lode.c new file +181 -0
181 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.
PATCH 9/12 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 | 4 ++ lib/graphic_utils.c | 116 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 116 insertions(+), 4 deletions(-)
include/graphic_utils.h +4 -0
@@ -7,7 +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,int r,int g,int b); +void set_rgba_pixel (struct fb_info *info,void *adr,int r,int g,int b,int a);void memset_pixel (struct fb_info *info,void * buf,u32 color,size_t size);#endif /* __GRAPHIC_UTILS_H__ */
lib/graphic_utils.c +112 -4
129 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
Hi Jean-Christophe,
$ LANG=en grep -rn Adobe . Binary file ./png8/600x600/while/blackbg/barebox.png matches Binary file ./png8/600x600/color/blackbg/barebox.png matches Binary file ./png8/400x400/white/blackbg/barebox.png matches Binary file ./png8/400x400/color/blackbg/barebox.png matches Binary file ./png8/900x900/white/blackbg/barebox.png matches Binary file ./png8/900x900/color/blackbg/barebox.png matches Binary file ./png8/100x100/white/blackbg/barebox.png matches Binary file ./png8/100x100/color/blackbg/barebox.png matches Binary file ./png8/800x800/white/blackbg/barebox.png matches Binary file ./png8/800x800/color/blackbg/barebox.png matches Binary file ./png8/200x200/white/blackbg/barebox.png matches Binary file ./png8/200x200/color/blackbg/barebox.png matches Binary file ./png24/600x600/while/blackbg/barebox.png matches Binary file ./png24/600x600/while/barebox.png matches Binary file ./png24/600x600/color/blackbg/barebox.png matches Binary file ./png24/600x600/color/barebox.png matches Binary file ./png24/400x400/white/blackbg/barebox.png matches Binary file ./png24/400x400/white/barebox.png matches Binary file ./png24/400x400/color/blackbg/barebox.png matches Binary file ./png24/400x400/color/barebox.png matches Binary file ./png24/900x900/white/blackbg/barebox.png matches Binary file ./png24/900x900/white/barebox.png matches Binary file ./png24/900x900/color/blackbg/barebox.png matches Binary file ./png24/900x900/color/barebox.png matches Binary file ./png24/100x100/white/blackbg/barebox.png matches Binary file ./png24/100x100/white/barebox.png matches Binary file ./png24/100x100/color/blackbg/barebox.png matches Binary file ./png24/100x100/color/barebox.png matches Binary file ./png24/800x800/white/blackbg/barebox.png matches Binary file ./png24/800x800/white/barebox.png matches Binary file ./png24/800x800/color/blackbg/barebox.png matches Binary file ./png24/800x800/color/barebox.png matches Binary file ./png24/200x200/white/blackbg/barebox.png matches Binary file ./png24/200x200/white/barebox.png matches Binary file ./png24/200x200/color/blackbg/barebox.png matches Binary file ./png24/200x200/color/barebox.png matches
$ strings ./png8/600x600/while/blackbg/barebox.png | grep Adobe Adobe ImageReadyq " id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.0-c060 61.134777, 2010/02/12-17:32:00 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmpMM:OriginalDocumentID="xmp.did:F77F117407206811920897BEAF1A9456" xmpMM:DocumentID="xmp.did:436D3B36EFAB11E19F07FD358A90E3D4" xmpMM:InstanceID="xmp.iid:436D3B35EFAB11E19F07FD358A90E3D4" xmp:CreatorTool="Adobe Photoshop CS4 Macintosh"> <xmpMM:DerivedFrom stRef:instanceID="xmp.iid:048011740720681195FEE0F8D2792B70" stRef:documentID="xmp.did:F77F117407206811920897BEAF1A9456"/> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="r"?>5
Barebox being an OpenSource project, is it possible to have these images created by a free tool and not including "Adobe Photoshop CS5 Macintosh" tags (proprietary software on a proprietary OS on a proprietary platform ;-) ?
thanks !
Eric
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 57 lines · Eric Bénard
Hi Jean-Christophe,
$ LANG=en grep -rn Adobe . Binary file ./png8/600x600/while/blackbg/barebox.png matches Binary file ./png8/600x600/color/blackbg/barebox.png matches Binary file ./png8/400x400/white/blackbg/barebox.png matches Binary file ./png8/400x400/color/blackbg/barebox.png matches Binary file ./png8/900x900/white/blackbg/barebox.png matches Binary file ./png8/900x900/color/blackbg/barebox.png matches Binary file ./png8/100x100/white/blackbg/barebox.png matches Binary file ./png8/100x100/color/blackbg/barebox.png matches Binary file ./png8/800x800/white/blackbg/barebox.png matches Binary file ./png8/800x800/color/blackbg/barebox.png matches Binary file ./png8/200x200/white/blackbg/barebox.png matches Binary file ./png8/200x200/color/blackbg/barebox.png matches Binary file ./png24/600x600/while/blackbg/barebox.png matches Binary file ./png24/600x600/while/barebox.png matches Binary file ./png24/600x600/color/blackbg/barebox.png matches Binary file ./png24/600x600/color/barebox.png matches Binary file ./png24/400x400/white/blackbg/barebox.png matches Binary file ./png24/400x400/white/barebox.png matches Binary file ./png24/400x400/color/blackbg/barebox.png matches Binary file ./png24/400x400/color/barebox.png matches Binary file ./png24/900x900/white/blackbg/barebox.png matches Binary file ./png24/900x900/white/barebox.png matches Binary file ./png24/900x900/color/blackbg/barebox.png matches Binary file ./png24/900x900/color/barebox.png matches Binary file ./png24/100x100/white/blackbg/barebox.png matches Binary file ./png24/100x100/white/barebox.png matches Binary file ./png24/100x100/color/blackbg/barebox.png matches Binary file ./png24/100x100/color/barebox.png matches Binary file ./png24/800x800/white/blackbg/barebox.png matches Binary file ./png24/800x800/white/barebox.png matches Binary file ./png24/800x800/color/blackbg/barebox.png matches Binary file ./png24/800x800/color/barebox.png matches Binary file ./png24/200x200/white/blackbg/barebox.png matches Binary file ./png24/200x200/white/barebox.png matches Binary file ./png24/200x200/color/blackbg/barebox.png matches Binary file ./png24/200x200/color/barebox.png matches$ strings ./png8/600x600/while/blackbg/barebox.png | grep Adobe Adobe ImageReadyq " id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.0-c060 61.134777, 2010/02/12-17:32:00 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmpMM:OriginalDocumentID="xmp.did:F77F117407206811920897BEAF1A9456" xmpMM:DocumentID="xmp.did:436D3B36EFAB11E19F07FD358A90E3D4" xmpMM:InstanceID="xmp.iid:436D3B35EFAB11E19F07FD358A90E3D4" xmp:CreatorTool="Adobe Photoshop CS4 Macintosh"> <xmpMM:DerivedFrom stRef:instanceID="xmp.iid:048011740720681195FEE0F8D2792B70" stRef:documentID="xmp.did:F77F117407206811920897BEAF1A9456"/> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="r"?>5
Quoted 4 lines
Barebox being an OpenSource project, is it possible to have these images created by a free tool and not including "Adobe Photoshop CS5 Macintosh" tags (proprietary software on a proprietary OS on a proprietary platform ;-) ?
Sorry no The logo is not OpenSource it's copyrighted
As put in the anounced e-mail
It's free to USE without modification for the Barebox Project
I'll put a COPYRIGHT NOTICE
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 12/12] png: add picoPNG lib support
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD
This 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.cwas just adapat to be compliant to C89 and drop the interanal ZLIB support. Coding style untouched.
^^^^^^^^^^^
:) the internal?
Quoted 1,075 lines
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- lib/Kconfig | 19 ++ lib/Makefile | 3 +- lib/picopng.c | 810 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/picopng.h | 34 +++ lib/png_pico.c | 152 +++++++++++ 5 files changed, 1017 insertions(+), 1 deletion(-) create mode 100644 lib/picopng.c create mode 100644 lib/picopng.h create mode 100644 lib/png_pico.clib/Kconfig +19
-0@@ -51,6 +51,25 @@ config PNG bool "png" select ZLIB +if PNG + +choice + prompt "PNG Lib" + +config LODEPNG + bool "lodePNG" + help + Mostly PNG support + +config PICOPNG + bool "picoPNG" + help + Support only RGBA PNG8 + +endchoice + +endif + endif endmenulib/Makefile +2
-1@@ -37,4 +37,5 @@ obj-$(CONFIG_QSORT) += qsort.o obj-$(CONFIG_BMP) += bmp.o obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o graphic_utils.o obj-$(CONFIG_IMAGE_RENDERER) += image_renderer.o -obj-$(CONFIG_PNG) += png.o lodepng.o +obj-$(CONFIG_LODEPNG) += png_lode.o lodepng.o +obj-$(CONFIG_PICOPNG) += png_pico.o picopng.olib/picopng.c new file +810
-0@@ -0,0 +1,810 @@ +// picoPNG version 20080503 (cleaned up and ported to c by kaitek) +// Copyright (c) 2005-2008 Lode Vandevenne +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would be +// appreciated but is not required. +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// 3. This notice may not be removed or altered from any source distribution. + +#include <common.h> +#include <malloc.h> +#include "picopng.h" + +/*************************************************************************************************/ + +typedef struct png_alloc_node { +struct png_alloc_node *prev, *next; +void *addr; +size_t size; +}png_alloc_node_t ; + +png_alloc_node_t *png_alloc_head =NULL ; +png_alloc_node_t *png_alloc_tail =NULL ; + +png_alloc_node_t *png_alloc_find_node (void *addr) +{ +png_alloc_node_t *node; +for (node = png_alloc_head; node; node = node->next) +if (node->addr == addr) +break ; +return node; +} + +void png_alloc_add_node (void *addr,size_t size) +{ +png_alloc_node_t *node; +if (png_alloc_find_node (addr)) +return ; + node =malloc (sizeof (png_alloc_node_t)); + node->addr = addr; + node->size = size; + node->prev = png_alloc_tail; + node->next =NULL ; + png_alloc_tail = node; +if (node->prev) + node->prev->next = node; +if (!png_alloc_head) + png_alloc_head = node; +} + +void png_alloc_remove_node (png_alloc_node_t *node) +{ +if (node->prev) + node->prev->next = node->next; +if (node->next) + node->next->prev = node->prev; +if (node == png_alloc_head) + png_alloc_head = node->next; +if (node == png_alloc_tail) + png_alloc_tail = node->prev; + node->prev = node->next = node->addr =NULL ; +free (node); +} + +void *png_alloc_malloc (size_t size) +{ +void *addr =malloc (size); +png_alloc_add_node (addr, size); +return addr; +} + +void *png_alloc_realloc (void *addr,size_t size) +{ +void *new_addr; +if (!addr) +return png_alloc_malloc (size); + new_addr =realloc (addr, size); +if (new_addr != addr) { +png_alloc_node_t *old_node; + old_node =png_alloc_find_node (addr); +png_alloc_remove_node (old_node); +png_alloc_add_node (new_addr, size); + } +return new_addr; +} + +void png_alloc_free (void *addr) +{ +png_alloc_node_t *node =png_alloc_find_node (addr); +if (!node) +return ; +png_alloc_remove_node (node); +free (addr); +} + +void png_alloc_free_all () +{ +while (png_alloc_tail) { +void *addr = png_alloc_tail->addr; +png_alloc_remove_node (png_alloc_tail); +free (addr); + } +} + +/*************************************************************************************************/ + +__maybe_unused void vector32_cleanup (vector32_t *p) +{ + p->size = p->allocsize =0 ; +if (p->data) +png_alloc_free (p->data); + p->data =NULL ; +} + +uint32_t vector32_resize (vector32_t *p,size_t size) +{// returns 1 if success, 0 if failure ==> nothing done +if (size *sizeof (uint32_t ) > p->allocsize) { +size_t newsize = size *sizeof (uint32_t ) *2 ; +void *data =png_alloc_realloc (p->data, newsize); +if (data) { + p->allocsize = newsize; + p->data = (uint32_t *) data; + p->size = size; + }else +return 0 ; + }else + p->size = size; +return 1 ; +} + +uint32_t vector32_resizev (vector32_t *p,size_t size,uint32_t value) +{// resize and give all new elements the value +size_t oldsize = p->size, i; +if (!vector32_resize (p, size)) +return 0 ; +for (i = oldsize; i < size; i++) + p->data[i] = value; +return 1 ; +} + +void vector32_init (vector32_t *p) +{ + p->data =NULL ; + p->size = p->allocsize =0 ; +} + +vector32_t *vector32_new (size_t size,uint32_t value) +{ +vector32_t *p =png_alloc_malloc (sizeof (vector32_t)); +vector32_init (p); +if (size && !vector32_resizev (p, size, value)) +return NULL ; +return p; +} + +/*************************************************************************************************/ + +__maybe_unused void vector8_cleanup (vector8_t *p) +{ + p->size = p->allocsize =0 ; +if (p->data) +png_alloc_free (p->data); + p->data =NULL ; +} + +uint32_t vector8_resize (vector8_t *p,size_t size) +{// returns 1 if success, 0 if failure ==> nothing done +// xxx: the use of sizeof uint32_t here seems like a bug (this descends from the lodepng vector +// compatibility functions which do the same). without this there is corruption in certain cases, +// so this was probably done to cover up allocation bug(s) in the original picopng code! +if (size *sizeof (uint32_t ) > p->allocsize) { +size_t newsize = size *sizeof (uint32_t ) *2 ; +void *data =png_alloc_realloc (p->data, newsize); +if (data) { + p->allocsize = newsize; + p->data = (uint8_t *) data; + p->size = size; + }else +return 0 ;// error: not enough memory + }else + p->size = size; +return 1 ; +} + +uint32_t vector8_resizev (vector8_t *p,size_t size,uint8_t value) +{// resize and give all new elements the value +size_t oldsize = p->size, i; +if (!vector8_resize (p, size)) +return 0 ; +for (i = oldsize; i < size; i++) + p->data[i] = value; +return 1 ; +} + +void vector8_init (vector8_t *p) +{ + p->data =NULL ; + p->size = p->allocsize =0 ; +} + +vector8_t *vector8_new (size_t size,uint8_t value) +{ +vector8_t *p =png_alloc_malloc (sizeof (vector8_t)); +vector8_init (p); +if (size && !vector8_resizev (p, size, value)) +return NULL ; +return p; +} + +vector8_t *vector8_copy (vector8_t *p) +{ +vector8_t *q =vector8_new (p->size,0 ); +uint32_t n; +for (n =0 ; n < q->size; n++) + q->data[n] = p->data[n]; +return q; +} + +/*************************************************************************************************/ +int Zlib_decompress (vector8_t *out,const vector8_t *in)// returns error value +{ +return picopng_zlib_decompress (out->data, out->size, in->data, in->size); +} + +/*************************************************************************************************/ + +#define PNG_SIGNATURE 0x0a1a0a0d474e5089ull + +#define CHUNK_IHDR 0x52444849 +#define CHUNK_IDAT 0x54414449 +#define CHUNK_IEND 0x444e4549 +#define CHUNK_PLTE 0x45544c50 +#define CHUNK_tRNS 0x534e5274 + +int PNG_error; + +uint32_t PNG_readBitFromReversedStream (size_t *bitp,const uint8_t *bits) +{ +uint32_t result = (bits[*bitp >>3 ] >> (7 - (*bitp &0x7 ))) &1 ; + (*bitp)++; +return result; +} + +uint32_t PNG_readBitsFromReversedStream (size_t *bitp,const uint8_t *bits,uint32_t nbits) +{ +uint32_t i, result =0 ; +for (i = nbits -1 ; i < nbits; i--) + result += ((PNG_readBitFromReversedStream (bitp, bits)) << i); +return result; +} + +void PNG_setBitOfReversedStream (size_t *bitp,uint8_t *bits,uint32_t bit) +{ + bits[*bitp >>3 ] |= (bit << (7 - (*bitp &0x7 ))); + (*bitp)++; +} + +uint32_t PNG_read32bitInt (const uint8_t *buffer) +{ +return (buffer[0 ] <<24 ) | (buffer[1 ] <<16 ) | (buffer[2 ] <<8 ) | buffer[3 ]; +} + +int PNG_checkColorValidity (uint32_t colorType,uint32_t bd)// return type is a LodePNG error code +{ +if ((colorType ==2 || colorType ==4 || colorType ==6 )) { +if (!(bd ==8 || bd ==16 )) +return 37 ; +else +return 0 ; + }else if (colorType ==0 ) { +if (!(bd ==1 || bd ==2 || bd ==4 || bd ==8 || bd ==16 )) +return 37 ; +else +return 0 ; + }else if (colorType ==3 ) { +if (!(bd ==1 || bd ==2 || bd ==4 || bd ==8 )) +return 37 ; +else +return 0 ; + }else +return 31 ;// nonexistent color type +} + +uint32_t PNG_getBpp (const PNG_info_t *info) +{ +uint32_t bitDepth, colorType; + bitDepth = info->bitDepth; + colorType = info->colorType; +if (colorType ==2 ) +return (3 * bitDepth); +else if (colorType >=4 ) +return (colorType -2 ) * bitDepth; +else +return bitDepth; +} + +void PNG_readPngHeader (PNG_info_t *info,const uint8_t *in,size_t inlength) +{// read the information from the header and store it in the Info +if (inlength <29 ) { + PNG_error =27 ;// error: the data length is smaller than the length of the header +return ; + } +if (*(uint64_t *) in !=PNG_SIGNATURE ) { + PNG_error =28 ;// no PNG signature +return ; + } +if (*(uint32_t *) &in[12 ] !=CHUNK_IHDR ) { + PNG_error =29 ;// error: it doesn't start with a IHDR chunk! +return ; + } + info->width =PNG_read32bitInt (&in[16 ]); + info->height =PNG_read32bitInt (&in[20 ]); + info->bitDepth = in[24 ]; + info->colorType = in[25 ]; + info->compressionMethod = in[26 ]; +if (in[26 ] !=0 ) { + PNG_error =32 ;// error: only compression method 0 is allowed in the specification +return ; + } + info->filterMethod = in[27 ]; +if (in[27 ] !=0 ) { + PNG_error =33 ;// error: only filter method 0 is allowed in the specification +return ; + } + info->interlaceMethod = in[28 ]; +if (in[28 ] >1 ) { + PNG_error =34 ;// error: only interlace methods 0 and 1 exist in the specification +return ; + } + PNG_error =PNG_checkColorValidity (info->colorType, info->bitDepth); +} + +int PNG_paethPredictor (int a,int b,int c)// Paeth predicter, used by PNG filter type 4 +{ +int p, pa, pb, pc; + p = a + b - c; + pa = p > a ? (p - a) : (a - p); + pb = p > b ? (p - b) : (b - p); + pc = p > c ? (p - c) : (c - p); +return (pa <= pb && pa <= pc) ? a : (pb <= pc ? b : c); +} + +void PNG_unFilterScanline (uint8_t *recon,const uint8_t *scanline,const uint8_t *precon, +size_t bytewidth,uint32_t filterType,size_t length) +{ +size_t i; +switch (filterType) { +case 0 : +for (i =0 ; i < length; i++) + recon[i] = scanline[i]; +break ; +case 1 : +for (i =0 ; i < bytewidth; i++) + recon[i] = scanline[i]; +for (i = bytewidth; i < length; i++) + recon[i] = scanline[i] + recon[i - bytewidth]; +break ; +case 2 : +if (precon) +for (i =0 ; i < length; i++) + recon[i] = scanline[i] + precon[i]; +else +for (i =0 ; i < length; i++) + recon[i] = scanline[i]; +break ; +case 3 : +if (precon) { +for (i =0 ; i < bytewidth; i++) + recon[i] = scanline[i] + precon[i] /2 ; +for (i = bytewidth; i < length; i++) + recon[i] = scanline[i] + ((recon[i - bytewidth] + precon[i]) /2 ); + }else { +for (i =0 ; i < bytewidth; i++) + recon[i] = scanline[i]; +for (i = bytewidth; i < length; i++) + recon[i] = scanline[i] + recon[i - bytewidth] /2 ; + } +break ; +case 4 : +if (precon) { +for (i =0 ; i < bytewidth; i++) + recon[i] = (uint8_t ) (scanline[i] +PNG_paethPredictor (0 , precon[i],0 )); +for (i = bytewidth; i < length; i++) + recon[i] = (uint8_t ) (scanline[i] +PNG_paethPredictor (recon[i - bytewidth], + precon[i], precon[i - bytewidth])); + }else { +for (i =0 ; i < bytewidth; i++) + recon[i] = scanline[i]; +for (i = bytewidth; i < length; i++) + recon[i] = (uint8_t ) (scanline[i] +PNG_paethPredictor (recon[i - bytewidth],0 ,0 )); + } +break ; +default : + PNG_error =36 ;// error: nonexistent filter type given +return ; + } +} + +void PNG_adam7Pass (uint8_t *out,uint8_t *linen,uint8_t *lineo,const uint8_t *in,uint32_t w, +size_t passleft,size_t passtop,size_t spacex,size_t spacey,size_t passw,size_t passh, +uint32_t bpp) +{ +size_t bytewidth, linelength; +uint32_t y; +uint8_t *temp; +// filter and reposition the pixels into the output when the image is Adam7 interlaced. This +// function can only do it after the full image is already decoded. The out buffer must have +// the correct allocated memory size already. +if (passw ==0 ) +return ; + bytewidth = (bpp +7 ) /8 ; + linelength =1 + ((bpp * passw +7 ) /8 ); +for (y =0 ; y < passh; y++) { +size_t i, b; +uint8_t filterType = in[y * linelength], *prevline = (y ==0 ) ?0 : lineo; +PNG_unFilterScanline (linen, &in[y * linelength +1 ], prevline, bytewidth, filterType, + (w * bpp +7 ) /8 ); +if (PNG_error) +return ; +if (bpp >=8 ) +for (i =0 ; i < passw; i++) +for (b =0 ; b < bytewidth; b++)// b = current byte of this pixel + out[bytewidth * w * (passtop + spacey * y) + bytewidth * + (passleft + spacex * i) + b] = linen[bytewidth * i + b]; +else +for (i =0 ; i < passw; i++) { +size_t obp, bp; + obp = bpp * w * (passtop + spacey * y) + bpp * (passleft + spacex * i); + bp = i * bpp; +for (b =0 ; b < bpp; b++) +PNG_setBitOfReversedStream (&obp, out,PNG_readBitFromReversedStream (&bp, linen)); + } + temp = linen; + linen = lineo; + lineo = temp;// swap the two buffer pointers "line old" and "line new" + } +} + +int PNG_convert (const PNG_info_t *info,vector8_t *out,const uint8_t *in) +{// converts from any color type to 32-bit. return value = LodePNG error code +size_t i, c; +uint32_t bitDepth, colorType; +size_t numpixels, bp; +uint8_t *out_data; + + bitDepth = info->bitDepth; + colorType = info->colorType; + numpixels = info->width * info->height; + bp =0 ; +vector8_resize (out, numpixels *4 ); + out_data = out->size ? out->data :0 ; +if (bitDepth ==8 && colorType ==0 )// greyscale +for (i =0 ; i < numpixels; i++) { + out_data[4 * i +0 ] = out_data[4 * i +1 ] = out_data[4 * i +2 ] = in[i]; + out_data[4 * i +3 ] = (info->key_defined && (in[i] == info->key_r)) ?0 :255 ; + } +else if (bitDepth ==8 && colorType ==2 )// RGB color +for (i =0 ; i < numpixels; i++) { +for (c =0 ; c <3 ; c++) + out_data[4 * i + c] = in[3 * i + c]; + out_data[4 * i +3 ] = (info->key_defined && (in[3 * i +0 ] == info->key_r) && + (in[3 * i +1 ] == info->key_g) && (in[3 * i +2 ] == info->key_b)) ?0 :255 ; + } +else if (bitDepth ==8 && colorType ==3 )// indexed color (palette) +for (i =0 ; i < numpixels; i++) { +if (4U * in[i] >= info->palette->size) +return 46 ; +for (c =0 ; c <4 ; c++)// get rgb colors from the palette + out_data[4 * i + c] = info->palette->data[4 * in[i] + c]; + } +else if (bitDepth ==8 && colorType ==4 )// greyscale with alpha +for (i =0 ; i < numpixels; i++) { + out_data[4 * i +0 ] = out_data[4 * i +1 ] = out_data[4 * i +2 ] = in[2 * i +0 ]; + out_data[4 * i +3 ] = in[2 * i +1 ]; + } +else if (bitDepth ==8 && colorType ==6 ) +for (i =0 ; i < numpixels; i++) +for (c =0 ; c <4 ; c++) + out_data[4 * i + c] = in[4 * i + c];// RGB with alpha +else if (bitDepth ==16 && colorType ==0 )// greyscale +for (i =0 ; i < numpixels; i++) { + out_data[4 * i +0 ] = out_data[4 * i +1 ] = out_data[4 * i +2 ] = in[2 * i]; + out_data[4 * i +3 ] = (info->key_defined && (256U * in[i] + in[i +1 ] == info->key_r)) + ?0 :255 ; + } +else if (bitDepth ==16 && colorType ==2 )// RGB color +for (i =0 ; i < numpixels; i++) { +for (c =0 ; c <3 ; c++) + out_data[4 * i + c] = in[6 * i +2 * c]; + out_data[4 * i +3 ] = (info->key_defined && + (256U * in[6 * i +0 ] + in[6 * i +1 ] == info->key_r) && + (256U * in[6 * i +2 ] + in[6 * i +3 ] == info->key_g) && + (256U * in[6 * i +4 ] + in[6 * i +5 ] == info->key_b)) ?0 :255 ; + } +else if (bitDepth ==16 && colorType ==4 )// greyscale with alpha +for (i =0 ; i < numpixels; i++) { + out_data[4 * i +0 ] = out_data[4 * i +1 ] = out_data[4 * i +2 ] = in[4 * i];// msb + out_data[4 * i +3 ] = in[4 * i +2 ]; + } +else if (bitDepth ==16 && colorType ==6 ) +for (i =0 ; i < numpixels; i++) +for (c =0 ; c <4 ; c++) + out_data[4 * i + c] = in[8 * i +2 * c];// RGB with alpha +else if (bitDepth <8 && colorType ==0 )// greyscale +for (i =0 ; i < numpixels; i++) { +uint32_t value = (PNG_readBitsFromReversedStream (&bp, in, bitDepth) *255 ) / + ((1 << bitDepth) -1 );// scale value from 0 to 255 + out_data[4 * i +0 ] = out_data[4 * i +1 ] = out_data[4 * i +2 ] = (uint8_t ) value; + out_data[4 * i +3 ] = (info->key_defined && value && + (((1U << bitDepth) -1U ) == info->key_r) && ((1U << bitDepth) -1U )) ?0 :255 ; + } +else if (bitDepth <8 && colorType ==3 )// palette +for (i =0 ; i < numpixels; i++) { +uint32_t value =PNG_readBitsFromReversedStream (&bp, in, bitDepth); +if (4 * value >= info->palette->size) +return 47 ; +for (c =0 ; c <4 ; c++)// get rgb colors from the palette + out_data[4 * i + c] = info->palette->data[4 * value + c]; + } +return 0 ; +} + +PNG_info_t *PNG_info_new (void ) +{ +PNG_info_t *info =png_alloc_malloc (sizeof (PNG_info_t)); +uint32_t i; +for (i =0 ; i <sizeof (PNG_info_t); i++) + ((uint8_t *) info)[i] =0 ; + info->palette =vector8_new (0 ,0 ); + info->image =vector8_new (0 ,0 ); +return info; +} + +PNG_info_t *PNG_decode (const uint8_t *in,uint32_t size) +{ +PNG_info_t *info; +size_t pos; +vector8_t *idat; +bool IEND , known_type; +uint32_t bpp; +vector8_t *scanlines;// now the out buffer will be filled +size_t bytewidth, outlength; +uint8_t *out_data; + + PNG_error =0 ; + +if (size ==0 || in ==0 ) { + PNG_error =48 ;// the given data is empty +return NULL ; + } + info =PNG_info_new (); +PNG_readPngHeader (info, in, size); +if (PNG_error) +return NULL ; + pos =33 ;// first byte of the first chunk after the header + idat =NULL ;// the data from idat chunks +IEND = false; + known_type = true; + info->key_defined = false; +// loop through the chunks, ignoring unknown chunks and stopping at IEND chunk. IDAT data is +// put at the start of the in buffer +while (!IEND ) { +size_t i, j; +size_t chunkLength; +uint32_t chunkType; + +if (pos +8 >= size) { + PNG_error =30 ;// error: size of the in buffer too small to contain next chunk +return NULL ; + } + chunkLength =PNG_read32bitInt (&in[pos]); + pos +=4 ; +if (chunkLength >0x7fffffff ) { + PNG_error =63 ; +return NULL ; + } +if (pos + chunkLength >= size) { + PNG_error =35 ;// error: size of the in buffer too small to contain next chunk +return NULL ; + } + chunkType = *(uint32_t *) &in[pos]; +if (chunkType ==CHUNK_IDAT ) {// IDAT: compressed image data chunk +size_t offset =0 ; +if (idat) { + offset = idat->size; +vector8_resize (idat, offset + chunkLength); + }else + idat =vector8_new (chunkLength,0 ); +for (i =0 ; i < chunkLength; i++) + idat->data[offset + i] = in[pos +4 + i]; + pos += (4 + chunkLength); + }else if (chunkType ==CHUNK_IEND ) {// IEND + pos +=4 ; +IEND = true; + }else if (chunkType ==CHUNK_PLTE ) {// PLTE: palette chunk + pos +=4 ;// go after the 4 letters +vector8_resize (info->palette,4 * (chunkLength /3 )); +if (info->palette->size > (4 *256 )) { + PNG_error =38 ;// error: palette too big +return NULL ; + } +for (i =0 ; i < info->palette->size; i +=4 ) { +for (j =0 ; j <3 ; j++) + info->palette->data[i + j] = in[pos++];// RGB + info->palette->data[i +3 ] =255 ;// alpha + } + }else if (chunkType == CHUNK_tRNS) {// tRNS: palette transparency chunk + pos +=4 ;// go after the 4 letters +if (info->colorType ==3 ) { +if (4 * chunkLength > info->palette->size) { + PNG_error =39 ;// error: more alpha values given than there are palette entries +return NULL ; + } +for (i =0 ; i < chunkLength; i++) + info->palette->data[4 * i +3 ] = in[pos++]; + }else if (info->colorType ==0 ) { +if (chunkLength !=2 ) { + PNG_error =40 ;// error: this chunk must be 2 bytes for greyscale image +return NULL ; + } + info->key_defined = true; + info->key_r = info->key_g = info->key_b =256 * in[pos] + in[pos +1 ]; + pos +=2 ; + }else if (info->colorType ==2 ) { +if (chunkLength !=6 ) { + PNG_error =41 ;// error: this chunk must be 6 bytes for RGB image +return NULL ; + } + info->key_defined = true; + info->key_r =256 * in[pos] + in[pos +1 ]; + pos +=2 ; + info->key_g =256 * in[pos] + in[pos +1 ]; + pos +=2 ; + info->key_b =256 * in[pos] + in[pos +1 ]; + pos +=2 ; + }else { + PNG_error =42 ;// error: tRNS chunk not allowed for other color models +return NULL ; + } + }else {// it's not an implemented chunk type, so ignore it: skip over the data +if (!(in[pos +0 ] &32 )) { +// error: unknown critical chunk (5th bit of first byte of chunk type is 0) + PNG_error =69 ; +return NULL ; + } + pos += (chunkLength +4 );// skip 4 letters and uninterpreted data of unimplemented chunk + known_type = false; + } + pos +=4 ;// step over CRC (which is ignored) + } + bpp =PNG_getBpp (info); + scanlines =vector8_new (((info->width * (info->height * bpp +7 )) /8 ) + info->height,0 ); + PNG_error =Zlib_decompress (scanlines, idat); +if (PNG_error) +return NULL ;// stop if the zlib decompressor returned an error + bytewidth = (bpp +7 ) /8 ; + outlength = (info->height * info->width * bpp +7 ) /8 ; +vector8_resize (info->image, outlength);// time to fill the out buffer + out_data = outlength ? info->image->data :0 ; +if (info->interlaceMethod ==0 ) {// no interlace, just filter +size_t y, obp, bp; +size_t linestart, linelength; + linestart =0 ; +// length in bytes of a scanline, excluding the filtertype byte + linelength = (info->width * bpp +7 ) /8 ; +if (bpp >=8 )// byte per byte +for (y =0 ; y < info->height; y++) { +uint32_t filterType = scanlines->data[linestart]; +const uint8_t *prevline; + prevline = (y ==0 ) ?0 : &out_data[(y -1 ) * info->width * bytewidth]; +PNG_unFilterScanline (&out_data[linestart - y], &scanlines->data[linestart +1 ], + prevline, bytewidth, filterType, linelength); +if (PNG_error) +return NULL ; + linestart += (1 + linelength);// go to start of next scanline + }else {// less than 8 bits per pixel, so fill it up bit per bit +vector8_t *templine;// only used if bpp < 8 + templine =vector8_new ((info->width * bpp +7 ) >>3 ,0 ); +for (y =0 , obp =0 ; y < info->height; y++) { +uint32_t filterType = scanlines->data[linestart]; +const uint8_t *prevline; + prevline = (y ==0 ) ?0 : &out_data[(y -1 ) * info->width * bytewidth]; +PNG_unFilterScanline (templine->data, &scanlines->data[linestart +1 ], prevline, + bytewidth, filterType, linelength); +if (PNG_error) +return NULL ; +for (bp =0 ; bp < info->width * bpp;) +PNG_setBitOfReversedStream (&obp, out_data,PNG_readBitFromReversedStream (&bp, + templine->data)); + linestart += (1 + linelength);// go to start of next scanline + } + } + }else {// interlaceMethod is 1 (Adam7) +int i; +vector8_t *scanlineo, *scanlinen;// "old" and "new" scanline +size_t passw[7 ] = { + (info->width +7 ) /8 , (info->width +3 ) /8 , (info->width +3 ) /4 , + (info->width +1 ) /4 , (info->width +1 ) /2 , (info->width +0 ) /2 , + (info->width +0 ) /1 + }; +size_t passh[7 ] = { + (info->height +7 ) /8 , (info->height +7 ) /8 , (info->height +3 ) /8 , + (info->height +3 ) /4 , (info->height +1 ) /4 , (info->height +1 ) /2 , + (info->height +0 ) /2 + }; +size_t passstart[7 ] = {0 }; +size_t pattern[28 ] = {0 ,4 ,0 ,2 ,0 ,1 ,0 ,0 ,0 ,4 ,0 ,2 ,0 ,1 ,8 ,8 ,4 ,4 ,2 ,2 ,1 ,8 ,8 , +8 ,4 ,4 ,2 ,2 };// values for the adam7 passes +for (i =0 ; i <6 ; i++) + passstart[i +1 ] = passstart[i] + passh[i] * ((passw[i] ?1 :0 ) + (passw[i] * bpp +7 ) /8 ); + scanlineo =vector8_new ((info->width * bpp +7 ) /8 ,0 ); + scanlinen =vector8_new ((info->width * bpp +7 ) /8 ,0 ); +for (i =0 ; i <7 ; i++) +PNG_adam7Pass (out_data, scanlinen->data, scanlineo->data, &scanlines->data[passstart[i]], + info->width, pattern[i], pattern[i +7 ], pattern[i +14 ], pattern[i +21 ], + passw[i], passh[i], bpp); + } +if (info->colorType !=6 || info->bitDepth !=8 ) {// conversion needed +vector8_t *copy =vector8_copy (info->image);// xxx: is this copy necessary? + PNG_error =PNG_convert (info, info->image, copy->data); + } +return info; +} + +/*************************************************************************************************/ + +#ifdef TEST + +#include <stdio.h> +#include <sys/stat.h> + +int main (int argc,char **argv) +{ +char *fname = (argc >1 ) ? argv[1 ] :"test.png" ; +PNG_info_t *info; +struct stat statbuf; +uint32_t insize, outsize; +FILE *infp, *outfp; +uint8_t *inbuf; +uint32_t n; + +if (stat (fname, &statbuf) !=0 ) { +perror ("stat" ); +return 1 ; + }else if (!statbuf.st_size) { +printf ("file empty\n" ); +return 1 ; + } + insize = (uint32_t ) statbuf.st_size; + inbuf =malloc (insize); + infp =fopen (fname,"rb" ); +if (!infp) { +perror ("fopen" ); +return 1 ; + }else if (fread (inbuf,1 , insize, infp) != insize) { +perror ("fread" ); +return 1 ; + } +fclose (infp); + +printf ("input file: %s (size: %d)\n" , fname, insize); + + info =PNG_decode (inbuf, insize); +free (inbuf); +printf ("PNG_error: %d\n" , PNG_error); +if (PNG_error !=0 ) +return 1 ; + +printf ("width: %d, height: %d\nfirst 16 bytes: " , info->width, info->height); +for (n =0 ; n <16 ; n++) +printf ("%02x " , info->image->data[n]); +printf ("\n" ); + + outsize = info->width * info->height *4 ; +printf ("image size: %d\n" , outsize); +if (outsize != info->image->size) { +printf ("error: image size doesn't match dimensions\n" ); +return 1 ; + } + outfp =fopen ("out.bin" ,"wb" ); +if (!outfp) { +perror ("fopen" ); +return 1 ; + }else if (fwrite (info->image->data,1 , outsize, outfp) != outsize) { +perror ("fwrite" ); +return 1 ; + } +fclose (outfp); + +#ifdef ALLOC_DEBUG +png_alloc_node_t *node; +for (node = png_alloc_head, n =1 ; node; node = node->next, n++) +printf ("node %d (%p) addr = %p, size = %ld\n" , n, node, node->addr, node->size); +#endif +png_alloc_free_all ();// also frees info and image data from PNG_decode + +return 0 ; +} + +#endif 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 +152
-1@@ -0,0 +1,152 @@ +#include <common.h> +#include <errno.h> +#include <malloc.h> +#include <fb.h> +#include <asm/byteorder.h> +#include <init.h> +#include <image_renderer.h> +#include <graphic_utils.h> +#include <linux/zlib.h> + +#include "picopng.h" + +static z_stream stream; +static int initialized; + +unsigned picopng_zlib_decompress (unsigned char * out,size_t outsize, +const unsigned char * in,size_t insize) +{ +int err; + + stream.next_in = in; + stream.avail_in = insize; + + stream.next_out = out; + stream.avail_out = outsize; + + err =zlib_inflateReset (&stream); +if (err !=Z_OK ) { +printk ("zlib_inflateReset error %d\n" , err); +zlib_inflateEnd (&stream); +zlib_inflateInit (&stream); + } + + err =zlib_inflate (&stream,Z_FINISH ); +if (err !=Z_STREAM_END ) + goto err; +return 0 ; + +err: +printk ("Error %d while decompressing!\n" , err); +printk ("%p(%d)->%p(%d)\n" , in, insize, out, outsize); +return -EIO ; +} + +static int png_uncompress_init (void ) +{ + stream.workspace =malloc (zlib_inflate_workspacesize ()); +if ( !stream.workspace ) { + initialized =0 ; +return -ENOMEM ; + } + stream.next_in =NULL ; + stream.avail_in =0 ; +zlib_inflateInit (&stream); +return 0 ; +} + +static void png_uncompress_exit (void ) +{ +zlib_inflateEnd (&stream); +vfree (stream.workspace); +} + +#define DEBUG +#ifdef DEBUG +static void png_info_display (PNG_info_t *info) +{ +pr_info ("width = %d\n" , info->width); +pr_info ("height = %d\n" , info->height); +} +#else +static void png_info_display (PNG_info_t *info) +{ +} +#endif + +static int png_renderer (struct fb_info *info,void * inbuf,int insize,void * fb, +int startx,int starty,int xres,int yres,void * offscreenbuf) +{ +int width, height; +int ret; +unsigned sw, sh; +PNG_info_t *png_info; +void *buf; +int xres, yres; + + xres = info->xres; + yres = info->yres; + + ret =png_uncompress_init (); +if (ret) +return ret; + +/* rgba */ + png_info =PNG_decode (inbuf, insize); + +if (PNG_error) { +printf ("error %u:\n" , PNG_error); + ret = -EINVAL ; + goto err; + } + + sw = png_info->width; + sh = png_info->height; + +png_info_display (png_info); + +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 ((int )sw, xres - startx); + height =min ((int )sh, yres - starty); + + buf = offscreenbuf ? offscreenbuf : fb; + +rgba_blend (info, png_info->image->data, buf, height, width, startx, starty, true); + +if (offscreenbuf) { +int fbsize; + + fbsize = xres * yres * (info->bits_per_pixel >>3 ); +memcpy (fb, offscreenbuf, fbsize); + } + + ret = sh; + +err: +png_uncompress_exit (); +png_alloc_free_all (); + +return ret; +} + +static struct image_renderer png = { + .type = filetype_png, + .renderer = png_renderer, +}; + +static int png_init (void ) +{ +return image_renderer_register (&png); +} +fs_initcall (png_init); --1.7.10.4
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Eric Bénard
Barebox being an OpenSource project, is it possible to have these images created by a free tool and not including "Adobe Photoshop CS5 Macintosh" tags (proprietary software on a proprietary OS on a proprietary platform ;-) ?
Sorry no The logo is not OpenSource it's copyrighted
so that's another problem.
Eric
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 10 lines · Eric Bénard
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Eric Bénard
Barebox being an OpenSource project, is it possible to have these images created by a free tool and not including "Adobe Photoshop CS5 Macintosh" tags (proprietary software on a proprietary OS on a proprietary platform ;-) ?
Sorry no The logo is not OpenSource it's copyrighted
so that's another problem.
it's not It's standard the Logo are always copyrigthed for protection and legal issue.
Codeboot have the same and other project too
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 7 lines · Eric Bénard
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Eric Bénard
Barebox being an OpenSource project, is it possible to have these images created by a free tool and not including "Adobe Photoshop CS5 Macintosh" tags (proprietary software on a proprietary OS on a proprietary platform ;-) ?
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Sorry no The logo is not OpenSource it's copyrighted
so that's another problem.
it's not It's standard the Logo are always copyrigthed for protection and legal issue.
check in Linux in drivers/video/logo/
I don't see any restriction but I may not have looked at the right place.
Eric
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 13 lines · Eric Bénard
Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 9 lines · Eric Bénard
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Eric Bénard
Barebox being an OpenSource project, is it possible to have these images created by a free tool and not including "Adobe Photoshop CS5 Macintosh" tags (proprietary software on a proprietary OS on a proprietary platform ;-) ?
Sorry no The logo is not OpenSource it's copyrighted
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
so that's another problem.
it's not It's standard the Logo are always copyrigthed for protection and legal issue.
check in Linux in
drivers/video/logo/
I don't see any restriction but I may not have looked at the right place.
Sorry the copyright are present the blackfin logo is a company logo Copyrighted SH, m32r too. This deos not mean you are not free to use this just mean they are protected.
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines · Eric Bénard
check in Linux in
drivers/video/logo/
I don't see any restriction but I may not have looked at the right place.Sorry the copyright are present the blackfin logo is a company logo Copyrighted SH, m32r too. This deos not mean you are not free to use this just mean they are protected.
where do you see these copyrights in Linux's source tree ?
Eric
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 11 lines · Eric Bénard
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines · Eric Bénard
check in Linux in
drivers/video/logo/
I don't see any restriction but I may not have looked at the right place.Sorry the copyright are present the blackfin logo is a company logo Copyrighted SH, m32r too. This deos not mean you are not free to use this just mean they are protected.
where do you see these copyrights in Linux's source tree ?
they are on the web ase the logo have a trademark
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 01/12] add barebox logo
In reply to Jean-Christophe PLAGNIOL-VILLARDHi,
Quoted 1 line · Jean-Christophe PLAGNIOL-VILLARD
skip as too big
This adds 18MB of binary logos to the tree, which is larger than the complete current tree. Is this really necessary?
Perhaps we could build the required files on demand from an SVG or something?
Regards,
Jan
Signature · 10 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 04/12] introduce image_renderer framework
In reply to Jean-Christophe PLAGNIOL-VILLARDHi!
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
lib/Kconfig +0
-0@@ -38,6 +38,9 @@ config BITREV config QSORT
lib/Kconfig config BITREV
Quoted 10 lines
lib/Kconfig +4
-0bool +config IMAGE_RENDERER + bool + config BMP bool + enum filetype type = file_detect_type(buf);
You're using functions from common/filetype.c but you do not declare the dependency on FILETYPE in Kconfig.
Regards,
Jan
Signature · 10 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 01/12] add barebox logo
In reply to Jan LübbeQuoted 8 lines · Jan Lübbe
Hi,
Quoted 1 line · Jean-Christophe PLAGNIOL-VILLARD
skip as too big
This adds 18MB of binary logos to the tree, which is larger than the complete current tree. Is this really necessary?
I put the bmp that's why if we drop it we have just 7MiB
and compare tot he linux tree we have a small tree
Quoted 3 lines
Perhaps we could build the required files on demand from an SVG or something?
no sorry no svg availlable
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 7 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 6 lines · Eric Bénard
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines · Eric Bénard
check in Linux in
drivers/video/logo/
I don't see any restriction but I may not have looked at the right place.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Sorry the copyright are present the blackfin logo is a company logo Copyrighted SH, m32r too. This deos not mean you are not free to use this just mean they are protected.
where do you see these copyrights in Linux's source tree ?
they are on the web ase the logo have a trademark
you see that as you want ... in that case why do you need to put a copyright & a readme concerning your logo ?
I don't care of the logo (I won't use this one in my projects) but at least I would prefer the logo to not carry proprietary tags inside its binary.
Eric
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 01/12] add barebox logo
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Jan Lübbe
Hi,
On Thu, 2012-09-06 at 08:04 +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
skip as too big
This adds 18MB of binary logos to the tree, which is larger than the complete current tree. Is this really necessary?
I put the bmp that's why if we drop it we have just 7MiB
and compare tot he linux tree we have a small tree
barebox is not Linux and with such arguments you will always find a good reason to include whatever you want in the project.
Eric
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH 01/12] add barebox logo
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 14 lines · Jean-Christophe PLAGNIOL-VILLARD
in logo/ you will found the barebox logo with color or white in:
- bmp (black background)
- png24 (transparent or black background)
- png8 (black background)for the following size
- 100x100
- 200x200
- 400x400
- 600x600
- 800x800
- 900x900
Quoted 2 lines
The logo are origanize in a way to be able to include them in the envfs by just point as it.
No. It's ok to have a small logo in the tree, but I won't commit a bunch of big binaries to the tree.
Most people probably want to use their own logo for a product anyway. I'm fine with uploading the logos to some website and wget them automatically when necessary.
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
Sascha Hauer
maintainerThe discussion in this thread makes it clear that there are two problems with this logo, one technical and one political.
The technical problem:
From a technical pov it makes no sense to put big image binaries into the repository when a small svg image would be sufficient to generate all other images.
The political problem:
For an open source project a closed image is a no go. We (and by we I mean we as the community, not we as Pengutronix) must for example be able to:
- generate versions with different colors, sizes, dimensions
- generate a logo without text
- modify the image and to redistribute without limitations
- add a journal to the logo and use it for bwn.org (barebox weekly news) ;)
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
Quoted 11 lines · Sascha Hauer
The discussion in this thread makes it clear that there are two problems with this logo, one technical and one political.
The technical problem:
From a technical pov it makes no sense to put big image binaries into the repository when a small svg image would be sufficient to generate all other images.
The political problem:
Quoted 8 lines
For an open source project a closed image is a no go. We (and by we I mean we as the community, not we as Pengutronix) must for example be able to:
- generate versions with different colors, sizes, dimensions
- generate a logo without text
- modify the image and to redistribute without limitations
- add a journal to the logo and use it for bwn.org (barebox weekly news) ;)
As on Linux, Meego , Mozilla, Coreboot and others Logo are copyrighted and protected
This is a standard for project image protection
Modify the image means the image is not Barebox Logo (Modify in the limit of the Licence)
This is the full meaning of the Copyright.
The redistribution are without limitation
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerQuoted 16 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Sascha Hauer
The discussion in this thread makes it clear that there are two problems with this logo, one technical and one political.
The technical problem:
From a technical pov it makes no sense to put big image binaries into the repository when a small svg image would be sufficient to generate all other images.
The political problem:
For an open source project a closed image is a no go. We (and by we I mean we as the community, not we as Pengutronix) must for example be able to:
Quoted 5 lines
Quoted 4 lines
- generate versions with different colors, sizes, dimensions
- generate a logo without text
- modify the image and to redistribute without limitations
- add a journal to the logo and use it for bwn.org (barebox weekly news) ;)As on Linux, Meego , Mozilla, Coreboot and others Logo are copyrighted and protected
From http://commons.wikimedia.org/wiki/File:Tux.svg:
| The copyright holder of this file allows anyone to use it for any | purpose, provided that the copyright holder is properly attributed. | Redistribution, derivative work, commercial use, and all other use is | permitted.
So the Linux logo can explicitely be modified (derivative work)
You mentioned that:
Quoted 1 line
It's free to USE without modification for the Barebox Project
^^^^^^^^^^^^^^^^^^^^
Whereas is coreboot we have (from http://www.coreboot.org/Logo):
| This logo or a modified version may be used by anyone to refer to the | coreboot project
btw, the mentioned projects do not seem to have a problem with svg files:
http://upload.wikimedia.org/wikipedia/commons/1/14/MeeGo_logo.svg
http://commons.wikimedia.org/wiki/File:Tux.svg
http://upload.wikimedia.org/wikipedia/en/7/74/Mozilla_Foundation_logo.svg
http://upload.wikimedia.org/wikipedia/de/e/ec/Coreboot_logo.svg
Quoted 5 lines
This is a standard for project image protection
Modify the image means the image is not Barebox Logo (Modify in the limit of the Licence)
Does this mean it can be modified or exactly the opposite?
Could you send a license text?
Thanks
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
Quoted 36 lines · Sascha Hauer
Quoted 16 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Sascha Hauer
The discussion in this thread makes it clear that there are two problems with this logo, one technical and one political.
The technical problem:
From a technical pov it makes no sense to put big image binaries into the repository when a small svg image would be sufficient to generate all other images.
The political problem:
For an open source project a closed image is a no go. We (and by we I mean we as the community, not we as Pengutronix) must for example be able to:
Quoted 5 lines
Quoted 4 lines
- generate versions with different colors, sizes, dimensions
- generate a logo without text
- modify the image and to redistribute without limitations
- add a journal to the logo and use it for bwn.org (barebox weekly news) ;)As on Linux, Meego , Mozilla, Coreboot and others Logo are copyrighted and protected
From http://commons.wikimedia.org/wiki/File:Tux.svg:
| The copyright holder of this file allows anyone to use it for any | purpose, provided that the copyright holder is properly attributed. | Redistribution, derivative work, commercial use, and all other use is | permitted.So the Linux logo can explicitely be modified (derivative work)
You mentioned that:
Quoted 1 line
It's free to USE without modification for the Barebox Project
^^^^^^^^^^^^^^^^^^^^
Quoted 7 lines
Whereas is coreboot we have (from http://www.coreboot.org/Logo):
| This logo or a modified version may be used by anyone to refer to the | coreboot project
btw, the mentioned projects do not seem to have a problem with svg files:
The logo was designed on Photoshop for the effect
THe basic one I've a svg but not with the whole blur effect that make the logo nice on black background
Quoted 7 lines
http://upload.wikimedia.org/wikipedia/commons/1/14/MeeGo_logo.svg
http://commons.wikimedia.org/wiki/File:Tux.svg
http://upload.wikimedia.org/wikipedia/en/7/74/Mozilla_Foundation_logo.svg
http://upload.wikimedia.org/wikipedia/de/e/ec/Coreboot_logo.svgQuoted 1 line
Quoted 8 lines
Quoted 4 lines
This is a standard for project image protection
Modify the image means the image is not Barebox Logo (Modify in the limit of the Licence)
Does this mean it can be modified or exactly the opposite?
Could you send a license text?
The idea is that we can modified in a certain limit
The limit is modified in respect of the Barebox Project and the logo can only be use for the Barebox project and related
Not to sell shoes or make fun of the project
This is where I DO NOT want to argue about.
The logo is for the barebox project ONLY.
Best Regards,
J.
Quoted 10 lines
Thanks
SaschaSignature · 4 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