From 5a6739f158277055040986ca8620964fd19c4d77 Mon Sep 17 00:00:00 2001 From: klirichek Date: Thu, 28 Mar 2019 19:15:59 +0700 Subject: [PATCH] Experimental new raster Try to output raster using modern graphinc functions 'GS ( L'. Epson says it is indended for whole future, and that old 'GS v' will not be supported. However experiment shows that for cheap zijiang zj-58 it doesn't work. To try, set RASTER_TYPE=New when configuring (i.e. cmake ... -DRASTER_TYPE=New) --- CMakeLists.txt | 7 +++++++ rastertozj.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a9aea2..b0b57b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,13 @@ if ( CMAKE_BUILD_TYPE STREQUAL "Debug" ) endif () endif () +# experimental rastering +SET ( RASTER_TYPE Old CACHE STRING "Flavor how to output the raster images" ) +set_property ( CACHE RASTER_TYPE PROPERTY STRINGS "Old" "New" ) +if ( RASTER_TYPE STREQUAL "New" ) + target_compile_definitions ( rastertozj PRIVATE NEWRASTER ) +endif() + # build ppds if ( NOT DEFINED PPDC ) find_program ( PPDC ppdc ) diff --git a/rastertozj.c b/rastertozj.c index 2b9bbbe..d887b23 100644 --- a/rastertozj.c +++ b/rastertozj.c @@ -340,10 +340,37 @@ static inline void send_raster(const unsigned char *pBuf, int width8, int height) { if (!height) return; - DEBUGPRINT("Raster block %dx%d pixels\n", width8*8, height); + DEBUGPRINT("Raster block %dx%d pixels\n", width8 * 8, height); + +#ifdef NEWRASTER + // experimental - output raster according to new ESC/POS specification, + // using graphic function. + // It may work with kind of epson, but zijiang fails, oops... + // download raster - function 112 + SendCommand("\x1d(L"); // GS ( L + mputnum(width8 * height + 10); // pL, pH + mputchar ('0'); // m=48 + mputchar (112); // fn + mputchar ('0'); // monochrome digital + mputchar ('\1'); // bx + mputchar ('\1'); // by + mputchar ('1'); // с (color)= 1 + mputnum(width8*8); // xL, xH + mputnum(height); // yL, yH + + outputarray((char *)pBuf, width8 * height); + + // print raster - function 50 + SendCommand("\x1d(L"); + mputnum (2); // pL, pH + mputchar (48); // m + mputchar (50); // function = 50 + +#else sendRasterHeader(width8, height); outputarray((char *)pBuf, width8 * height); flushBuffer(); +#endif } #define EXITPRINT(CODE) \