mirror of
https://git.familie-radermacher.ch/linux/ptouch-print.git
synced 2025-05-14 15:52:55 +00:00
Add --copies switch for multiple printouts (thanks to Wojciech Fred)
This commit is contained in:
parent
bc7d32a6e6
commit
740b20e150
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h> /* malloc() */
|
#include <stdlib.h> /* malloc() */
|
||||||
#include <string.h> /* memcmp() */
|
#include <string.h> /* memcmp() */
|
||||||
#include <sys/types.h> /* open() */
|
#include <sys/types.h> /* open() */
|
||||||
#include <sys/stat.h> /* open() */
|
#include <sys/stat.h> /* open() */
|
||||||
#include <fcntl.h> /* open() */
|
#include <fcntl.h> /* open() */
|
||||||
@ -78,7 +78,7 @@ struct _pt_dev_info ptdevs[] = {
|
|||||||
cutting of tape, printing maximum of 73mm length) */
|
cutting of tape, printing maximum of 73mm length) */
|
||||||
{0x04f9, 0x20e1, "PT-D610BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_HAS_PRECUT|FLAG_D460BT_MAGIC},
|
{0x04f9, 0x20e1, "PT-D610BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_HAS_PRECUT|FLAG_D460BT_MAGIC},
|
||||||
//{0x04f9, 0x200d, "PT-3600", 384, 360, FLAG_RASTER_PACKBITS},
|
//{0x04f9, 0x200d, "PT-3600", 384, 360, FLAG_RASTER_PACKBITS},
|
||||||
{0x04f9, 0x20af, "PT-P710BT", 128, 180, FLAG_RASTER_PACKBITS},
|
{0x04f9, 0x20af, "PT-P710BT", 128, 180, FLAG_RASTER_PACKBITS|FLAG_HAS_PRECUT},
|
||||||
{0,0,"",0,0,0}
|
{0,0,"",0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,15 +91,15 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain)
|
|||||||
printf(_("maximum printing width for this tape is %ipx\n"), tape_width);
|
printf(_("maximum printing width for this tape is %ipx\n"), tape_width);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//offset=64-(gdImageSY(im)/2); /* always print centered */
|
//offset=64-(gdImageSY(im)/2); /* always print centered */
|
||||||
size_t max_pixels=ptouch_get_max_width(ptdev);
|
size_t max_pixels=ptouch_get_max_width(ptdev);
|
||||||
offset=((int)max_pixels / 2)-(gdImageSY(im)/2); /* always print centered */
|
offset=((int)max_pixels / 2)-(gdImageSY(im)/2); /* always print centered */
|
||||||
printf("max_pixels=%ld, offset=%d\n", max_pixels, offset);
|
printf("max_pixels=%ld, offset=%d\n", max_pixels, offset);
|
||||||
if ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) {
|
if ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
printf("enable PackBits mode\n");
|
printf("enable PackBits mode\n");
|
||||||
}
|
}
|
||||||
ptouch_enable_packbits(ptdev);
|
ptouch_enable_packbits(ptdev);
|
||||||
}
|
}
|
||||||
if (ptouch_rasterstart(ptdev) != 0) {
|
if (ptouch_rasterstart(ptdev) != 0) {
|
||||||
printf(_("ptouch_rasterstart() failed\n"));
|
printf(_("ptouch_rasterstart() failed\n"));
|
||||||
@ -163,7 +163,7 @@ gdImage *image_load(const char *file)
|
|||||||
} else {
|
} else {
|
||||||
f = fopen(file, "rb");
|
f = fopen(file, "rb");
|
||||||
}
|
}
|
||||||
if (f == NULL) { /* error could not open file */
|
if (f == NULL) { /* error could not open file */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (fseek(f, 0L, SEEK_SET)) { /* file is not seekable. eg 'stdin' */
|
if (fseek(f, 0L, SEEK_SET)) { /* file is not seekable. eg 'stdin' */
|
||||||
@ -431,6 +431,7 @@ void usage(char *progname)
|
|||||||
printf("\t--writepng <file>\tinstead of printing, write output to png file\n");
|
printf("\t--writepng <file>\tinstead of printing, write output to png file\n");
|
||||||
printf("\t--force-tape-width <px>\tSet tape width in pixels, use together with\n");
|
printf("\t--force-tape-width <px>\tSet tape width in pixels, use together with\n");
|
||||||
printf("\t\t\t\t--writepng without a printer connected.\n");
|
printf("\t\t\t\t--writepng without a printer connected.\n");
|
||||||
|
printf("\t--copies <number>\tSets the number of identical prints\n");
|
||||||
printf("print commands:\n");
|
printf("print commands:\n");
|
||||||
printf("\t--image <file>\t\tprint the given image which must be a 2 color\n");
|
printf("\t--image <file>\t\tprint the given image which must be a 2 color\n");
|
||||||
printf("\t\t\t\t(black/white) png\n");
|
printf("\t\t\t\t(black/white) png\n");
|
||||||
@ -487,6 +488,12 @@ int parse_args(int argc, char **argv)
|
|||||||
debug=true;
|
debug=true;
|
||||||
} else if (strcmp(&argv[i][1], "-info") == 0) {
|
} else if (strcmp(&argv[i][1], "-info") == 0) {
|
||||||
continue; /* not done here */
|
continue; /* not done here */
|
||||||
|
} else if (strcmp(&argv[i][1], "-copies") == 0) {
|
||||||
|
if (i+1<argc) {
|
||||||
|
++i;
|
||||||
|
} else {
|
||||||
|
usage(argv[0]);
|
||||||
|
}
|
||||||
} else if (strcmp(&argv[i][1], "-image") == 0) {
|
} else if (strcmp(&argv[i][1], "-image") == 0) {
|
||||||
if (i+1<argc) {
|
if (i+1<argc) {
|
||||||
++i;
|
++i;
|
||||||
@ -524,7 +531,7 @@ int parse_args(int argc, char **argv)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, lines = 0, tape_width;
|
int i, lines = 0, tape_width, copies=1;
|
||||||
char *line[MAX_LINES];
|
char *line[MAX_LINES];
|
||||||
gdImage *im=NULL;
|
gdImage *im=NULL;
|
||||||
gdImage *out=NULL;
|
gdImage *out=NULL;
|
||||||
@ -629,6 +636,8 @@ int main(int argc, char *argv[])
|
|||||||
chain = true;
|
chain = true;
|
||||||
} else if (strcmp(&argv[i][1], "-debug") == 0) {
|
} else if (strcmp(&argv[i][1], "-debug") == 0) {
|
||||||
debug = true;
|
debug = true;
|
||||||
|
} else if (strcmp(&argv[i][1], "-copies") == 0) {
|
||||||
|
copies = strtol(argv[++i], NULL, 10);
|
||||||
} else {
|
} else {
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
@ -637,10 +646,12 @@ int main(int argc, char *argv[])
|
|||||||
if (save_png) {
|
if (save_png) {
|
||||||
write_png(out, save_png);
|
write_png(out, save_png);
|
||||||
} else {
|
} else {
|
||||||
print_img(ptdev, out, chain);
|
for (i=0; i<copies; ++i) {
|
||||||
if (ptouch_finalize(ptdev, chain) != 0) {
|
print_img(ptdev, out, chain);
|
||||||
printf(_("ptouch_finalize(%d) failed\n"), chain);
|
if (ptouch_finalize(ptdev, ( chain || (i < copies-1) ) ) != 0) {
|
||||||
return -1;
|
printf(_("ptouch_finalize(%d) failed\n"), chain);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gdImageDestroy(out);
|
gdImageDestroy(out);
|
||||||
|
Loading…
Reference in New Issue
Block a user