int lucas_write_char(FILE *f, char c){ if(!f) return 0; c^=lucas_crypt; fwrite((char *)&c,1,1,f); return 1; } int laencode(int width, int height) { int color; int inicioX, inicioY; int x,y,z,oldz; int salida = 0; int cont = 0; FILE *out; char *file_name = "01img.lfl"; x=y=z=0; if ((out = fopen(file_name, "wb")) == NULL) { printf("Error opening file : %s\n",file_name); return -1; } while(x=height) { y=0; x++; } } if(z) { oldz = z; z |= 0x80; if(oldz>127) { lucas_write_char(out,0x80); lucas_write_char(out,z); } else { lucas_write_char(out,z); } } // EO Mirror mode // Simple color mode if(!z) { color = getpixelSld ( x, y); while(color == getpixelSld ( x, y) && !salida) { z++; y++; if(y>=height) { y=0; x++; } /**************************************************** ** If next pixel have a mirror at left, break this mode. ****************************************************/ if((x%8) && z>0 && color == getpixelSld ( x, y) && color == getpixelSld ( x-1, y)) { salida = 1; } } if(z<8) { color = (z << 4) + color; lucas_write_char(out,color); } else { lucas_write_char(out,color); lucas_write_char(out,z); } } // Eo Simple color mode z = 0; salida = 0; } fclose(out); return 1; }