/* VLW Compress v0.0.1 16/7/21 Used to transform 8bit VLW file into 4bit VLW file with no padding support. Note: The program is made by pure C ;it has no dependence. License:See license in root directory. */ #include #include #include FILE* fin; FILE* fout; struct { uint32_t gCount; uint32_t gVer; //0xB(11) = unCompressed,0xC(12)=compressed. uint32_t fSize; uint32_t mboxY; uint32_t ascent; uint32_t descent; uint8_t* gX; uint8_t* gY; } fInfo; uint32_t readu32(){ uint32_t temp=0; uint8_t tmp[4]={0}; fread(tmp,1,4,fin); temp |= tmp[0] << 24; temp |= tmp[1] << 16; temp |= tmp[2] << 8; temp |= tmp[3] << 0; return temp; } uint8_t readu8(){ uint8_t temp[1]; fread(temp,1,1,fin); return temp[0]; } int writeu32(uint32_t in){ uint8_t tmp[4]={0}; tmp[0]=in>>24; tmp[1]=(in & 0x00ff0000 )>>16; tmp[2]=(in & 0x0000ff00 )>>8; tmp[3]=(in & 0x000000ff ); if(fwrite(tmp,1,4,fout)==4){ return 0; } return 1; } int writeu16(uint16_t in){ uint8_t tmp[2]={0}; tmp[0]=in>>8; tmp[1]=(in & 0x00ff ); if(fwrite(tmp,1,2,fout)==2){ return 0; } return 1; } int writeu8(uint8_t in){ if(fwrite(&in,1,1,fout)==1){ return 0; } return 1; } uint8_t combine2u8(uint8_t H,uint8_t L){ return (H & 0xf0 ) | (L >> 4); //All get High bits and combine } int getFontInfo(){ fInfo.gCount=readu32(); fInfo.gVer=readu32(); fInfo.fSize=readu32(); fInfo.mboxY=readu32(); fInfo.ascent=readu32(); fInfo.descent=readu32(); return 0; } int writeHeader(){ writeu32(fInfo.gCount); writeu32(12ULL); writeu32(fInfo.fSize); writeu32(fInfo.mboxY); writeu32(fInfo.ascent); writeu32(fInfo.descent); return 0; } int compressCharsTable(){ for(uint32_t i=0;i