$Name$
Definition in file bmp_lib.c.
#include "lcdc.h"
#include "usart.h"
#include <string.h>
Go to the source code of this file.
Data Structures | |
| struct | bm_file_header_t |
| File header of a bitmap file. 14 bytes long, little endian representation and packed. See bitmap specification for more details. More... | |
| struct | bm_info_header_t |
| Bitmap file information header. Starts after the file header and is 40 bytes long, in little endian and packed. More... | |
Functions | |
| int | display_bm (lcdc_conf_t *lcdc_conf, void *file_start) |
| Dispays the content of a bitmap file in the frame buffer. | |
| int | display_virtual_bm (lcdc_conf_t *lcdc_conf, void *file_start) |
| Dispays the content of a bitmap file in the virtual frame buffer. | |
| void | fill_frame_buffer_bm (lcdc_conf_t *lcdc_conf, bm_info_header_t *bm_info_header, unsigned char *data_start) |
| Fill the frame buffer with a bitmap. | |
| void | fill_virtual_frame_buffer_bm (lcdc_conf_t *lcdc_conf, bm_info_header_t *bm_info_header, unsigned char *data_start) |
| Magnifies a bitmap file by two and prints it into the virtual frame buffer Size of the image 320*240; Virtual frame buffer 640*480. | |
| void | swap_endian_blk (unsigned char *pblock, int size) |
| Swaps a block of data to the other endian representation. | |
| int display_bm | ( | lcdc_conf_t * | lcdc_conf, | |
| void * | file_start | |||
| ) |
Dispays the content of a bitmap file in the frame buffer.
| lcdc_conf | Pointer to the LCD controller configuration | |
| file_start | Pointer to the beginning of the file |
Definition at line 270 of file bmp_lib.c.
References bm_file_header_t::bfOffBits, bm_file_header_t::bfSize, bm_file_header_t::bfType, bm_info_header_t::biBitCount, bm_info_header_t::biCompression, bm_info_header_t::biHeight, bm_info_header_t::biWidth, fill_frame_buffer_bm(), and swap_endian_blk().
Referenced by main().
00270 { 00271 00272 bm_file_header_t bm_file_header; 00273 bm_info_header_t bm_info_header; 00274 unsigned char * data_start; 00275 00276 /* get file header and header information */ 00277 memcpy(&bm_file_header, file_start, sizeof(bm_file_header_t)); 00278 memcpy(&bm_info_header, file_start + 14, sizeof(bm_info_header_t)); 00279 00280 /* correct endianess */ 00281 swap_endian_blk((unsigned char *) &bm_file_header.bfType, 2); 00282 swap_endian_blk((unsigned char *) &bm_file_header.bfSize, 4); 00283 swap_endian_blk((unsigned char *) &bm_file_header.bfOffBits, 4); 00284 swap_endian_blk((unsigned char *) &bm_info_header.biWidth, 4); 00285 swap_endian_blk((unsigned char *) &bm_info_header.biHeight, 4); 00286 swap_endian_blk((unsigned char *) &bm_info_header.biBitCount, 2); 00287 swap_endian_blk((unsigned char *) &bm_info_header.biCompression, 4); 00288 00289 00290 data_start = file_start + bm_file_header.bfOffBits; 00291 fill_frame_buffer_bm(lcdc_conf, &bm_info_header, data_start); 00292 00293 return 0; 00294 }
| int display_virtual_bm | ( | lcdc_conf_t * | lcdc_conf, | |
| void * | file_start | |||
| ) |
Dispays the content of a bitmap file in the virtual frame buffer.
| lcdc_conf | Pointer to the LCD controller configuration | |
| file_start | Pointer to the beginning of the file |
Definition at line 241 of file bmp_lib.c.
References bm_file_header_t::bfOffBits, bm_file_header_t::bfSize, bm_file_header_t::bfType, bm_info_header_t::biBitCount, bm_info_header_t::biCompression, bm_info_header_t::biHeight, bm_info_header_t::biWidth, fill_virtual_frame_buffer_bm(), and swap_endian_blk().
Referenced by main().
00241 { 00242 00243 bm_file_header_t bm_file_header; 00244 bm_info_header_t bm_info_header; 00245 unsigned char * data_start; 00246 00247 /* get file header and header information */ 00248 memcpy(&bm_file_header, file_start, sizeof(bm_file_header_t)); 00249 memcpy(&bm_info_header, file_start + 14, sizeof(bm_info_header_t)); 00250 00251 /* correct endianess */ 00252 swap_endian_blk((unsigned char *) &bm_file_header.bfType, 2); 00253 swap_endian_blk((unsigned char *) &bm_file_header.bfSize, 4); 00254 swap_endian_blk((unsigned char *) &bm_file_header.bfOffBits, 4); 00255 swap_endian_blk((unsigned char *) &bm_info_header.biWidth, 4); 00256 swap_endian_blk((unsigned char *) &bm_info_header.biHeight, 4); 00257 swap_endian_blk((unsigned char *) &bm_info_header.biBitCount, 2); 00258 swap_endian_blk((unsigned char *) &bm_info_header.biCompression, 4); 00259 00260 00261 data_start = file_start + bm_file_header.bfOffBits; 00262 fill_virtual_frame_buffer_bm(lcdc_conf, &bm_info_header, data_start); 00263 00264 return 0; 00265 }
| void fill_frame_buffer_bm | ( | lcdc_conf_t * | lcdc_conf, | |
| bm_info_header_t * | bm_info_header, | |||
| unsigned char * | data_start | |||
| ) |
Fill the frame buffer with a bitmap.
| lcdc_conf | Pointer to the LCD controller configuration | |
| bm_info_header | Pointer to the bitmap file information (with correct endianess) | |
| data_start | Pointer to the beginning of the bitmap data |
Definition at line 175 of file bmp_lib.c.
References bm_info_header_t::biBitCount, bm_info_header_t::biHeight, bm_info_header_t::biWidth, BPP_16, BPP_24, lcdc_conf_t::dmabaddr1, lcdc_conf_t::pixelsize, and lcdc_conf_t::xres.
Referenced by display_bm().
00176 { 00177 00178 unsigned int k,l; 00179 unsigned char * framePtr, *bm; 00180 unsigned short * pframe; 00181 unsigned short red,green,blue; 00182 00183 framePtr = (unsigned char *) (lcdc_conf->dmabaddr1 | 0xA0000000); 00184 bm = data_start; 00185 if(lcdc_conf->pixelsize == BPP_24){ 00186 if(bm_info_header->biHeight < 0){ 00187 for (l = 0; l < bm_info_header->biHeight; l++){ 00188 for (k = 0; k < bm_info_header->biWidth; k++) { 00189 *framePtr++ = *( bm + 0 ); /* blue */ 00190 *framePtr++ = *( bm + 1 ); /* green */ 00191 *framePtr++ = *( bm + 2 ); /* red */ 00192 bm += 3; 00193 } 00194 if(bm_info_header->biWidth < lcdc_conf->xres) 00195 framePtr += (lcdc_conf->xres - bm_info_header->biWidth) * 3; 00196 00197 } 00198 } 00199 else { 00200 bm = bm + bm_info_header->biBitCount * bm_info_header->biWidth * (bm_info_header->biHeight - 1) / 8; 00201 for (l = 0 ; l < bm_info_header->biHeight; l++){ 00202 for (k = 0; k < bm_info_header->biWidth; k++) { 00203 *framePtr++ = *(bm + 0); 00204 *framePtr++ = *(bm + 1); 00205 *framePtr++ = *(bm + 2); 00206 bm += 3; 00207 } 00208 bm = bm - bm_info_header->biBitCount *2* bm_info_header->biWidth / 8; 00209 if(bm_info_header->biWidth < lcdc_conf->xres) 00210 framePtr += (lcdc_conf->xres - bm_info_header->biWidth) * 3; 00211 00212 } 00213 } 00214 } 00215 if(lcdc_conf->pixelsize == BPP_16){ 00216 pframe = (unsigned short *) framePtr; 00217 if(bm_info_header->biHeight > 0) { 00218 00219 bm = bm + bm_info_header->biBitCount * bm_info_header->biWidth * (bm_info_header->biHeight - 1) / 8; 00220 for (l = 0 ; l < bm_info_header->biHeight; l++){ 00221 for (k = 0; k < bm_info_header->biWidth; k++) { 00222 00223 blue = *(bm + 2) >> 3; 00224 green = *(bm +1) >> 3; 00225 red = *bm >> 3; 00226 *pframe++ = ((blue << 10) & 0x7C00) | ((green << 5) & 0x03E0) | (red & 0x001F); 00227 bm += 3; 00228 } 00229 bm = bm - bm_info_header->biBitCount *2* bm_info_header->biWidth / 8; 00230 if(bm_info_header->biWidth < lcdc_conf->xres) 00231 pframe += (lcdc_conf->xres - bm_info_header->biWidth); 00232 00233 } 00234 } 00235 } 00236 }
| void fill_virtual_frame_buffer_bm | ( | lcdc_conf_t * | lcdc_conf, | |
| bm_info_header_t * | bm_info_header, | |||
| unsigned char * | data_start | |||
| ) |
Magnifies a bitmap file by two and prints it into the virtual frame buffer Size of the image 320*240; Virtual frame buffer 640*480.
| lcdc_conf | Pointer to the LCD controller setup structure | |
| bm_info_header | Pointer to the bit map file information structure | |
| data_start | Pointer to the beginning of the bit map file |
Definition at line 132 of file bmp_lib.c.
References bm_info_header_t::biBitCount, bm_info_header_t::biHeight, bm_info_header_t::biWidth, and lcdc_conf_t::dmabaddr1.
Referenced by display_virtual_bm().
00133 { 00134 unsigned int k,l; 00135 unsigned char * framePtr, *bm; 00136 00137 /* set framebuffer start pointer to non-cached address */ 00138 framePtr = (unsigned char *) (lcdc_conf->dmabaddr1 | 0xA0000000); 00139 bm = data_start; 00140 00141 bm = bm + bm_info_header->biBitCount * bm_info_header->biWidth * (bm_info_header->biHeight - 1) / 8; 00142 for (l = 0 ; l < bm_info_header->biHeight; l++){ 00143 for (k = 0; k < bm_info_header->biWidth; k++) { 00144 framePtr++; /* empty */ 00145 *framePtr++ = *( bm + 0 ); /* blue */ 00146 *framePtr++ = *( bm + 1 ); /* green */ 00147 *framePtr++ = *( bm + 2 ); /* red */ 00148 framePtr++; 00149 *framePtr++ = *( bm + 0 ); 00150 *framePtr++ = *( bm + 1 ); 00151 *framePtr++ = *( bm + 2 ); 00152 bm += 3; 00153 } 00154 bm = bm - bm_info_header->biBitCount * bm_info_header->biWidth / 8; 00155 for (k = 0; k < bm_info_header->biWidth; k++) { 00156 framePtr++; 00157 *framePtr++ = *( bm + 0 ); 00158 *framePtr++ = *( bm + 1 ); 00159 *framePtr++ = *( bm + 2 ); 00160 framePtr++; 00161 *framePtr++ = *( bm + 0 ); 00162 *framePtr++ = *( bm + 1 ); 00163 *framePtr++ = *( bm + 2 ); 00164 bm += 3; 00165 } 00166 bm = bm - bm_info_header->biBitCount *2* bm_info_header->biWidth / 8; 00167 } 00168 }
| void swap_endian_blk | ( | unsigned char * | pblock, | |
| int | size | |||
| ) |
Swaps a block of data to the other endian representation.
| pblock | Pointer to the first byte of the data block | |
| size | Size of the data bock in bytes |
Definition at line 113 of file bmp_lib.c.
Referenced by display_bm(), and display_virtual_bm().
00114 { 00115 unsigned char *pend = &pblock[size - 1]; 00116 unsigned char temp; 00117 while(pblock < pend) 00118 { 00119 temp = *pblock; 00120 *pblock = *pend; 00121 *pend = temp; 00122 pblock++; 00123 pend--; 00124 } 00125 }
1.5.3-20071008