BaseJpegDeocde exampe program
Dependencies: BaseJpegDecode Terminal BaseUsbHost mbed mbed-rtos
Fork of BaseJpegDecode by
Diff: bmp24.h
- Revision:
- 5:033432f9baf3
- Parent:
- 4:7d88de31c55a
--- a/bmp24.h Tue Oct 30 15:35:36 2012 +0000 +++ b/bmp24.h Thu Nov 15 10:20:38 2012 +0000 @@ -6,9 +6,12 @@ class bmp24 { public: + int width; + int height; + bmp24() { - m_width = BMP24_WIDTH; - m_height = BMP24_HEIGHT; + width = BMP24_WIDTH; + height = BMP24_HEIGHT; } void clear() { @@ -16,8 +19,8 @@ } void point(int x, int y, uint8_t* rgb) { - if (x >= 0 && x < m_width && y >= 0 && y < m_height) { - int pos = y*m_width*3+x*3; + if (x >= 0 && x < width && y >= 0 && y < height) { + int pos = y*width*3+x*3; m_bitmap[pos++] = rgb[0]; m_bitmap[pos++] = rgb[1]; m_bitmap[pos] = rgb[2]; @@ -43,21 +46,20 @@ 0x00,0x00,0x00,0x00,0x00,0x00}; int file_size = sizeof(header) + sizeof(m_bitmap); LE32write(header+2, file_size); - LE32write(header+18, m_width); - LE32write(header+22, m_height); + LE32write(header+18, width); + LE32write(header+22, height); fwrite(header, 1, sizeof(header), fp); - for(int y = m_height-1; y >=0; y--) { - for(int x = 0; x < m_width; x++) { - fputc(m_bitmap[y*m_width*3+x*3+2], fp); - fputc(m_bitmap[y*m_width*3+x*3+1], fp); - fputc(m_bitmap[y*m_width*3+x*3+0], fp); + for(int y = height-1; y >=0; y--) { + for(int x = 0; x < width; x++) { + fputc(m_bitmap[y*width*3+x*3+2], fp); + fputc(m_bitmap[y*width*3+x*3+1], fp); + fputc(m_bitmap[y*width*3+x*3+0], fp); } } fclose(fp); } - int m_width; - int m_height; + uint8_t m_bitmap[BMP24_WIDTH*BMP24_HEIGHT*3]; };