From 81f54d568c8e94d383e83c7f3fccb7cef1e8fa5c Mon Sep 17 00:00:00 2001 From: Steve Hawley Date: Thu, 21 May 2015 21:08:57 -0400 Subject: [PATCH] Added pixel doubling --- ppd/EpsonTMT20Simple.ppd | 12 +++ ppd/EpsonTMT20Simple.ppd~ | 211 ++++++++++++++++++++++++++++++++++++++ src/bufferedscanlines.c | 8 +- src/bufferedscanlines.h | 11 +- src/rastertoepsonsimple.c | 6 +- 5 files changed, 243 insertions(+), 5 deletions(-) create mode 100644 ppd/EpsonTMT20Simple.ppd~ diff --git a/ppd/EpsonTMT20Simple.ppd b/ppd/EpsonTMT20Simple.ppd index 40070a7..49ac118 100644 --- a/ppd/EpsonTMT20Simple.ppd +++ b/ppd/EpsonTMT20Simple.ppd @@ -179,6 +179,14 @@ *PageType 0Variable/Variable Length: "" *PageType 1Fixed/Fixed Length: "" *CloseUI: *PageType + +*OpenUI *PixelDoublingType/Pixel Doubling: PickOne +*DefaultPixelDoublingType: 0NoDoubling +*PixelDoublingType 0NoDoubling/None: "" +*PixelDoublingType 1HorizontalDoubling/Double Width: "" +*PixelDoublingType 2VerticalDoubling/Double High: "" +*PixelDoublingType 3BothDoubling/Double Wide and High: "" +*CloseUI: *PixelDoublingType *CloseGroup: OutputGroup *OpenGroup: CutGroup/Cut Options @@ -196,4 +204,8 @@ *CloseGroup: CutGroup +*OpenGroup: DoublingGroup/Pixel Doubling +*CloseGroup: DoublingGroup + + *% End diff --git a/ppd/EpsonTMT20Simple.ppd~ b/ppd/EpsonTMT20Simple.ppd~ new file mode 100644 index 0000000..70f217e --- /dev/null +++ b/ppd/EpsonTMT20Simple.ppd~ @@ -0,0 +1,211 @@ +*PPD-Adobe: "4.3" +*FormatVersion: "4.3" +*FileVersion: "2.0" +*LanguageVersion: English +*LanguageEncoding: ISOLatin1 +*PCFileName: "EpsonTMT20Simple.ppd" +*Manufacturer: "Epson" +*Product: "(TM-T20)" +*1284DeviceID: "MFG:Epson;CMD:Epson;MDL:TMT20;CLS:PRINTER;" +*cupsVersion: 1.1 +*cupsManualCopies: True +*cupsModelNumber: 20 +*cupsFilter: "application/vnd.cups-raster 0 rastertoepsonsimple" +*ModelName: "TM-T20" +*ShortNickName: "TM-T20" +*NickName: "Epson TM-T20" +*PSVersion: "(3010.000) 550" +*LanguageLevel: "3" +*ColorDevice: False +*DefaultColorSpace: Gray +*FileSystem: False +*Throughput: "1" +*LandscapeOrientation: Plus90 +*VariablePaperSize: True +*TTRasterizer: Type42 +*cupsSNMPSupplies: False +*cupsIPPReason com.star-paper_out_error/Printer is out of paper: "" + +*OpenUI *PageSize/Media Size: PickOne +*OrderDependency: 10 AnySetup *PageSize +*DefaultPageSize: X80MMY200MM + +*%PageSize Custom/Custom: "<>setpagedevice" + +*% 50.8mm wide page size note +*% 50.8mm = 2.0in * 72 = 144 points +*% use 143 points to cause 5.0 point difference with 52.5mm paper and help CUPS matching algorithm +*% see CUPS src - gdevcups.c - search "find matching page size" +*PageSize X80MMY30MM/80mm * 30mm: "<>setpagedevice" +*PageSize X80MMY40MM/80mm * 40mm: "<>setpagedevice" +*PageSize X80MMY50MM/80mm * 50mm: "<>setpagedevice" +*PageSize X80MMY60MM/80mm * 60mm: "<>setpagedevice" +*PageSize X80MMY70MM/80mm * 70mm: "<>setpagedevice" +*PageSize X80MMY80MM/80mm * 80mm: "<>setpagedevice" +*PageSize X80MMY90MM/80mm * 90mm: "<>setpagedevice" +*PageSize X80MMY100MM/80mm * 100mm: "<>setpagedevice" +*PageSize X80MMY110MM/80mm * 110mm: "<>setpagedevice" +*PageSize X80MMY120MM/80mm * 120mm: "<>setpagedevice" +*PageSize X80MMY130MM/80mm * 130mm: "<>setpagedevice" +*PageSize X80MMY140MM/80mm * 140mm: "<>setpagedevice" +*PageSize X80MMY150MM/80mm * 150mm: "<>setpagedevice" +*PageSize X80MMY160MM/80mm * 160mm: "<>setpagedevice" +*PageSize X80MMY170MM/80mm * 170mm: "<>setpagedevice" +*PageSize X80MMY180MM/80mm * 180mm: "<>setpagedevice" +*PageSize X80MMY190MM/80mm * 190mm: "<>setpagedevice" +*PageSize X80MMY200MM/80mm * 200mm: "<>setpagedevice" +*PageSize X80MMY1500MM/80mm * 1500mm: "<>setpagedevice" +*PageSize X80MMY2000MM/80mm * 2000mm: "<>setpagedevice" + +*% Zoom resolution calculation note +*% A4 real width = 209mm = 8.23in +*% Printer real width = 72mm = 576 dots +*% Printer real resolution = 203dpi +*% Rendering resolution = floor(576 dots / (8.23in * (1 - zoom))) +*% 69 = floor(576 / (8.23 * (1 - 0))) +*% 139 = floor(576 / (8.23 * (1 - .5))) + +*PageSize A4/A4 : "<>setpagedevice" +*PageSize Letter/Letter : "<>setpagedevice" +*PageSize Legal/Legal : "<>setpagedevice" +*CloseUI: *PageSize + +*OpenUI *PageRegion: PickOne +*OrderDependency: 10 AnySetup *PageRegion +*DefaultPageRegion: X80MMY200MM + +*%PageRegion Custom/Custom: "<>setpagedevice" + + +*PageRegion X80MMY30MM/80mm * 30mm: "<>setpagedevice" +*PageRegion X80MMY40MM/80mm * 40mm: "<>setpagedevice" +*PageRegion X80MMY50MM/80mm * 50mm: "<>setpagedevice" +*PageRegion X80MMY60MM/80mm * 60mm: "<>setpagedevice" +*PageRegion X80MMY70MM/80mm * 70mm: "<>setpagedevice" +*PageRegion X80MMY80MM/80mm * 80mm: "<>setpagedevice" +*PageRegion X80MMY90MM/80mm * 90mm: "<>setpagedevice" +*PageRegion X80MMY100MM/80mm * 100mm: "<>setpagedevice" +*PageRegion X80MMY110MM/80mm * 110mm: "<>setpagedevice" +*PageRegion X80MMY120MM/80mm * 120mm: "<>setpagedevice" +*PageRegion X80MMY130MM/80mm * 130mm: "<>setpagedevice" +*PageRegion X80MMY140MM/80mm * 140mm: "<>setpagedevice" +*PageRegion X80MMY150MM/80mm * 150mm: "<>setpagedevice" +*PageRegion X80MMY160MM/80mm * 160mm: "<>setpagedevice" +*PageRegion X80MMY170MM/80mm * 170mm: "<>setpagedevice" +*PageRegion X80MMY180MM/80mm * 180mm: "<>setpagedevice" +*PageRegion X80MMY190MM/80mm * 190mm: "<>setpagedevice" +*PageRegion X80MMY200MM/80mm * 200mm: "<>setpagedevice" +*PageRegion X80MMY1500MM/80mm * 1500mm: "<>setpagedevice" +*PageRegion X80MMY2000MM/80mm * 2000mm: "<>setpagedevice" + +*PageRegion A4/A4 : "<>setpagedevice" +*PageRegion Letter/Letter : "<>setpagedevice" +*PageRegion Legal/Legal : "<>setpagedevice" +*CloseUI: *PageRegion + +*DefaultImageableArea: X80MMY200MM + +*%ImageableArea Custom: "0.0 0.0 0.0 0.0" + +*ImageableArea X80MMY30MM: "0.0 0.0 226.0 85.0" +*ImageableArea X80MMY40MM: "0.0 0.0 226.0 113.0" +*ImageableArea X80MMY50MM: "0.0 0.0 226.0 141.0" +*ImageableArea X80MMY60MM: "0.0 0.0 226.0 170.0" +*ImageableArea X80MMY70MM: "0.0 0.0 226.0 198.0" +*ImageableArea X80MMY80MM: "0.0 0.0 226.0 226.0" +*ImageableArea X80MMY90MM: "0.0 0.0 226.0 255.0" +*ImageableArea X80MMY100MM: "0.0 0.0 226.0 283.0" +*ImageableArea X80MMY110MM: "0.0 0.0 226.0 311.0" +*ImageableArea X80MMY120MM: "0.0 0.0 226.0 340.0" +*ImageableArea X80MMY130MM: "0.0 0.0 226.0 368.0" +*ImageableArea X80MMY140MM: "0.0 0.0 226.0 396.0" +*ImageableArea X80MMY150MM: "0.0 0.0 226.0 425.0" +*ImageableArea X80MMY160MM: "0.0 0.0 226.0 453.0" +*ImageableArea X80MMY170MM: "0.0 0.0 226.0 481.0" +*ImageableArea X80MMY180MM: "0.0 0.0 226.0 510.0" +*ImageableArea X80MMY190MM: "0.0 0.0 226.0 538.0" +*ImageableArea X80MMY200MM: "0.0 0.0 226.0 566.0" +*ImageableArea X80MMY1500MM: "0.0 0.0 226.0 4251.0" +*ImageableArea X80MMY2000MM: "0.0 0.0 226.0 5668.0" + +*ImageableArea A4: "0.0 0.0 595.0 842.0" +*ImageableArea Letter: "0.0 0.0 612.0 792.0" +*ImageableArea Legal: "0.0 0.0 612.0 1008.0" + + +*DefaultPaperDimension: X80MMY200MM + +*%PaperDimension Custom: "0 0" + + +*PaperDimension X80MMY30MM: "226 85" +*PaperDimension X80MMY40MM: "226 113" +*PaperDimension X80MMY50MM: "226 141" +*PaperDimension X80MMY60MM: "226 170" +*PaperDimension X80MMY70MM: "226 198" +*PaperDimension X80MMY80MM: "226 226" +*PaperDimension X80MMY90MM: "226 255" +*PaperDimension X80MMY100MM: "226 283" +*PaperDimension X80MMY110MM: "226 311" +*PaperDimension X80MMY120MM: "226 340" +*PaperDimension X80MMY130MM: "226 368" +*PaperDimension X80MMY140MM: "226 396" +*PaperDimension X80MMY150MM: "226 425" +*PaperDimension X80MMY160MM: "226 453" +*PaperDimension X80MMY170MM: "226 481" +*PaperDimension X80MMY180MM: "226 510" +*PaperDimension X80MMY190MM: "226 538" +*PaperDimension X80MMY200MM: "226 566" +*PaperDimension X80MMY1500MM: "226 4251" +*PaperDimension X80MMY2000MM: "226 5668" + +*PaperDimension A4: "595 842" +*PaperDimension Letter: "612 792" +*PaperDimension Legal: "612 1008" + +*MaxMediaWidth: "226" +*MaxMediaHeight: "5670" +*HWMargins: 0 0 0 0 +*CustomPageSize True: "pop pop pop <>setpagedevice" +*ParamCustomPageSize Width: 1 points 72 226 +*ParamCustomPageSize Height: 2 points 72 5670 +*ParamCustomPageSize WidthOffset: 3 points 0 0 +*ParamCustomPageSize HeightOffset: 4 points 0 0 +*ParamCustomPageSize Orientation: 5 int 0 0 + +*OpenGroup: OutputGroup/Output Options +*OpenUI *PageType/3. Page Type: PickOne +*DefaultPageType: 0Variable +*PageType 0Variable/Variable Length: "" +*PageType 1Fixed/Fixed Length: "" +*CloseUI: *PageType + +*OpenUI *PixelDoublingType/4. Pixel Doubling: PickOne +*DefaultPixelDoublingType: 0NoDoubling +*PixelDoublingType 0NoDoubling/None: "" +*PixelDoublingType 1HorizontalDoubling/Double Width: "" +*PixelDoublingType 2VerticalDoubling/Double High: "" +*PixelDoublingType 3BothDoubling/Double Wide and High: "" +*CloseUI: *PixelDoublingType +*CloseGroup: OutputGroup + +*OpenGroup: CutGroup/Cut Options +*OpenUI *PageCutType/1. Page Cut Type: PickOne +*DefaultPageCutType: 0NoCutPage +*PageCutType 0NoCutPage/No Cut: "" +*PageCutType 1CutPage/Cut: "" +*CloseUI: *PageCutType + +*OpenUI *DocCutType/2. Document Cut Type: PickOne +*DefaultDocCutType: 1CutDoc +*DocCutType 0NoCutDoc/No Cut: "" +*DocCutType 1CutDoc/Cut: "" +*CloseUI: *DocCutType +*CloseGroup: CutGroup + + +*OpenGroup: DoublingGroup/Pixel Doubling +*CloseGroup: DoublingGroup + + +*% End diff --git a/src/bufferedscanlines.c b/src/bufferedscanlines.c index 855eaa2..5c59862 100644 --- a/src/bufferedscanlines.c +++ b/src/bufferedscanlines.c @@ -43,13 +43,14 @@ static void bufferscan_reset(t_bufferscan *bs) * Allocate and reset a new bufferscan object. * Returns NULL on failure. */ -t_bufferscan *bufferscan_new(int bytesperrow, int rows, FILE *fp) +t_bufferscan *bufferscan_new(int bytesperrow, int rows, int outputFlags, FILE *fp) { t_bufferscan *bs = (t_bufferscan *)malloc(sizeof(t_bufferscan)); if (!bs) return 0; bs->bytesPerRow = bytesperrow; bs->totalRows = rows; + bs->outputFlags = outputFlags; bs->fp = fp; bs->rawData = (unsigned char *)malloc(bytesperrow * rows); if (!bs->rawData) @@ -117,7 +118,10 @@ void bufferscan_flush(t_bufferscan *bs) fputc(29, bs->fp); fputc('8', bs->fp); fputc('L', bs->fp); writeLong(totalBytes + 10, bs->fp); fputc('0', bs->fp); fputc('p', bs->fp); - fputc('0', bs->fp); fputc(1, bs->fp); fputc(1, bs->fp); fputc('1', bs->fp); + fputc('0', bs->fp); + fputc(bs->outputFlags & kDoubleWide ? 2 : 1, bs->fp); + fputc(bs->outputFlags & kDoubleHigh ? 2 : 1, bs->fp); + fputc('1', bs->fp); writeShort(bs->bytesPerRow * 8, bs->fp); writeShort(bs->currentRow, bs->fp); diff --git a/src/bufferedscanlines.h b/src/bufferedscanlines.h index f92f03c..a1c5177 100644 --- a/src/bufferedscanlines.h +++ b/src/bufferedscanlines.h @@ -38,6 +38,7 @@ typedef struct t_bufferscan { int bytesPerRow; int totalRows; int currentRow; + int outputFlags; FILE *fp; unsigned char *rawData; } t_bufferscan; @@ -49,11 +50,19 @@ typedef struct t_bufferscan { * little endian integers as binary data. */ +/* + * defines flags for setting double width/height + */ +enum { + kDoubleWide = 1, + kDoubleHigh = 2 +}; + /* constructs a new t_bufferscan with the given bytesperrow, the total number of rows, * and the output FILE. Returns NULL on failure. Internally, this will allocate memory * for the buffer. */ -extern t_bufferscan *bufferscan_new(int bytesperrow, int rows, FILE *fp); +extern t_bufferscan *bufferscan_new(int bytesperrow, int rows, int outputFlags, FILE *fp); /* destructure the t_bufferscan and its contents. Does NOT close the output FILE */ extern void bufferscan_dispose(t_bufferscan *bs); diff --git a/src/rastertoepsonsimple.c b/src/rastertoepsonsimple.c index 66f56b6..f169b63 100644 --- a/src/rastertoepsonsimple.c +++ b/src/rastertoepsonsimple.c @@ -129,7 +129,7 @@ struct settings_ int bytesPerScanLine; int bytesPerScanLineStd; - + int doubleMode; }; struct command @@ -150,6 +150,7 @@ inline void debugPrintSettings(struct settings_ * settings) fprintf(stderr, "DEBUG: pageCutType = %d\n" , settings->pageCutType); fprintf(stderr, "DEBUG: docCutType = %d\n" , settings->docCutType); fprintf(stderr, "DEBUG: bytesPerScanLine = %d\n", settings->bytesPerScanLine); + fprintf(stderr, "DEBUG: doubleMode = %d\n", settings->doubleMode); } inline void outputCommand(struct command output) @@ -315,6 +316,7 @@ inline void initializeSettings(char * commandLineOptionSettings, struct settings settings->docCutType = getOptionChoiceIndex("DocCutType" , ppd); settings->bytesPerScanLine = 80; settings->bytesPerScanLineStd = 80; + settings->doubleMode = getOptionChoiceIndex("PixelDoublingType", ppd); getPageWidthPageHeight(ppd, settings); @@ -499,7 +501,7 @@ int main(int argc, char *argv[]) bytesPerScanline = settings.bytesPerScanLine < header.cupsBytesPerLine ? settings.bytesPerScanLine : header.cupsBytesPerLine; - bs = bufferscan_new(bytesPerScanline, 256, stdout); + bs = bufferscan_new(bytesPerScanline, 256, settings.doubleMode, stdout); if (!bs) { CLEANUP;