#include #include #include #include #include using namespace Magick; fstream fout; class CImage { public: int maxX; int maxY; int cRes; int **intensity; void loadImage(char*); void compressImage(char*); CImage() { maxX = maxY = 0; intensity = NULL; cRes = 255; } void CImage::print() { for(int i=0;ilenb-cat-1;j--) { if(c%2==1) b[j] = '1'; else b[j] = '0'; c/=2; } b[lenb] = '\0'; } void getACcode(int n,int a, int& lenb, char* b) { int codeLen[16][11] = { 4 ,3 ,4 ,6 ,8 ,10,12,14,18,25,26, 0 ,5 ,8 ,10,13,16,22,23,24,25,26, 0 ,6 ,10,13,20,21,22,23,24,25,26, 0 ,7 ,11,14,20,21,22,23,24,25,26, 0 ,7 ,12,19,20,21,22,23,24,25,26, 0 ,8 ,12,19,20,21,22,23,24,25,26, 0 ,8 ,13,19,20,21,22,23,24,25,26, 0 ,9 ,13,19,20,21,22,23,24,25,26, 0 ,9 ,17,19,20,21,22,23,24,25,26, 0 ,10,18,19,20,21,22,23,24,25,26, 0 ,10,18,19,20,21,22,23,24,25,26, 0 ,10,18,19,20,21,22,23,24,25,26, 0 ,11,18,19,20,21,22,23,24,25,26, 0 ,12,18,19,20,21,22,23,24,25,26, 0 ,13,18,19,20,21,22,23,24,25,26, 12,17,18,19,20,21,22,23,24,25,26 }; char* code[16][11] = { "1010", "00", "01", "100", "1011", "11010", "111000", "1111000", "1111110110", "1111111110000010", "1111111110000011", "","1100","111001","1111001","111110110","11111110110","1111111110000100","1111111110000101","1111111110000110","1111111110000111","1111111110001000", "","11011","11111000","1111110111","1111111110001001","1111111110001010","1111111110001011","1111111110001100","1111111110001101","1111111110001110","1111111110001111", "","111010","111110111","11111110111","1111111110010000","1111111110010001","1111111110010010","1111111110010011","1111111110010100","1111111110010101","1111111110010110", "","111011","1111111000","1111111110010111","1111111110011000","1111111110011001","1111111110011010","1111111110011011","1111111110011100","1111111110011101","1111111110011110", "","1111010","1111111001","1111111110011111","1111111110100000","1111111110100001","1111111110100010","1111111110100011","1111111110100100","1111111110100101","1111111110100110", "","1111011","11111111000","1111111110100111","1111111110101000","1111111110101001","1111111110101010","1111111110101011","1111111110101100","1111111110101101","1111111110101110", "","11111001","11111111001","1111111110101111","1111111110110000","1111111110110001","1111111110110010","1111111110110011","1111111110110100","1111111110110101","1111111110110110", "","11111010","111111111000000","1111111110110111","1111111110111000","1111111110111001","1111111110111010","1111111110111011","1111111110111100","1111111110111101","1111111110111110", "","111111000","1111111110111111","1111111111000000","1111111111000001","1111111111000010","1111111111000011","1111111111000100","1111111111000101","1111111111000110","1111111111000111", "","111111001","1111111111001000","1111111111001001","1111111111001010","1111111111001011","1111111111001100","1111111111001101","1111111111001110","1111111111001111","1111111111010000", "","111111010","1111111111010001","1111111111010010","1111111111010011","1111111111010100","1111111111010101","1111111111010110","1111111111010111","1111111111011000","1111111111011001", "","1111111010","1111111111011010","1111111111011011","1111111111011100","1111111111011101","1111111111011110","1111111111011111","1111111111100000","1111111111100001","1111111111100010", "","11111111010","1111111111100011","1111111111100100","1111111111100101","1111111111100110","1111111111100111","1111111111101000", "1111111111101001","1111111111101010","1111111111101011", "","111111110110","1111111111101100","1111111111101101","1111111111101110","1111111111101111","1111111111110000","1111111111110001","1111111111110010","1111111111110011","1111111111110100", "111111110111","1111111111110101","1111111111110110","1111111111110111","1111111111111000","1111111111111001","1111111111111010","1111111111111011","1111111111111100","1111111111111101","1111111111111110" }; int cat = getCat(a); lenb = codeLen[n][cat]; strcpy(b,code[n][cat]); int j; int c = a; if(a<0) c+=(int)pow(2,cat)-1; for(j=lenb-1;j>lenb-cat-1;j--) { if(c%2==1) b[j] = '1'; else b[j] = '0'; c/=2; } b[lenb] = '\0'; } void Encode(int RL[64], int rl, char* output) { // char output[33*26]; char b[32]; int bLen; getDCcode(RL[0],bLen,b); // cout<<"Code : "<>a; } char *end = "111111111"; strcat(writecode,end); writeToFile(writecode); fout.close(); } void main() { CImage i; char fname[20]; cout<<"\n\nEnter name of image file (GIF file) : "; cin>>fname; i.loadImage(fname); // i.print(); cout<<"\n\nImage is loaded.\nSize is : "<>fname; strcat(fname,".Ajpg"); i.compressImage(fname); }