electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

bmp to hex tool for ks0108 graphic lcd


Post new topic  Reply to topic    EDAboard.com Forum Index -> Software Requests -> bmp to hex tool for ks0108 graphic lcd
Author Message
gameelgamal



Joined: 14 Dec 2006
Posts: 89
Location: Egypt


Post09 Jun 2009 7:44   

bmp to hex


I need a bmp to hex tool for ks0108 graphic lcd with size of 128 * 64 pixel
Back to top
Google
AdSense
Google Adsense




Post09 Jun 2009 7:44   

Ads




Back to top
Easwar



Joined: 27 Oct 2009
Posts: 1
Location: India


Post27 Oct 2009 6:49   

Re: bmp to hex tool for ks0108 graphic lcd


You can use this code for converting BMP to Hex

Code:

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>

#define HEXFILE1 "mono.bmp"      //Use ur bmp file here
#define OUTPUTFILE "hex.txt"       // Ur output file
#define READ_PLUS_MODE "rb"
#define ERROR_FILE_OPEN -1
#define ERROR_FSEEK     -2
#define ERROR_FREAD     -3
#define ERROR_FWRITE    -4
union
{
   unsigned char readdata[4];
   unsigned int readint;
}p;


int main()
{

   FILE *fp, *dp;

      int rwsize, ret, rp, i;

    
   dp = fopen(OUTPUTFILE, "w+");
   if(dp == NULL)             // Checks whether the file is present
   {
      printf("\nOutput File\n");
      return ERROR_FILE_OPEN;
   }

   fp = fopen(HEXFILE1,READ_PLUS_MODE);
   if(fp == NULL)
   {
      printf("\nInput File\n");
      fclose(dp);
      return ERROR_FILE_OPEN;
   }
                  
   ret = fseek(fp, 0, SEEK_END);
   if(ret != 0)
   {
      printf("\nSeek End\n");
      fclose(dp);
      fclose(fp);
      return ERROR_FSEEK;
   }

   rwsize =  ftell(fp);

   printf( "file size is %d\n",rwsize);

////////////////////////////////////////////////////////

   if(ret != 0)
   {
      printf("\nSeek Set\n");
      fclose(dp);
      fclose(fp);
      return ERROR_FSEEK;
   }

   
////////////////////////////////////////////////////////
   
 

   for (i=0;i<(rwsize-0x3E)/4; i++)
   {
   ret = fread(&p.readint,1,4,fp);
   fprintf (dp, "0x%02X%02X%02X%02X, ", p.readdata[0],p.readdata[1],p.readdata[2],p.readdata[3]);
   if(i%4==6) fprintf(dp, "\n");
   }
//   ret = fwrite(readdata, 1, rwsize, dp); //

   
   fclose(fp);

   fclose(dp);

   return 0;
}
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Software Requests -> bmp to hex tool for ks0108 graphic lcd
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
bmp to graphic lcd hex converter (4)
PIC C18 Library Needed for 128x64 KS0108 Graphic LCD (1)
displaying BMP file in color graphic lcd (1)
Graphic lcd user interface design tool (1)
Graphic LCD design and programming tool (4)
Need LCD command list for KS0108 (2)
help request for 128x64 lcd graphic lcd (1)
KS0108 LCD and Assembler (3)
Which LCD KS0107/KS0108 or T6963 or ...? (2)
Problem interfaceing PIC18F2550 and KS0108 LCD (3)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS