diff --git a/src/libptouch.c b/src/libptouch.c index e70bfbf..9876f3a 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -1,7 +1,7 @@ /* libptouch - functions to help accessing a brother ptouch - Copyright (C) 2013-2023 Dominic Radermacher + Copyright (C) 2013-2025 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as @@ -45,9 +45,10 @@ struct _pt_tape_info tape_info[]= { }; struct _pt_dev_info ptdevs[] = { + {0x04f9, 0x2004, "PT-2300", 112, 180, FLAG_RASTER_PACKBITS|FLAG_HAS_PRECUT}, /* 180dpi, 112px printhead */ {0x04f9, 0x2007, "PT-2420PC", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, 128px, maximum tape width 24mm, must send TIFF compressed pixel data */ {0x04f9, 0x2011, "PT-2450PC", 128, 180, FLAG_RASTER_PACKBITS}, - {0x04f9, 0x2019, "PT-1950", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, apparently 112px printhead ?, maximum tape width 18mm - unconfirmed if it works */ + {0x04f9, 0x2019, "PT-1950", 112, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, apparently 112px printhead ?, maximum tape width 18mm - unconfirmed if it works */ {0x04f9, 0x201f, "PT-2700", 128, 180, FLAG_HAS_PRECUT}, {0x04f9, 0x202c, "PT-1230PC", 128, 180, FLAG_NONE}, /* 180dpi, supports tapes up to 12mm - I don't know how much pixels it can print! */ /* Notes about the PT-1230PC: While it is true that this printer supports diff --git a/src/ptouch-print.c b/src/ptouch-print.c index b05eb05..b742596 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -1,7 +1,7 @@ /* ptouch-print - Print labels with images or text on a Brother P-Touch - Copyright (C) 2015-2024 Dominic Radermacher + Copyright (C) 2015-2025 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as @@ -67,7 +67,7 @@ void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel) { // TODO: pixel should be unsigned, since we can't have negative // if (pixel > ptdev->devinfo->device_max_px) { - if (pixel > (int)(size*8)) { + if ((pixel < 0) || (pixel >= (int)(size*8))) { return; } rasterline[(size-1)-(pixel/8)] |= (uint8_t)(1<<(pixel%8)); @@ -91,7 +91,7 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) printf(_("maximum printing width for this tape is %ipx\n"), tape_width); return -1; } - //offset=64-(gdImageSY(im)/2); /* always print centered */ + printf(_("image size (%ipx x %ipx)\n"), gdImageSX(im), gdImageSY(im)); size_t max_pixels=ptouch_get_max_width(ptdev); offset=((int)max_pixels / 2)-(gdImageSY(im)/2); /* always print centered */ printf("max_pixels=%ld, offset=%d\n", max_pixels, offset); @@ -136,7 +136,7 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) rasterline_setpixel(rasterline, sizeof(rasterline), offset+i); } } - if (ptouch_sendraster(ptdev, rasterline, 16) != 0) { + if (ptouch_sendraster(ptdev, rasterline, (ptdev->devinfo->max_px / 8)) != 0) { printf(_("ptouch_sendraster() failed\n")); return -1; } diff --git a/udev/90-usb-ptouch-permissions.rules b/udev/90-usb-ptouch-permissions.rules index b9d9f66..1c379f8 100644 --- a/udev/90-usb-ptouch-permissions.rules +++ b/udev/90-usb-ptouch-permissions.rules @@ -1,4 +1,5 @@ # Enable non-root access for known ptouch printers +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2004", MODE="0660", TAG+="uaccess" SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2007", MODE="0660", TAG+="uaccess" SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2011", MODE="0660", TAG+="uaccess" SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2019", MODE="0660", TAG+="uaccess"