Created
September 27, 2011 15:19
-
-
Save connors511/1245350 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
printf("Image compression: RLE8\n"); | |
printf("Bit offset: %d\n", bmfh.BfOffBits); | |
#endif | |
i = 0; | |
while(1) { | |
fread(&pixels, sizeof(BYTE), 1, fp); | |
fread(&color, sizeof(BYTE), 1, fp); | |
if ( pixels != 0x00 ) // escape char? | |
{ | |
for(j = 0; j < (int)pixels; j++) | |
{ | |
image->Pixels[i - 1 + j] = color; | |
totalPixels++; | |
} | |
i += (int)pixels; | |
} | |
else if (color == 0x00) // EOL | |
{ | |
#if DEBUG == 2 | |
printf("\nNEW LINE: %d\n",i); | |
#endif | |
//i = ceil((double)i / image->Width) * image->Width; | |
for (; i < ceil((double)i / image->Width) * image->Width; i++) | |
{ | |
// Assign default background color to the rest of the line | |
image->Pixels[i] = (BYTE)0; | |
} | |
#if DEBUG == 2 | |
printf("i set to %d\n",i); | |
#endif | |
} | |
else if (color == 0x01) // EOB | |
{ | |
printf("End of image\n"); | |
printf("Pixels read: %d\n", totalPixels); | |
break; | |
} | |
else // color == 0x02 | |
{ | |
// delta is not used in this assignment | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment