Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MARY_CAMERA NokiaLCD mbed
bmp_handler.cpp@10:3c8fc9569377, 2014-02-18 (annotated)
- Committer:
- okano
- Date:
- Tue Feb 18 05:03:58 2014 +0000
- Revision:
- 10:3c8fc9569377
- Child:
- 11:149993faf2be
bmp file saving function added
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| okano | 10:3c8fc9569377 | 1 | #include "mbed.h" // for mbed |
| okano | 10:3c8fc9569377 | 2 | LocalFileSystem local("local"); // for mbed to access local file system |
| okano | 10:3c8fc9569377 | 3 | |
| okano | 10:3c8fc9569377 | 4 | char bmp_header[] = { |
| okano | 10:3c8fc9569377 | 5 | 0x42, 0x4d, 0x8a, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x7c, 0x00, |
| okano | 10:3c8fc9569377 | 6 | 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, |
| okano | 10:3c8fc9569377 | 7 | 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00, |
| okano | 10:3c8fc9569377 | 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x1f, 0x00, |
| okano | 10:3c8fc9569377 | 9 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| okano | 10:3c8fc9569377 | 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| okano | 10:3c8fc9569377 | 11 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, |
| okano | 10:3c8fc9569377 | 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| okano | 10:3c8fc9569377 | 13 | }; |
| okano | 10:3c8fc9569377 | 14 | |
| okano | 10:3c8fc9569377 | 15 | FILE *fp; |
| okano | 10:3c8fc9569377 | 16 | |
| okano | 10:3c8fc9569377 | 17 | int open_BMP( char *file_name ) |
| okano | 10:3c8fc9569377 | 18 | { |
| okano | 10:3c8fc9569377 | 19 | char s[ 80 ]; |
| okano | 10:3c8fc9569377 | 20 | |
| okano | 10:3c8fc9569377 | 21 | sprintf( s, "/local/%s", file_name ); |
| okano | 10:3c8fc9569377 | 22 | |
| okano | 10:3c8fc9569377 | 23 | if ( NULL == (fp = fopen( s, "wb" )) ) |
| okano | 10:3c8fc9569377 | 24 | return 1; |
| okano | 10:3c8fc9569377 | 25 | |
| okano | 10:3c8fc9569377 | 26 | fwrite( bmp_header, sizeof( bmp_header ), 1, fp ); |
| okano | 10:3c8fc9569377 | 27 | |
| okano | 10:3c8fc9569377 | 28 | return 0; |
| okano | 10:3c8fc9569377 | 29 | } |
| okano | 10:3c8fc9569377 | 30 | |
| okano | 10:3c8fc9569377 | 31 | void write_BMP( short *p, int length ) |
| okano | 10:3c8fc9569377 | 32 | { |
| okano | 10:3c8fc9569377 | 33 | fwrite( p, sizeof( short ), length, fp ); |
| okano | 10:3c8fc9569377 | 34 | } |
| okano | 10:3c8fc9569377 | 35 | |
| okano | 10:3c8fc9569377 | 36 | void close_BMP( void ) |
| okano | 10:3c8fc9569377 | 37 | { |
| okano | 10:3c8fc9569377 | 38 | fclose( fp ); |
| okano | 10:3c8fc9569377 | 39 | } |