summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-10-03 21:12:19 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-03 21:12:19 +0200
commitcd323c02240af01eb914c87d9d7c41db6e34984b (patch)
treef040bcd063d5de45d287ea93a08dda46c848a70e /include
parent6a6402414852d994ce67f5df1eb7ff6e827d531b (diff)
parentf65c991d410bc5e04cf0798618f94a0627f33057 (diff)
downloadbarebox-cd323c02240af01eb914c87d9d7c41db6e34984b.tar.gz
barebox-cd323c02240af01eb914c87d9d7c41db6e34984b.tar.xz
Merge branch 'for-next/png'
Conflicts: common/filetype.c include/filetype.h
Diffstat (limited to 'include')
-rw-r--r--include/bmp_layout.h77
-rw-r--r--include/filetype.h2
-rw-r--r--include/graphic_utils.h17
-rw-r--r--include/image_renderer.h85
4 files changed, 104 insertions, 77 deletions
diff --git a/include/bmp_layout.h b/include/bmp_layout.h
deleted file mode 100644
index 63c5564830..0000000000
--- a/include/bmp_layout.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* (C) Copyright 2002
- * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-/************************************************************************/
-/* ** Layout of a bmp file */
-/************************************************************************/
-
-#ifndef _BMP_H_
-#define _BMP_H_
-
-struct bmp_color_table_entry {
- __u8 blue;
- __u8 green;
- __u8 red;
- __u8 reserved;
-} __attribute__ ((packed));
-
-/* When accessing these fields, remember that they are stored in little
- endian format, so use linux macros, e.g. le32_to_cpu(width) */
-
-struct bmp_header {
- /* Header */
- char signature[2];
- __u32 file_size;
- __u32 reserved;
- __u32 data_offset;
- /* InfoHeader */
- __u32 size;
- __u32 width;
- __u32 height;
- __u16 planes;
- __u16 bit_count;
- __u32 compression;
- __u32 image_size;
- __u32 x_pixels_per_m;
- __u32 y_pixels_per_m;
- __u32 colors_used;
- __u32 colors_important;
- /* ColorTable */
-
-} __attribute__ ((packed));
-
-struct bmp_image {
- struct bmp_header header;
- /* We use a zero sized array just as a placeholder for variable
- sized array */
- struct bmp_color_table_entry color_table[0];
-};
-
-/* Data in the bmp_image is aligned to this length */
-#define BMP_DATA_ALIGN 4
-
-/* Constants for the compression field */
-#define BMP_BI_RGB 0
-#define BMP_BI_RLE8 1
-#define BMP_BI_RLE4 2
-
-#endif /* _BMP_H_ */
diff --git a/include/filetype.h b/include/filetype.h
index 209dc11a3d..0b6cd24a6d 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -20,6 +20,8 @@ enum filetype {
filetype_mips_barebox,
filetype_fat,
filetype_mbr,
+ filetype_bmp,
+ filetype_png,
};
const char *file_type_to_string(enum filetype f);
diff --git a/include/graphic_utils.h b/include/graphic_utils.h
new file mode 100644
index 0000000000..9909b6c873
--- /dev/null
+++ b/include/graphic_utils.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPL v2
+ */
+
+#ifndef __GRAPHIC_UTILS_H__
+#define __GRAPHIC_UTILS_H__
+
+void rgba_blend(struct fb_info *info, void *image, void* dest, int height,
+ int width, int startx, int starty, bool is_rgba);
+void set_pixel(struct fb_info *info, void *adr, u32 px);
+void set_rgb_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b);
+void set_rgba_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b, u8 a);
+void memset_pixel(struct fb_info *info, void* buf, u32 color, size_t size);
+
+#endif /* __GRAPHIC_UTILS_H__ */
diff --git a/include/image_renderer.h b/include/image_renderer.h
new file mode 100644
index 0000000000..0b686e1686
--- /dev/null
+++ b/include/image_renderer.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * GPL v2
+ */
+
+#ifndef __IMAGE_RENDER_H__
+#define __IMAGE_RENDER_H__
+
+#include <filetype.h>
+#include <linux/list.h>
+#include <errno.h>
+#include <linux/err.h>
+#include <fb.h>
+
+struct image {
+ void *data;
+ struct image_renderer *ir;
+ int height;
+ int width;
+ int bits_per_pixel;
+};
+
+struct image_renderer {
+ enum filetype type;
+ struct image *(*open)(char *data, int size);
+ void (*close)(struct image *img);
+ int (*renderer)(struct fb_info *info, struct image *img, void* fb,
+ int startx, int starty, void* offscreenbuf);
+
+ /*
+ * do not free the data read from the file
+ * needed by bmp support
+ */
+ int keep_file_data;
+
+ struct list_head list;
+};
+
+#ifdef CONFIG_IMAGE_RENDERER
+int image_renderer_register(struct image_renderer *ir);
+void image_render_unregister(struct image_renderer *ir);
+
+int image_renderer_image(struct fb_info *info, struct image *img, void* fb,
+ int startx, int starty, void* offscreenbuf);
+
+struct image *image_renderer_open(const char* file);
+void image_renderer_close(struct image *img);
+
+#else
+static inline int image_renderer_register(struct image_renderer *ir)
+{
+ return -EINVAL;
+}
+static inline void image_renderer_unregister(struct image_renderer *ir) {}
+
+static inline struct image *image_renderer_open(const char* file)
+{
+ return ERR_PTR(-EINVAL);
+}
+
+static inline void image_renderer_close(struct image *img) {}
+
+int image_renderer_image(struct fb_info *info, struct image *img, void* fb,
+ int startx, int starty, void* offscreenbuf);
+#endif
+
+static inline int image_renderer_file(struct fb_info *info, const char* file, void* fb,
+ int startx, int starty, void* offscreenbuf)
+{
+ struct image* img = image_renderer_open(file);
+ int ret;
+
+ if (IS_ERR(img))
+ return PTR_ERR(img);
+
+ ret = image_renderer_image(info, img, fb, startx, starty,
+ offscreenbuf);
+
+ image_renderer_close(img);
+
+ return ret;
+}
+
+#endif /* __IMAGE_RENDERER_H__ */