Skip to content

Commit

Permalink
Experimental new raster
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
klirichek committed Mar 28, 2019
1 parent 36b5458 commit 5a6739f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
29 changes: 28 additions & 1 deletion rastertozj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit 5a6739f

Please sign in to comment.