diff --git a/dvp2sdcard/main.c b/dvp2sdcard/main.c index d604e53..ec83e94 100644 --- a/dvp2sdcard/main.c +++ b/dvp2sdcard/main.c @@ -249,7 +249,7 @@ int main(void) if (g_save_flag) { - rgb565tobmp((char*)(g_ram_mux ? g_lcd_gram0 : g_lcd_gram1), 320, 240, _T("0:photo.bmp")); + rgb565tobmp((uint8_t*)(g_ram_mux ? g_lcd_gram0 : g_lcd_gram1), 320, 240, _T("0:photo.bmp")); g_save_flag = 0; } /* display pic*/ diff --git a/dvp2sdcard/rgb2bmp.c b/dvp2sdcard/rgb2bmp.c index 9a466ab..d158774 100644 --- a/dvp2sdcard/rgb2bmp.c +++ b/dvp2sdcard/rgb2bmp.c @@ -1,11 +1,14 @@ #include "rgb2bmp.h" #include "ff.h" -int rgb565tobmp(char *buf,int width,int height, const char *filename) +int rgb565tobmp(uint8_t *buf,int width,int height, const char *filename) { FIL file; FRESULT ret = FR_OK; uint32_t ret_len = 0; + uint32_t i; + uint16_t temp; + uint16_t *ptr; BitMapFileHeader bmfHdr; /* file header */ BitMapInfoHeader bmiHdr; /* information header */ @@ -45,6 +48,15 @@ int rgb565tobmp(char *buf,int width,int height, const char *filename) bmfHdr.bfReserved2 = 0; bmfHdr.bfOffBits = sizeof(BitMapFileHeader) + sizeof(BitMapInfoHeader)+ sizeof(RgbQuad) * 3; + ptr = (uint16_t*)buf; + + for (i = 0; i < width * height; i += 2) + { + temp = ptr[i]; + ptr[i] = ptr[i + 1]; + ptr[i + 1] = temp; + } + if ((ret = f_open(&file, filename, FA_CREATE_ALWAYS | FA_WRITE)) != FR_OK) { printf("create file %s err[%d]\n", filename, ret); diff --git a/dvp2sdcard/rgb2bmp.h b/dvp2sdcard/rgb2bmp.h index 48330ab..6ee15a3 100644 --- a/dvp2sdcard/rgb2bmp.h +++ b/dvp2sdcard/rgb2bmp.h @@ -35,6 +35,6 @@ typedef struct tagRGBQUAD{ uint8_t rgbReserved;/* reserved */ }__attribute__((packed)) RgbQuad; -int rgb565tobmp(char *buf,int width,int height, const char *filename); +int rgb565tobmp(uint8_t *buf,int width,int height, const char *filename); #endif