]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/cmd_bmp.c
3 * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * BMP handling routines
29 #include <bmp_layout.h>
31 #include <asm/byteorder.h>
34 static int bmp_info (ulong addr
);
35 static int bmp_display (ulong addr
, int x
, int y
);
37 int gunzip(void *, int, unsigned char *, unsigned long *);
42 * Description: Handler for 'bmp' command..
44 * Inputs: argv[1] contains the subcommand
49 int do_bmp(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
55 case 2: /* use load_addr as default address */
58 case 3: /* use argument */
59 addr
= simple_strtoul(argv
[2], NULL
, 16);
62 addr
= simple_strtoul(argv
[2], NULL
, 16);
63 x
= simple_strtoul(argv
[3], NULL
, 10);
64 y
= simple_strtoul(argv
[4], NULL
, 10);
67 printf ("Usage:\n%s\n", cmdtp
->usage
);
71 /* Allow for short names
72 * Adjust length if more sub-commands get added
74 if (strncmp(argv
[1],"info",1) == 0) {
75 return (bmp_info(addr
));
76 } else if (strncmp(argv
[1],"display",1) == 0) {
77 return (bmp_display(addr
, x
, y
));
79 printf ("Usage:\n%s\n", cmdtp
->usage
);
86 "bmp - manipulate BMP image data\n",
87 "info <imageAddr> - display image info\n"
88 "bmp display <imageAddr> [x y] - display image at x,y\n"
92 * Subroutine: bmp_info
94 * Description: Show information about bmp file in memory
96 * Inputs: addr address of the bmp file
101 static int bmp_info(ulong addr
)
103 bmp_image_t
*bmp
=(bmp_image_t
*)addr
;
104 #ifdef CONFIG_VIDEO_BMP_GZIP
105 unsigned char *dst
= NULL
;
107 #endif /* CONFIG_VIDEO_BMP_GZIP */
109 if (!((bmp
->header
.signature
[0]=='B') &&
110 (bmp
->header
.signature
[1]=='M'))) {
112 #ifdef CONFIG_VIDEO_BMP_GZIP
114 * Decompress bmp image
116 len
= CFG_VIDEO_LOGO_MAX_SIZE
;
117 dst
= malloc(CFG_VIDEO_LOGO_MAX_SIZE
);
119 printf("Error: malloc in gunzip failed!\n");
122 if (gunzip(dst
, CFG_VIDEO_LOGO_MAX_SIZE
, (uchar
*)addr
, &len
) != 0) {
123 printf("There is no valid bmp file at the given address\n");
126 if (len
== CFG_VIDEO_LOGO_MAX_SIZE
) {
127 printf("Image could be truncated (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n");
131 * Set addr to decompressed image
133 bmp
= (bmp_image_t
*)dst
;
136 * Check for bmp mark 'BM'
138 if (!((bmp
->header
.signature
[0] == 'B') &&
139 (bmp
->header
.signature
[1] == 'M'))) {
140 printf("There is no valid bmp file at the given address\n");
145 printf("Gzipped BMP image detected!\n");
146 #else /* CONFIG_VIDEO_BMP_GZIP */
147 printf("There is no valid bmp file at the given address\n");
149 #endif /* CONFIG_VIDEO_BMP_GZIP */
151 printf("Image size : %d x %d\n", le32_to_cpu(bmp
->header
.width
),
152 le32_to_cpu(bmp
->header
.height
));
153 printf("Bits per pixel: %d\n", le16_to_cpu(bmp
->header
.bit_count
));
154 printf("Compression : %d\n", le32_to_cpu(bmp
->header
.compression
));
156 #ifdef CONFIG_VIDEO_BMP_GZIP
160 #endif /* CONFIG_VIDEO_BMP_GZIP */
166 * Subroutine: bmp_display
168 * Description: Display bmp file located in memory
170 * Inputs: addr address of the bmp file
175 static int bmp_display(ulong addr
, int x
, int y
)
177 #if defined(CONFIG_LCD)
178 extern int lcd_display_bitmap (ulong
, int, int);
180 return (lcd_display_bitmap (addr
, x
, y
));
181 #elif defined(CONFIG_VIDEO)
182 extern int video_display_bitmap (ulong
, int, int);
183 return (video_display_bitmap (addr
, x
, y
));
185 # error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO