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) \