Added pixel doubling

This commit is contained in:
Steve Hawley 2015-05-21 21:08:57 -04:00
parent f7bc558f27
commit 81f54d568c
5 changed files with 243 additions and 5 deletions

View file

@ -179,6 +179,14 @@
*PageType 0Variable/Variable Length: "" *PageType 0Variable/Variable Length: ""
*PageType 1Fixed/Fixed Length: "" *PageType 1Fixed/Fixed Length: ""
*CloseUI: *PageType *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 *CloseGroup: OutputGroup
*OpenGroup: CutGroup/Cut Options *OpenGroup: CutGroup/Cut Options
@ -196,4 +204,8 @@
*CloseGroup: CutGroup *CloseGroup: CutGroup
*OpenGroup: DoublingGroup/Pixel Doubling
*CloseGroup: DoublingGroup
*% End *% End

211
ppd/EpsonTMT20Simple.ppd~ Normal file
View file

@ -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: "<</PageSize[0 0]/HWResolution[203 203]/ImagingBBox null>>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: "<</PageSize[226 85]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY40MM/80mm * 40mm: "<</PageSize[226 113]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY50MM/80mm * 50mm: "<</PageSize[226 141]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY60MM/80mm * 60mm: "<</PageSize[226 170]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY70MM/80mm * 70mm: "<</PageSize[226 198]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY80MM/80mm * 80mm: "<</PageSize[226 226]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY90MM/80mm * 90mm: "<</PageSize[226 255]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY100MM/80mm * 100mm: "<</PageSize[226 283]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY110MM/80mm * 110mm: "<</PageSize[226 311]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY120MM/80mm * 120mm: "<</PageSize[226 340]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY130MM/80mm * 130mm: "<</PageSize[226 368]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY140MM/80mm * 140mm: "<</PageSize[226 396]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY150MM/80mm * 150mm: "<</PageSize[226 425]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY160MM/80mm * 160mm: "<</PageSize[226 453]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY170MM/80mm * 170mm: "<</PageSize[226 481]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY180MM/80mm * 180mm: "<</PageSize[226 510]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY190MM/80mm * 190mm: "<</PageSize[226 538]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY200MM/80mm * 200mm: "<</PageSize[226 566]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY1500MM/80mm * 1500mm: "<</PageSize[226 4251]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageSize X80MMY2000MM/80mm * 2000mm: "<</PageSize[226 5668]/HWResolution[203 203]/ImagingBBox null>>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 : "<</PageSize[595 842]/HWResolution[69 69]/ImagingBBox null>>setpagedevice"
*PageSize Letter/Letter : "<</PageSize[612 792]/HWResolution[67 67]/ImagingBBox null>>setpagedevice"
*PageSize Legal/Legal : "<</PageSize[612 1008]/HWResolution[67 67]/ImagingBBox null>>setpagedevice"
*CloseUI: *PageSize
*OpenUI *PageRegion: PickOne
*OrderDependency: 10 AnySetup *PageRegion
*DefaultPageRegion: X80MMY200MM
*%PageRegion Custom/Custom: "<</PageSize[0 0]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY30MM/80mm * 30mm: "<</PageSize[226 85]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY40MM/80mm * 40mm: "<</PageSize[226 113]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY50MM/80mm * 50mm: "<</PageSize[226 141]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY60MM/80mm * 60mm: "<</PageSize[226 170]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY70MM/80mm * 70mm: "<</PageSize[226 198]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY80MM/80mm * 80mm: "<</PageSize[226 226]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY90MM/80mm * 90mm: "<</PageSize[226 255]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY100MM/80mm * 100mm: "<</PageSize[226 283]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY110MM/80mm * 110mm: "<</PageSize[226 311]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY120MM/80mm * 120mm: "<</PageSize[226 340]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY130MM/80mm * 130mm: "<</PageSize[226 368]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY140MM/80mm * 140mm: "<</PageSize[226 396]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY150MM/80mm * 150mm: "<</PageSize[226 425]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY160MM/80mm * 160mm: "<</PageSize[226 453]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY170MM/80mm * 170mm: "<</PageSize[226 481]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY180MM/80mm * 180mm: "<</PageSize[226 510]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY190MM/80mm * 190mm: "<</PageSize[226 538]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY200MM/80mm * 200mm: "<</PageSize[226 566]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY1500MM/80mm * 1500mm: "<</PageSize[226 4251]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion X80MMY2000MM/80mm * 2000mm: "<</PageSize[226 5668]/HWResolution[203 203]/ImagingBBox null>>setpagedevice"
*PageRegion A4/A4 : "<</PageSize[595 842]/HWResolution[69 69]/ImagingBBox null>>setpagedevice"
*PageRegion Letter/Letter : "<</PageSize[612 792]/HWResolution[67 67]/ImagingBBox null>>setpagedevice"
*PageRegion Legal/Legal : "<</PageSize[612 1008]/HWResolution[67 67]/ImagingBBox null>>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 <</PageSize[5 -2 roll]/HWResolution[203 203]/ImagingBBox null>>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

