} while (--bits);
}
-static unsigned char ChoosePackagingMode(signed len, signed index, char LineBuffer[512])
+static unsigned char ChoosePackagingMode(signed len, signed index, char ColorBits, char LineBuffer[512])
{
--len;
if (!len) {
if (LineBuffer[index] != LineBuffer[index + 1]) {
return 0;
}
+ if (ColorBits > 2) {
+ return 1;
+ }
+ if (LineBuffer[index] != LineBuffer[index + 2]) {
+ return 0;
+ }
+ if (ColorBits > 1) {
+ return 1;
+ }
+ if (LineBuffer[index] != LineBuffer[index + 3]) {
+ return 0;
+ }
return 1;
}
case smPacked:
i = 0;
while (len) {
- if (ChoosePackagingMode(len, i, LineBuffer)) {
+ if (ChoosePackagingMode(len, i, ColorBits, LineBuffer)) {
/* Make runlength packet */
V = LineBuffer[i];
++i;
*d_ptr++ = V;
--len;
count = 0;
- while (ChoosePackagingMode(len, i, LineBuffer) == 0 && len && count != 15) {
+ while (ChoosePackagingMode(len, i, ColorBits, LineBuffer) == 0 && len && count != 15) {
V = LineBuffer[i++];
*d_ptr++ = V;
++count;
}
i = 0;
while (len) {
- if (ChoosePackagingMode(len, i, LineBuffer)) {
+ if (ChoosePackagingMode(len, i, ColorBits, LineBuffer)) {
/* Make runlength packet */
V = LineBuffer[i];
++i;
*d_ptr++ = V;
--len;
count = 0;
- while (ChoosePackagingMode(len, i, LineBuffer) == 0 && len && count != 15) {
+ while (ChoosePackagingMode(len, i, ColorBits, LineBuffer) == 0 && len && count != 15) {
V = LineBuffer[i++];
*d_ptr++ = V;
++count;