티스토리 뷰

Mobile

MV2530 / MP2530F Boot Logo Maker

알 수 없는 사용자 2011. 3. 18. 07:20

개발보드를 요즘 쪼물딱거리고 있는데..

 

부트로고가 마음에 들지 않아서 바꾸어 보려고 했습니다만, 국내사이트에서는 굉장히 찾기가 힘들더군요..

 

겨우 두어개 찾긴 했습니다만, 카페 회원만 받을수 있다거나 그런 경우였습니다..

 

어쨌건 기본적인 힌트를 얻고, 중국 사이트의 소스를 참조하여 만들었습니다.. ?_-;;

 

   1: #include "stdio.h"
   2: #include "stdlib.h"
   3:  
   4: /***********************************************
   5: Data types
   6: ************************************************/
   7: #define dgNULL    0L
   8:  
   9: #define dgTRUE    1
  10: #define dgFALSE    0
  11: typedef short int dgBOOL;
  12:  
  13: typedef signed char    S8;
  14: typedef signed short int S16;
  15: typedef signed int    S32;
  16:  
  17: typedef unsigned char    U8;
  18: typedef unsigned short int U16;
  19: typedef unsigned int    U32;
  20:  
  21: #define BI_RGB 0L
  22: typedef struct tag_dgImage_BITMAPFILEHEADER {
  23:   U32 bfSize;
  24:   U16 bfReserved1;
  25:   U16 bfReserved2;
  26:   U32 bfOffBits;
  27: } _dgImage_BITMAPFILEHEADER;
  28:  
  29: typedef struct tag_dgImage_BITMAPINFOHEADER{
  30:   U32 biSize;
  31:   S32 biWidth;
  32:   S32 biHeight;
  33:   U16 biPlanes;
  34:   U16 biBitCount;
  35:   U32 biCompression;
  36:   U32 biSizeImage;
  37:   S32 biXPelsPerMeter;
  38:   S32 biYPelsPerMeter;
  39:   U32 biClrUsed;
  40:   U32 biClrImportant;
  41: } _dgImage_BITMAPINFOHEADER;
  42:  
  43:  
  44: #define RGB_16BIT     0
  45: #define RGB_24BIT     1
  46: dgBOOL BMP2DMP( const char *const srcname, const char *const dstname, char rgbdata)
  47: {
  48:   U16 BMP_ID;
  49:   _dgImage_BITMAPFILEHEADER bmpfh;
  50:   _dgImage_BITMAPINFOHEADER bmpinfo;
  51:  
  52:   FILE *fp1, *fp2;
  53:  
  54:   /* load windows BMP file */
  55:   fp1 = fopen( srcname, "rb" );
  56:   if( !fp1 ) goto error;
  57:  
  58:   fp2 = fopen( dstname, "wb" );
  59:   if( !fp2 ) goto error;
  60:  
  61:   fread((void *)(&BMP_ID),2, 1, fp1 );
  62:   //if (BMP_ID != *((U16*) "BM")) goto error;
  63:   fread((void *)(&bmpfh),sizeof(_dgImage_BITMAPFILEHEADER), 1, fp1 );
  64:   fread((void *)(&bmpinfo),sizeof(_dgImage_BITMAPINFOHEADER), 1, fp1 );
  65:  
  66:   printf( "Width : %d, Height : %d\n", bmpinfo.biWidth, bmpinfo.biHeight );
  67:   //printf( "Data Position = 0x%08X\n", bmpfh.bfOffBits );
  68:   {
  69:     int i, j;
  70:     unsigned short int rgb565;
  71:     unsigned char bgr[3];
  72:  
  73:     fseek( fp1, bmpfh.bfOffBits,SEEK_SET );
  74:     for( i=(bmpinfo.biHeight)-1 ; i>=0 ; i-- )
  75:     {
  76:       for( j=0 ; j<(bmpinfo.biWidth) ; j++ )
  77:       {
  78:         if(rgbdata == 0)
  79:         {
  80:           fread( bgr, 3, 1, fp1 );
  81:           rgb565 = ((((U16)bgr[2])&0xF8)<<8) | ((((U16)bgr[1])&0xFC)<<3) | ((((U16)bgr[0])&0xF8)>>3);
  82:           //printf(" (%3d, %3d) = (%3d, %3d, %3d) = 0x%04X\n", j, i, bgr[0], bgr[1], bgr[2], rgb565 );
  83:           fseek( fp2, (i*bmpinfo.biWidth + j)*2, SEEK_SET );
  84:           fwrite( &rgb565, 2, 1, fp2 );
  85:         }
  86:         else if(rgbdata == 1)
  87:         {
  88:           fread( bgr, 3, 1, fp1 );
  89:           fseek( fp2, (i*bmpinfo.biWidth + j)*3, SEEK_SET );
  90:           fwrite( bgr, 3, 1, fp2);
  91:         }
  92:         else
  93:         {
  94:           goto error;
  95:         }
  96:       }
  97:       // 4 byte aline per every line.
  98:       if( (bmpinfo.biWidth*3) % 4 )
  99:       {
 100:         fread( bgr, (bmpinfo.biWidth*3) % 4, 1, fp1 );
 101:       }
 102:     }
 103:   }
 104:  
 105:   switch(rgbdata)
 106:   {
 107:   case 0:
 108:     printf( "16BIT RGBDATA\n" );
 109:     break;
 110:   case 1:
 111:     printf( "24BIT RGBDATA\n" );
 112:     break;
 113:   default:
 114:     break;
 115:   }
 116:   //    printf( "saved\n" );
 117:   if( fp1 ) fclose( fp1 );
 118:   if( fp2 ) fclose( fp2 );
 119:   return dgTRUE;
 120:  
 121: error:
 122:   printf( "error\n" );
 123:   if( fp1 ) fclose( fp1 );
 124:   if( fp2 ) fclose( fp2 );
 125:   return dgFALSE;
 126: }
 127:  
 128: int main( int argc, char *argv[] )
 129: {
 130:   if( argc != 4 )
 131:   {
 132:     printf( "Usage : bmp2dmp.exe srcfilename dstfilename RGB_DATA\n" );
 133:     printf( "<>\n" );
 134:     printf( "0 : 24Bit BMP File --> 16Bit RGB DATA\n" );
 135:     printf( "1 : 24Bit BMP File --> 24Bit RGB DATA\n" );
 136:  
 137:     return -1;
 138:   }
 139:  
 140:   //    if( BMP2DMP( (const char *const)argv[1], (const char *const)argv[2] ) )
 141:   if( BMP2DMP( (const char *const)argv[1], (const char *const)argv[2] , (atoi(argv[3]))))
 142:     return 0;
 143:   return -1;
 144: }

 

사용법은, 해상도에 맞는 bmp파일을 16비트로 작업하시고 저장은 24비트로 하십니다..

 

그리고 콘솔에서

bmp2dmp 원본.bmp 사본.bin 0

 

요렇게 돌리면 750kb짜리 파일이 하나 생깁니다..

 

파일을 업로드하면 전송이 시작됨과 동시에 화면이 갱신되기 시작합니다..

 

 

저야 개인이니 별 상관없습니다만, 회사에서 납품을 했는데 부트로고가 개발보드 생산업체면 난감하잖아요 ㅋㅋ

 

UI도 좀 짜서 이쁘게 만들어보려다가.. 이런게 필요한 사람이 있으면 얼마나 있을런지.. 그리고 이게 필요한 사람이면 콘솔이 편할 확률이 훨씬 높다고 생각해서 걍 냅뒀습니다 ㅋㅋ

 

어쨌건 샘플도 첨부합니다..