[PATCH] Fix BMP display when the image stretches beyond border
Heinrich Schuchardt
xypron.glpk at gmx.de
Sat Apr 9 00:08:31 CEST 2022
On 4/7/22 15:42, Vitaly Wool wrote:
> When an image stretches beyond the display border, one still needs
> to seek to the next pixel line to display the visible part of that
> image correctly.
>
> Signed-off-by: Vitaly Wool <vitaly.wool at konsulko.com>
> ---
> drivers/video/video_bmp.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
> index 4d2d961696..d0177daf58 100644
> --- a/drivers/video/video_bmp.c
> +++ b/drivers/video/video_bmp.c
> @@ -238,7 +238,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
> struct bmp_image *bmp = map_sysmem(bmp_image, 0);
> uchar *bmap;
> ushort padded_width;
> - unsigned long width, height, byte_width;
> + unsigned long width, vis_width, height, byte_width;
> unsigned long pwidth = priv->xsize;
> unsigned colours, bpix, bmp_bpix;
> enum video_format eformat;
> @@ -297,8 +297,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
> video_splash_align_axis(&y, priv->ysize, height);
> }
>
> - if ((x + width) > pwidth)
> - width = pwidth - x;
> + vis_width = min(pwidth - x, width);
Where do we treat x > pwidth?
> if ((y + height) > priv->ysize)
Or y > priv->ysize?
Best regards
Heinrich
> height = priv->ysize - y;
>
> @@ -318,7 +317,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
> debug("compressed %d %d\n", compression, BMP_BI_RLE8);
> if (compression == BMP_BI_RLE8) {
> video_display_rle8_bitmap(dev, bmp, bpix, palette, fb,
> - x, y, width, height);
> + x, y, vis_width, height);
> break;
> }
> }
> @@ -330,7 +329,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
>
> for (i = 0; i < height; ++i) {
> WATCHDOG_RESET();
> - for (j = 0; j < width; j++) {
> + for (j = 0; j < vis_width; j++) {
> write_pix8(fb, bpix, eformat, palette, bmap);
> bmap++;
> fb += bpix / 8;
> @@ -343,7 +342,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
> if (IS_ENABLED(CONFIG_BMP_16BPP)) {
> for (i = 0; i < height; ++i) {
> WATCHDOG_RESET();
> - for (j = 0; j < width; j++) {
> + for (j = 0; j < vis_width; j++) {
> *fb++ = *bmap++;
> *fb++ = *bmap++;
> }
> @@ -355,7 +354,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
> case 24:
> if (IS_ENABLED(CONFIG_BMP_24BPP)) {
> for (i = 0; i < height; ++i) {
> - for (j = 0; j < width; j++) {
> + for (j = 0; j < vis_width; j++) {
> if (bpix == 16) {
> /* 16bit 565RGB format */
> *(u16 *)fb = ((bmap[2] >> 3)
> @@ -389,7 +388,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
> case 32:
> if (IS_ENABLED(CONFIG_BMP_32BPP)) {
> for (i = 0; i < height; ++i) {
> - for (j = 0; j < width; j++) {
> + for (j = 0; j < vis_width; j++) {
> if (eformat == VIDEO_X2R10G10B10) {
> u32 pix;
>
More information about the U-Boot
mailing list