Slightly improved implementation of the convert85() function.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10596 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2015-02-28 07:41:38 +00:00
parent 1e0b4af8bc
commit 00a7e2d576

View File

@ -50,22 +50,23 @@ static struct85 *prepare85(FILE *outfile) // prepare to produce ASCII85-encoded
return big;
}
static int convert85(const uchar *bytes4, uchar *chars5) // encodes 4 input bytes into chars5 array
// encodes 4 input bytes from bytes4 into chars5 array
// returns # of output chars
static int convert85(const uchar *bytes4, uchar *chars5)
{
unsigned val = bytes4[0]*256*256*256 + bytes4[1]*256*256 + bytes4[2]*256 + bytes4[3];
chars5[0] = val / 52200625;
val = val % 52200625;
chars5[1] = val / 614125;
val = val % 614125;
chars5[2] = val / 7225;
val = val % 7225;
chars5[3] = val / 85;
chars5[4] = val % 85;
if (chars5[0] == 0 && chars5[1] == 0 && chars5[2] == 0 && chars5[3] == 0 && chars5[4] == 0) {
if (bytes4[0] == 0 && bytes4[1] == 0 && bytes4[2] == 0 && bytes4[3] == 0) {
chars5[0] = 'z';
return 1;
}
chars5[0] += 33; chars5[1] += 33; chars5[2] += 33; chars5[3] += 33; chars5[4] += 33;
unsigned val = bytes4[0]*(256*256*256) + bytes4[1]*(256*256) + bytes4[2]*256 + bytes4[3];
chars5[0] = val / 52200625 + 33; // 52200625 = 85 to the 4th
val = val % 52200625;
chars5[1] = val / 614125 + 33; // 614125 = 85 cube
val = val % 614125;
chars5[2] = val / 7225 + 33; // 7225 = 85 squared
val = val % 7225;
chars5[3] = val / 85 + 33;
chars5[4] = val % 85 + 33;
return 5;
}
@ -103,6 +104,10 @@ static void close85(struct85 *big) // stops ASCII85-encoding after processing r
delete big;
}
//
// End of implementation of the /ASCII85Encode PostScript filter
//
int Fl_PostScript_Graphics_Driver::alpha_mask(const uchar * data, int w, int h, int D, int LD){