graphic_utils: pass image so we can draw only the visible part of the image
This is needed if the image is bigger than the screen. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
da0d61770a
commit
21a8ef55b0
|
@ -7,7 +7,10 @@
|
||||||
#ifndef __GRAPHIC_UTILS_H__
|
#ifndef __GRAPHIC_UTILS_H__
|
||||||
#define __GRAPHIC_UTILS_H__
|
#define __GRAPHIC_UTILS_H__
|
||||||
|
|
||||||
void rgba_blend(struct fb_info *info, void *image, void* dest, int height,
|
#include <fb.h>
|
||||||
|
#include <gui/image.h>
|
||||||
|
|
||||||
|
void rgba_blend(struct fb_info *info, struct image *img, void* dest, int height,
|
||||||
int width, int startx, int starty, bool is_rgba);
|
int width, int startx, int starty, bool is_rgba);
|
||||||
void set_pixel(struct fb_info *info, void *adr, u32 px);
|
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_rgb_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b);
|
||||||
|
|
|
@ -157,13 +157,14 @@ void set_rgba_pixel(struct fb_info *info, void *adr, u8 r, u8 g, u8 b, u8 a)
|
||||||
set_pixel(info, adr, px);
|
set_pixel(info, adr, px);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rgba_blend(struct fb_info *info, void *image, void* buf, int height,
|
void rgba_blend(struct fb_info *info, struct image *img, void* buf, int height,
|
||||||
int width, int startx, int starty, bool is_rgba)
|
int width, int startx, int starty, bool is_rgba)
|
||||||
{
|
{
|
||||||
unsigned char *adr;
|
unsigned char *adr;
|
||||||
int x, y;
|
int x, y;
|
||||||
int xres;
|
int xres;
|
||||||
int img_byte_per_pixel = 3;
|
int img_byte_per_pixel = 3;
|
||||||
|
void *image;
|
||||||
|
|
||||||
if (is_rgba)
|
if (is_rgba)
|
||||||
img_byte_per_pixel++;
|
img_byte_per_pixel++;
|
||||||
|
@ -173,11 +174,11 @@ void rgba_blend(struct fb_info *info, void *image, void* buf, int height,
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
adr = buf + ((y + starty) * xres + startx) *
|
adr = buf + ((y + starty) * xres + startx) *
|
||||||
(info->bits_per_pixel >> 3);
|
(info->bits_per_pixel >> 3);
|
||||||
|
image = img->data + (y * img->width *img_byte_per_pixel);
|
||||||
|
|
||||||
for (x = 0; x < width; x++) {
|
for (x = 0; x < width; x++) {
|
||||||
char *pixel;
|
uint8_t *pixel = image;
|
||||||
|
|
||||||
pixel = image;
|
|
||||||
if (is_rgba)
|
if (is_rgba)
|
||||||
set_rgba_pixel(info, adr, pixel[0], pixel[1],
|
set_rgba_pixel(info, adr, pixel[0], pixel[1],
|
||||||
pixel[2], pixel[3]);
|
pixel[2], pixel[3]);
|
||||||
|
|
|
@ -63,7 +63,7 @@ static int png_renderer(struct fb_info *info, struct image *img, void* fb,
|
||||||
|
|
||||||
buf = offscreenbuf ? offscreenbuf : fb;
|
buf = offscreenbuf ? offscreenbuf : fb;
|
||||||
|
|
||||||
rgba_blend(info, img->data, buf, height, width, startx, starty, true);
|
rgba_blend(info, img, buf, height, width, startx, starty, true);
|
||||||
|
|
||||||
if (offscreenbuf) {
|
if (offscreenbuf) {
|
||||||
int fbsize;
|
int fbsize;
|
||||||
|
|
Loading…
Reference in New Issue