mitsu70x: Fix incorrect page combining for the Kodak 305 and Mitsu K60

2* 3.5x5" -> 5x7-div2 overpadded by 11 rows, overflowing a buffer.
2* 4x6 -> 8x6-div2 underpadded by 2 rows, possibly resulting in a white margin.
This commit is contained in:
Solomon Peachy 2024-01-20 20:41:22 -05:00
parent e0ec2898a6
commit 12f8c1c231
1 changed files with 15 additions and 15 deletions

View File

@ -747,7 +747,7 @@ static void *mitsu70x_combine_jobs(const void *vjob1,
struct mitsu70x_printjob *newjob = NULL;
uint16_t newrows;
uint16_t newcols;
uint32_t newpad, finalpad;
int32_t middlepad, finalpad;
uint16_t lamoffset;
const struct mitsu70x_hdr *hdr1, *hdr2;
@ -774,26 +774,25 @@ static void *mitsu70x_combine_jobs(const void *vjob1,
switch (job1->rows) {
case 1218: /* K60, EK305 */
newrows = 2454;
newpad = 16;
middlepad = 18;
finalpad = 0;
lamoffset = 0;
break;
case 1228: /* D70, ASK300, D80, DS480/DS680 */
if (job1->cols == 1264) { // DS480 4" wide..
newrows = 2494;
newpad = 38;
middlepad = 38;
finalpad = 0;
lamoffset = 12;
} else {
newrows = 2730;
newpad = 38;
middlepad = 38;
finalpad = 236;
lamoffset = 12;
}
lamoffset = 12;
break;
case 1076: /* EK305, K60 3.5x5" prints */
newrows = 2190;
newpad = 49;
middlepad = 38;
finalpad = 0;
lamoffset = 0;
break;
@ -801,7 +800,7 @@ static void *mitsu70x_combine_jobs(const void *vjob1,
goto done;
}
newcols = job1->cols;
newpad *= newcols;
middlepad *= newcols;
finalpad *= newcols;
/* Okay, it's kosher to proceed */
@ -855,20 +854,21 @@ static void *mitsu70x_combine_jobs(const void *vjob1,
goto done;
}
/* Fill in padding */
/* Fill in "final" padding */
memset(newjob->spoolbuf + newjob->spoolbuflen, 0xff, finalpad * 3);
newjob->spoolbuflen += finalpad * 3;
/* Copy image payload */
/* Copy image1 payload */
memcpy(newjob->spoolbuf + newjob->spoolbuflen, job1->spoolbuf,
job1->spoolbuflen);
newjob->spoolbuflen += job1->spoolbuflen;
/* Fill in padding */
memset(newjob->spoolbuf + newjob->spoolbuflen, 0xff, newpad * 3);
newjob->spoolbuflen += newpad * 3;
/* Fill in middle padding */
if (middlepad > 0)
memset(newjob->spoolbuf + newjob->spoolbuflen, 0xff, middlepad * 3);
newjob->spoolbuflen += middlepad * 3;
/* Copy image payload */
/* Copy image2 payload */
memcpy(newjob->spoolbuf + newjob->spoolbuflen, job2->spoolbuf,
job2->spoolbuflen);
newjob->spoolbuflen += job2->spoolbuflen;
@ -2618,7 +2618,7 @@ static const char *mitsu70x_prefixes[] = {
/* Exported */
const struct dyesub_backend mitsu70x_backend = {
.name = "Mitsubishi CP-D70 family",
.version = "0.108" " (lib " LIBMITSU_VER ")",
.version = "0.109" " (lib " LIBMITSU_VER ")",
.flags = BACKEND_FLAG_DUMMYPRINT,
.uri_prefixes = mitsu70x_prefixes,
.cmdline_usage = mitsu70x_cmdline,