View file

@ -43,13 +43,14 @@ static void bufferscan_reset(t_bufferscan *bs)
* Allocate and reset a new bufferscan object. * Allocate and reset a new bufferscan object.
* Returns NULL on failure. * 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)); t_bufferscan *bs = (t_bufferscan *)malloc(sizeof(t_bufferscan));
if (!bs) return 0; if (!bs) return 0;
bs->bytesPerRow = bytesperrow; bs->bytesPerRow = bytesperrow;
bs->totalRows = rows; bs->totalRows = rows;
bs->outputFlags = outputFlags;
bs->fp = fp; bs->fp = fp;
bs->rawData = (unsigned char *)malloc(bytesperrow * rows); bs->rawData = (unsigned char *)malloc(bytesperrow * rows);
if (!bs->rawData) 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); fputc(29, bs->fp); fputc('8', bs->fp); fputc('L', bs->fp);
writeLong(totalBytes + 10, bs->fp); writeLong(totalBytes + 10, bs->fp);
fputc('0', bs->fp); fputc('p', 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->bytesPerRow * 8, bs->fp);
writeShort(bs->currentRow, bs->fp); writeShort(bs->currentRow, bs->fp);

View file

@ -38,6 +38,7 @@ typedef struct t_bufferscan {
int bytesPerRow; int bytesPerRow;
int totalRows; int totalRows;
int currentRow; int currentRow;
int outputFlags;
FILE *fp; FILE *fp;
unsigned char *rawData; unsigned char *rawData;
} t_bufferscan; } t_bufferscan;
@ -49,11 +50,19 @@ typedef struct t_bufferscan {
* little endian integers as binary data. * 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, /* 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 * and the output FILE. Returns NULL on failure. Internally, this will allocate memory
* for the buffer. * 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 */ /* destructure the t_bufferscan and its contents. Does NOT close the output FILE */
extern void bufferscan_dispose(t_bufferscan *bs); extern void bufferscan_dispose(t_bufferscan *bs);

View file

@ -129,7 +129,7 @@ struct settings_
int bytesPerScanLine; int bytesPerScanLine;
int bytesPerScanLineStd; int bytesPerScanLineStd;
int doubleMode;
}; };
struct command struct command
@ -150,6 +150,7 @@ inline void debugPrintSettings(struct settings_ * settings)
fprintf(stderr, "DEBUG: pageCutType = %d\n" , settings->pageCutType); fprintf(stderr, "DEBUG: pageCutType = %d\n" , settings->pageCutType);
fprintf(stderr, "DEBUG: docCutType = %d\n" , settings->docCutType); fprintf(stderr, "DEBUG: docCutType = %d\n" , settings->docCutType);
fprintf(stderr, "DEBUG: bytesPerScanLine = %d\n", settings->bytesPerScanLine); fprintf(stderr, "DEBUG: bytesPerScanLine = %d\n", settings->bytesPerScanLine);
fprintf(stderr, "DEBUG: doubleMode = %d\n", settings->doubleMode);
} }
inline void outputCommand(struct command output) inline void outputCommand(struct command output)
@ -315,6 +316,7 @@ inline void initializeSettings(char * commandLineOptionSettings, struct settings
settings->docCutType = getOptionChoiceIndex("DocCutType" , ppd); settings->docCutType = getOptionChoiceIndex("DocCutType" , ppd);
settings->bytesPerScanLine = 80; settings->bytesPerScanLine = 80;
settings->bytesPerScanLineStd = 80; settings->bytesPerScanLineStd = 80;
settings->doubleMode = getOptionChoiceIndex("PixelDoublingType", ppd);
getPageWidthPageHeight(ppd, settings); getPageWidthPageHeight(ppd, settings);
@ -499,7 +501,7 @@ int main(int argc, char *argv[])
bytesPerScanline = settings.bytesPerScanLine < header.cupsBytesPerLine ? bytesPerScanline = settings.bytesPerScanLine < header.cupsBytesPerLine ?
settings.bytesPerScanLine : header.cupsBytesPerLine; settings.bytesPerScanLine : header.cupsBytesPerLine;
bs = bufferscan_new(bytesPerScanline, 256, stdout); bs = bufferscan_new(bytesPerScanline, 256, settings.doubleMode, stdout);
if (!bs) if (!bs)
{ {
CLEANUP; CLEANUP;