diff options
Diffstat (limited to 'src/main/print-olympus.c')
-rw-r--r-- | src/main/print-olympus.c | 1921 |
1 files changed, 1117 insertions, 804 deletions
diff --git a/src/main/print-olympus.c b/src/main/print-olympus.c index c5ad531..7c02b15 100644 --- a/src/main/print-olympus.c +++ b/src/main/print-olympus.c @@ -1,9 +1,9 @@ /* - * "$Id: print-olympus.c,v 1.59 2006/05/28 16:59:05 rlk Exp $" + * "$Id: print-olympus.c,v 1.61.2.1 2007/03/02 12:01:30 rlk Exp $" * - * Print plug-in Olympus driver for the GIMP. + * Print plug-in DyeSub driver (formerly Olympus driver) for the GIMP. * - * Copyright 2003 - 2005 + * Copyright 2003 - 2006 * Michael Mraka (Michael.Mraka@linux.cz) * * The plug-in is based on the code of the RAW plugin for the GIMP of @@ -37,26 +37,42 @@ #include <gutenprint/gutenprint-intl-internal.h> #include <string.h> #include <stdio.h> +#include <limits.h> + +#define STP_DBG_DYESUB STP_DBG_OLYMPUS #ifdef __GNUC__ #define inline __inline__ #endif -#define OLYMPUS_INTERLACE_NONE 0 -#define OLYMPUS_INTERLACE_LINE 1 -#define OLYMPUS_INTERLACE_PLANE 2 - -#define OLYMPUS_FEATURE_NONE 0x00000000 -#define OLYMPUS_FEATURE_FULL_WIDTH 0x00000001 -#define OLYMPUS_FEATURE_FULL_HEIGHT 0x00000002 -#define OLYMPUS_FEATURE_BLOCK_ALIGN 0x00000004 -#define OLYMPUS_FEATURE_BORDERLESS 0x00000008 -#define OLYMPUS_FEATURE_WHITE_BORDER 0x00000010 - -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#define MAX(a,b) (((a) > (b)) ? (a) : (b)) +#define DYESUB_FEATURE_NONE 0x00000000 +#define DYESUB_FEATURE_FULL_WIDTH 0x00000001 +#define DYESUB_FEATURE_FULL_HEIGHT 0x00000002 +#define DYESUB_FEATURE_BLOCK_ALIGN 0x00000004 +#define DYESUB_FEATURE_BORDERLESS 0x00000008 +#define DYESUB_FEATURE_WHITE_BORDER 0x00000010 +#define DYESUB_FEATURE_PLANE_INTERLACE 0x00000020 + +#define DYESUB_PORTRAIT 0 +#define DYESUB_LANDSCAPE 1 + +#ifndef MIN +# define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif /* !MIN */ +#ifndef MAX +# define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif /* !MAX */ +#define PX(pt,dpi) ((pt) * (dpi) / 72) +#define PT(px,dpi) ((px) * 72 / (dpi)) +#define LIST(list_t, list_name, items_t, items_name) \ + static const list_t list_name = \ + { \ + items_name, sizeof(items_name) / sizeof(items_t) \ + } -static const char *zero = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; +#define MAX_INK_CHANNELS 3 +#define MAX_BYTES_PER_CHANNEL 2 +#define SIZE_THRESHOLD 6 typedef struct { @@ -75,12 +91,12 @@ typedef struct { const char* name; int xdpi; int ydpi; -} olymp_resolution_t; +} dyesub_resolution_t; typedef struct { - const olymp_resolution_t *item; + const dyesub_resolution_t *item; size_t n_items; -} olymp_resolution_list_t; +} dyesub_resolution_list_t; typedef struct { const char* name; @@ -91,24 +107,25 @@ typedef struct { int border_pt_right; int border_pt_top; int border_pt_bottom; -} olymp_pagesize_t; + int print_mode; +} dyesub_pagesize_t; typedef struct { - const olymp_pagesize_t *item; + const dyesub_pagesize_t *item; size_t n_items; -} olymp_pagesize_list_t; +} dyesub_pagesize_list_t; typedef struct { const char* res_name; const char* pagesize_name; int width_px; int height_px; -} olymp_printsize_t; +} dyesub_printsize_t; typedef struct { - const olymp_printsize_t *item; + const dyesub_printsize_t *item; size_t n_items; -} olymp_printsize_list_t; +} dyesub_printsize_list_t; typedef struct { @@ -131,18 +148,32 @@ typedef struct int block_max_x, block_max_y; const char* pagesize; const laminate_t* laminate; -} olympus_privdata_t; +} dyesub_privdata_t; -static olympus_privdata_t privdata; +static dyesub_privdata_t privdata; + +typedef struct { + int out_channels; + int ink_channels; + const char *ink_order; + int bytes_per_out_channel; + int bytes_per_ink_channel; + int plane_interlacing; + char empty_byte; + unsigned short **image_data; + int outh_px, outw_px, outt_px, outb_px, outl_px, outr_px; + int imgh_px, imgw_px; + int prnh_px, prnw_px, prnt_px, prnb_px, prnl_px, prnr_px; + int print_mode; /* portrait or landscape */ +} dyesub_print_vars_t; typedef struct /* printer specific parameters */ { int model; /* printer model number from printers.xml*/ const ink_list_t *inks; - const olymp_resolution_list_t *resolution; - const olymp_pagesize_list_t *pages; - const olymp_printsize_list_t *printsize; - int interlacing; /* color interlacing scheme */ + const dyesub_resolution_list_t *resolution; + const dyesub_pagesize_list_t *pages; + const dyesub_printsize_list_t *printsize; int block_size; int features; void (*printer_init_func)(stp_vars_t *); @@ -155,11 +186,12 @@ typedef struct /* printer specific parameters */ const char *adj_magenta; const char *adj_yellow; const laminate_list_t *laminate; -} olympus_cap_t; +} dyesub_cap_t; -static const olympus_cap_t* olympus_get_model_capabilities(int model); -static const laminate_t* olympus_get_laminate_pattern(stp_vars_t *v); +static const dyesub_cap_t* dyesub_get_model_capabilities(int model); +static const laminate_t* dyesub_get_laminate_pattern(stp_vars_t *v); +static void dyesub_nputc(stp_vars_t *v, char byte, int count); static const ink_t cmy_inks[] = @@ -167,76 +199,55 @@ static const ink_t cmy_inks[] = { "CMY", 3, "CMY", "\1\2\3" }, }; -static const ink_list_t cmy_ink_list = -{ - cmy_inks, sizeof(cmy_inks) / sizeof(ink_t) -}; +LIST(ink_list_t, cmy_ink_list, ink_t, cmy_inks); static const ink_t ymc_inks[] = { { "CMY", 3, "CMY", "\3\2\1" }, }; -static const ink_list_t ymc_ink_list = -{ - ymc_inks, sizeof(ymc_inks) / sizeof(ink_t) -}; +LIST(ink_list_t, ymc_ink_list, ink_t, ymc_inks); static const ink_t rgb_inks[] = { { "RGB", 3, "RGB", "\1\2\3" }, }; -static const ink_list_t rgb_ink_list = -{ - rgb_inks, sizeof(rgb_inks) / sizeof(ink_t) -}; +LIST(ink_list_t, rgb_ink_list, ink_t, rgb_inks); static const ink_t bgr_inks[] = { { "RGB", 3, "RGB", "\3\2\1" }, }; -static const ink_list_t bgr_ink_list = -{ - bgr_inks, sizeof(bgr_inks) / sizeof(ink_t) -}; +LIST(ink_list_t, bgr_ink_list, ink_t, bgr_inks); /* Olympus P-10 */ -static const olymp_resolution_t res_320dpi[] = +static const dyesub_resolution_t res_310dpi[] = { - { "320x320", 320, 320}, + { "310x310", 310, 310}, }; -static const olymp_resolution_list_t res_320dpi_list = -{ - res_320dpi, sizeof(res_320dpi) / sizeof(olymp_resolution_t) -}; +LIST(dyesub_resolution_list_t, res_310dpi_list, dyesub_resolution_t, res_310dpi); -static const olymp_pagesize_t p10_page[] = +static const dyesub_pagesize_t p10_page[] = { - { "w288h432", "4 x 6", -1, -1, 0, 0, 16, 0}, /* 4x6" */ - { "B7", "3.5 x 5", -1, -1, 0, 0, 4, 0}, /* 3.5x5" */ - { "Custom", NULL, -1, -1, 28, 28, 48, 48}, + { "w288h432", "4 x 6", 298, 430, 0, 0, 0, 0, DYESUB_PORTRAIT}, /* 4x6" */ + { "B7", "3.5 x 5", 266, 370, 0, 0, 0, 0, DYESUB_PORTRAIT}, /* 3.5x5" */ + { "Custom", NULL, 298, 430, 28, 28, 48, 48, DYESUB_PORTRAIT}, }; -static const olymp_pagesize_list_t p10_page_list = -{ - p10_page, sizeof(p10_page) / sizeof(olymp_pagesize_t) -}; +LIST(dyesub_pagesize_list_t, p10_page_list, dyesub_pagesize_t, p10_page); -static const olymp_printsize_t p10_printsize[] = +static const dyesub_printsize_t p10_printsize[] = { - { "320x320", "w288h432", 1280, 1848}, - { "320x320", "B7", 1144, 1591}, - { "320x320", "Custom", 1280, 1848}, + { "310x310", "w288h432", 1280, 1848}, + { "310x310", "B7", 1144, 1591}, + { "310x310", "Custom", 1280, 1848}, }; -static const olymp_printsize_list_t p10_printsize_list = -{ - p10_printsize, sizeof(p10_printsize) / sizeof(olymp_printsize_t) -}; +LIST(dyesub_printsize_list_t, p10_printsize_list, dyesub_printsize_t, p10_printsize); static void p10_printer_init_func(stp_vars_t *v) { @@ -266,34 +277,32 @@ static const laminate_t p10_laminate[] = {"None", N_("None"), {1, "\x02"}}, }; -static const laminate_list_t p10_laminate_list = -{ - p10_laminate, sizeof(p10_laminate) / sizeof(laminate_t) -}; +LIST(laminate_list_t, p10_laminate_list, laminate_t, p10_laminate); /* Olympus P-200 series */ -static const olymp_pagesize_t p200_page[] = +static const dyesub_resolution_t res_320dpi[] = { - { "ISOB7", "80x125mm", -1, -1, 16, 17, 33, 33}, - { "Custom", NULL, -1, -1, 16, 17, 33, 33}, + { "320x320", 320, 320}, }; -static const olymp_pagesize_list_t p200_page_list = +LIST(dyesub_resolution_list_t, res_320dpi_list, dyesub_resolution_t, res_320dpi); + +static const dyesub_pagesize_t p200_page[] = { - p200_page, sizeof(p200_page) / sizeof(olymp_pagesize_t) + { "ISOB7", "80x125mm", -1, -1, 16, 17, 33, 33, DYESUB_PORTRAIT}, + { "Custom", NULL, -1, -1, 16, 17, 33, 33, DYESUB_PORTRAIT}, }; -static const olymp_printsize_t p200_printsize[] = +LIST(dyesub_pagesize_list_t, p200_page_list, dyesub_pagesize_t, p200_page); + +static const dyesub_printsize_t p200_printsize[] = { { "320x320", "ISOB7", 960, 1280}, { "320x320", "Custom", 960, 1280}, }; -static const olymp_printsize_list_t p200_printsize_list = -{ - p200_printsize, sizeof(p200_printsize) / sizeof(olymp_printsize_t) -}; +LIST(dyesub_printsize_list_t, p200_printsize_list, dyesub_printsize_t, p200_printsize); static void p200_printer_init_func(stp_vars_t *v) { @@ -327,40 +336,31 @@ static const char p200_adj_any[] = /* Olympus P-300 series */ -static const olymp_resolution_t p300_res[] = +static const dyesub_resolution_t p300_res[] = { { "306x306", 306, 306}, { "153x153", 153, 153}, }; -static const olymp_resolution_list_t p300_res_list = -{ - p300_res, sizeof(p300_res) / sizeof(olymp_resolution_t) -}; +LIST(dyesub_resolution_list_t, p300_res_list, dyesub_resolution_t, p300_res); -static const olymp_pagesize_t p300_page[] = +static const dyesub_pagesize_t p300_page[] = { - { "A6", NULL, -1, -1, 28, 28, 48, 48}, - { "Custom", NULL, -1, -1, 28, 28, 48, 48}, + { "A6", NULL, -1, -1, 28, 28, 48, 48, DYESUB_PORTRAIT}, + { "Custom", NULL, -1, -1, 28, 28, 48, 48, DYESUB_PORTRAIT}, }; -static const olymp_pagesize_list_t p300_page_list = -{ - p300_page, sizeof(p300_page) / sizeof(olymp_pagesize_t) -}; +LIST(dyesub_pagesize_list_t, p300_page_list, dyesub_pagesize_t, p300_page); -static const olymp_printsize_t p300_printsize[] = +static const dyesub_printsize_t p300_printsize[] = { { "306x306", "A6", 1024, 1376}, { "153x153", "A6", 512, 688}, { "306x306", "Custom", 1024, 1376}, - { "153x153", "Custom", 1024, 1376}, + { "153x153", "Custom", 512, 688}, }; -static const olymp_printsize_list_t p300_printsize_list = -{ - p300_printsize, sizeof(p300_printsize) / sizeof(olymp_printsize_t) -}; +LIST(dyesub_printsize_list_t, p300_printsize_list, dyesub_printsize_t, p300_printsize); static void p300_printer_init_func(stp_vars_t *v) { @@ -374,7 +374,7 @@ static void p300_plane_end_func(stp_vars_t *v) { const char *c = "CMY"; stp_zprintf(v, "\033\033\033P%cS", c[privdata.plane-1]); - stp_deprintf(STP_DBG_OLYMPUS, "olympus: p300_plane_end_func: %c\n", + stp_deprintf(STP_DBG_DYESUB, "dyesub: p300_plane_end_func: %c\n", c[privdata.plane-1]); } @@ -387,7 +387,7 @@ static void p300_block_init_func(stp_vars_t *v) stp_put16_be(privdata.block_max_y, v); stp_put16_be(privdata.block_max_x, v); - stp_deprintf(STP_DBG_OLYMPUS, "olympus: p300_block_init_func: %d-%dx%d-%d\n", + stp_deprintf(STP_DBG_DYESUB, "dyesub: p300_block_init_func: %d-%dx%d-%d\n", privdata.block_min_x, privdata.block_max_x, privdata.block_min_y, privdata.block_max_y); } @@ -433,30 +433,24 @@ static const char p300_adj_yellow[] = /* Olympus P-400 series */ -static const olymp_resolution_t res_314dpi[] = +static const dyesub_resolution_t res_314dpi[] = { { "314x314", 314, 314}, }; -static const olymp_resolution_list_t res_314dpi_list = -{ - res_314dpi, sizeof(res_314dpi) / sizeof(olymp_resolution_t) -}; +LIST(dyesub_resolution_list_t, res_314dpi_list, dyesub_resolution_t, res_314dpi); -static const olymp_pagesize_t p400_page[] = +static const dyesub_pagesize_t p400_page[] = { - { "A4", NULL, -1, -1, 22, 22, 54, 54}, - { "c8x10", "A5 wide", -1, -1, 58, 59, 84, 85}, - { "C6", "2 Postcards (A4)", -1, -1, 9, 9, 9, 9}, - { "Custom", NULL, -1, -1, 22, 22, 54, 54}, + { "A4", NULL, -1, -1, 22, 22, 54, 54, DYESUB_PORTRAIT}, + { "c8x10", "A5 wide", -1, -1, 58, 59, 84, 85, DYESUB_PORTRAIT}, + { "C6", "2 Postcards (A4)", -1, -1, 9, 9, 9, 9, DYESUB_PORTRAIT}, + { "Custom", NULL, -1, -1, 22, 22, 54, 54, DYESUB_PORTRAIT}, }; -static const olymp_pagesize_list_t p400_page_list = -{ - p400_page, sizeof(p400_page) / sizeof(olymp_pagesize_t) -}; +LIST(dyesub_pagesize_list_t, p400_page_list, dyesub_pagesize_t, p400_page); -static const olymp_printsize_t p400_printsize[] = +static const dyesub_printsize_t p400_printsize[] = { { "314x314", "A4", 2400, 3200}, { "314x314", "c8x10", 2000, 2400}, @@ -464,20 +458,17 @@ static const olymp_printsize_t p400_printsize[] = { "314x314", "Custom", 2400, 3200}, }; -static const olymp_printsize_list_t p400_printsize_list = -{ - p400_printsize, sizeof(p400_printsize) / sizeof(olymp_printsize_t) -}; +LIST(dyesub_printsize_list_t, p400_printsize_list, dyesub_printsize_t, p400_printsize); static void p400_printer_init_func(stp_vars_t *v) { int wide = (strcmp(privdata.pagesize, "c8x10") == 0 || strcmp(privdata.pagesize, "C6") == 0); - stp_zprintf(v, "\033ZQ"); stp_zfwrite(zero, 1, 61, v); - stp_zprintf(v, "\033FP"); stp_zfwrite(zero, 1, 61, v); + stp_zprintf(v, "\033ZQ"); dyesub_nputc(v, '\0', 61); + stp_zprintf(v, "\033FP"); dyesub_nputc(v, '\0', 61); stp_zprintf(v, "\033ZF"); - stp_putc((wide ? '\x40' : '\x00'), v); stp_zfwrite(zero, 1, 60, v); + stp_putc((wide ? '\x40' : '\x00'), v); dyesub_nputc(v, '\0', 60); stp_zprintf(v, "\033ZS"); if (wide) { @@ -489,18 +480,18 @@ static void p400_printer_init_func(stp_vars_t *v) stp_put16_be(privdata.xsize, v); stp_put16_be(privdata.ysize, v); } - stp_zfwrite(zero, 1, 57, v); - stp_zprintf(v, "\033ZP"); stp_zfwrite(zero, 1, 61, v); + dyesub_nputc(v, '\0', 57); + stp_zprintf(v, "\033ZP"); dyesub_nputc(v, '\0', 61); } static void p400_plane_init_func(stp_vars_t *v) { - stp_zprintf(v, "\033ZC"); stp_zfwrite(zero, 1, 61, v); + stp_zprintf(v, "\033ZC"); dyesub_nputc(v, '\0', 61); } static void p400_plane_end_func(stp_vars_t *v) { - stp_zprintf(v, "\033P"); stp_zfwrite(zero, 1, 62, v); + stp_zprintf(v, "\033P"); dyesub_nputc(v, '\0', 62); } static void p400_block_init_func(stp_vars_t *v) @@ -523,7 +514,7 @@ static void p400_block_init_func(stp_vars_t *v) stp_put16_be(privdata.block_max_x - privdata.block_min_x + 1, v); stp_put16_be(privdata.block_max_y - privdata.block_min_y + 1, v); } - stp_zfwrite(zero, 1, 53, v); + dyesub_nputc(v, '\0', 53); } static const char p400_adj_cyan[] = @@ -567,21 +558,19 @@ static const char p400_adj_yellow[] = /* Olympus P-440 series */ -static const olymp_pagesize_t p440_page[] = +/* FIXME: colors - BGR instead of RGB ?!? */ +static const dyesub_pagesize_t p440_page[] = { - { "A4", NULL, -1, -1, 10, 9, 54, 54}, - { "c8x10", "A5 wide", -1, -1, 58, 59, 72, 72}, - { "C6", "2 Postcards (A4)", -1, -1, 9, 9, 9, 9}, - { "w255h581", "A6 wide", -1, -1, 25, 25, 25, 24}, - { "Custom", NULL, -1, -1, 22, 22, 54, 54}, + { "A4", NULL, -1, -1, 10, 9, 54, 54, DYESUB_PORTRAIT}, + { "c8x10", "A5 wide", -1, -1, 58, 59, 72, 72, DYESUB_PORTRAIT}, + { "C6", "2 Postcards (A4)", -1, -1, 9, 9, 9, 9, DYESUB_PORTRAIT}, + { "w255h581", "A6 wide", -1, -1, 25, 25, 25, 24, DYESUB_PORTRAIT}, + { "Custom", NULL, -1, -1, 22, 22, 54, 54, DYESUB_PORTRAIT}, }; -static const olymp_pagesize_list_t p440_page_list = -{ - p440_page, sizeof(p440_page) / sizeof(olymp_pagesize_t) -}; +LIST(dyesub_pagesize_list_t, p440_page_list, dyesub_pagesize_t, p440_page); -static const olymp_printsize_t p440_printsize[] = +static const dyesub_printsize_t p440_printsize[] = { { "314x314", "A4", 2508, 3200}, { "314x314", "c8x10", 2000, 2508}, @@ -590,25 +579,22 @@ static const olymp_printsize_t p440_printsize[] = { "314x314", "Custom", 2508, 3200}, }; -static const olymp_printsize_list_t p440_printsize_list = -{ - p440_printsize, sizeof(p440_printsize) / sizeof(olymp_printsize_t) -}; +LIST(dyesub_printsize_list_t, p440_printsize_list, dyesub_printsize_t, p440_printsize); static void p440_printer_init_func(stp_vars_t *v) { int wide = ! (strcmp(privdata.pagesize, "A4") == 0 || strcmp(privdata.pagesize, "Custom") == 0); - stp_zprintf(v, "\033FP"); stp_zfwrite(zero, 1, 61, v); + stp_zprintf(v, "\033FP"); dyesub_nputc(v, '\0', 61); stp_zprintf(v, "\033Y"); stp_zfwrite((privdata.laminate->seq).data, 1, (privdata.laminate->seq).bytes, v); /* laminate */ - stp_zfwrite(zero, 1, 61, v); - stp_zprintf(v, "\033FC"); stp_zfwrite(zero, 1, 61, v); + dyesub_nputc(v, '\0', 61); + stp_zprintf(v, "\033FC"); dyesub_nputc(v, '\0', 61); stp_zprintf(v, "\033ZF"); - stp_putc((wide ? '\x40' : '\x00'), v); stp_zfwrite(zero, 1, 60, v); - stp_zprintf(v, "\033N\1"); stp_zfwrite(zero, 1, 61, v); + stp_putc((wide ? '\x40' : '\x00'), v); dyesub_nputc(v, '\0', 60); + stp_zprintf(v, "\033N\1"); dyesub_nputc(v, '\0', 61); stp_zprintf(v, "\033ZS"); if (wide) { @@ -620,16 +606,16 @@ static void p440_printer_init_func(stp_vars_t *v) stp_put16_be(privdata.xsize, v); stp_put16_be(privdata.ysize, v); } - stp_zfwrite(zero, 1, 57, v); + dyesub_nputc(v, '\0', 57); if (strcmp(privdata.pagesize, "C6") == 0) { - stp_zprintf(v, "\033ZC"); stp_zfwrite(zero, 1, 61, v); + stp_zprintf(v, "\033ZC"); dyesub_nputc(v, '\0', 61); } } static void p440_printer_end_func(stp_vars_t *v) { - stp_zprintf(v, "\033P"); stp_zfwrite(zero, 1, 62, v); + stp_zprintf(v, "\033P"); dyesub_nputc(v, '\0', 62); } static void p440_block_init_func(stp_vars_t *v) @@ -652,61 +638,145 @@ static void p440_block_init_func(stp_vars_t *v) stp_put16_be(privdata.block_max_x - privdata.block_min_x + 1, v); stp_put16_be(privdata.block_max_y - privdata.block_min_y + 1, v); } - stp_zfwrite(zero, 1, 53, v); + dyesub_nputc(v, '\0', 53); } static void p440_block_end_func(stp_vars_t *v) { int pad = (64 - (((privdata.block_max_x - privdata.block_min_x + 1) * (privdata.block_max_y - privdata.block_min_y + 1) * 3) % 64)) % 64; - stp_deprintf(STP_DBG_OLYMPUS, - "olympus: max_x %d min_x %d max_y %d min_y %d\n", + stp_deprintf(STP_DBG_DYESUB, + "dyesub: max_x %d min_x %d max_y %d min_y %d\n", privdata.block_max_x, privdata.block_min_x, privdata.block_max_y, privdata.block_min_y); - stp_deprintf(STP_DBG_OLYMPUS, "olympus: olympus-p440 padding=%d\n", pad); - stp_zfwrite(zero, 1, pad, v); + stp_deprintf(STP_DBG_DYESUB, "dyesub: olympus-p440 padding=%d\n", pad); + dyesub_nputc(v, '\0', pad); } -/* Canon CP-100 series */ -static const olymp_pagesize_t cpx00_page[] = +/* Olympus P-S100 */ +/* FIXME: colors - BGR instead of RGB ?!? */ +static const dyesub_pagesize_t ps100_page[] = { - { "Postcard", "Postcard 148x100mm", -1, -1, 13, 13, 16, 18}, - { "w253h337", "CP_L 89x119mm", -1, -1, 13, 13, 15, 15}, - { "w244h155", "Card 54x86mm", -1, -1, 15, 15, 13, 13}, - { "Custom", NULL, -1, -1, 13, 13, 16, 18}, + { "w288h432", "4 x 6", 296, 426, 0, 0, 0, 0, DYESUB_PORTRAIT},/* 4x6" */ + { "B7", "3.5 x 5", 264, 366, 0, 0, 0, 0, DYESUB_PORTRAIT}, /* 3.5x5" */ + { "Custom", NULL, 296, 426, 0, 0, 0, 0, DYESUB_PORTRAIT}, }; -static const olymp_pagesize_list_t cpx00_page_list = +LIST(dyesub_pagesize_list_t, ps100_page_list, dyesub_pagesize_t, ps100_page); + +static const dyesub_printsize_t ps100_printsize[] = { - cpx00_page, sizeof(cpx00_page) / sizeof(olymp_pagesize_t) + { "306x306", "w288h432", 1254, 1808}, + { "306x306", "B7", 1120, 1554}, + { "306x306", "Custom", 1254, 1808}, }; -static const olymp_printsize_t cpx00_printsize[] = +LIST(dyesub_printsize_list_t, ps100_printsize_list, dyesub_printsize_t, ps100_printsize); + +static void ps100_printer_init_func(stp_vars_t *v) { - { "314x314", "Postcard", 1232, 1808}, - { "314x314", "w253h337", 1100, 1456}, - { "314x314", "w244h155", 1040, 672}, - { "314x314", "Custom", 1232, 1808}, + stp_zprintf(v, "\033U"); dyesub_nputc(v, '\0', 62); + + /* stp_zprintf(v, "\033ZC"); dyesub_nputc(v, '\0', 61); */ + + stp_zprintf(v, "\033W"); dyesub_nputc(v, '\0', 62); + + stp_zfwrite("\x30\x2e\x00\xa2\x00\xa0\x00\xa0", 1, 8, v); + stp_put16_be(privdata.ysize, v); /* paper height (px) */ + stp_put16_be(privdata.xsize, v); /* paper width (px) */ + dyesub_nputc(v, '\0', 3); + stp_putc('\1', v); /* number of copies */ + dyesub_nputc(v, '\0', 8); + stp_putc('\1', v); + dyesub_nputc(v, '\0', 15); + stp_putc('\6', v); + dyesub_nputc(v, '\0', 23); + + stp_zfwrite("\033ZT\0", 1, 4, v); + stp_put16_be(0, v); /* image width offset (px) */ + stp_put16_be(0, v); /* image height offset (px) */ + stp_put16_be(privdata.xsize, v); /* image width (px) */ + stp_put16_be(privdata.ysize, v); /* image height (px) */ + dyesub_nputc(v, '\0', 52); +} + +static void ps100_printer_end_func(stp_vars_t *v) +{ + int pad = (64 - (((privdata.block_max_x - privdata.block_min_x + 1) + * (privdata.block_max_y - privdata.block_min_y + 1) * 3) % 64)) % 64; + stp_deprintf(STP_DBG_DYESUB, + "dyesub: max_x %d min_x %d max_y %d min_y %d\n", + privdata.block_max_x, privdata.block_min_x, + privdata.block_max_y, privdata.block_min_y); + stp_deprintf(STP_DBG_DYESUB, "dyesub: olympus-ps100 padding=%d\n", pad); + dyesub_nputc(v, '\0', pad); /* padding to 64B blocks */ + + stp_zprintf(v, "\033PY"); dyesub_nputc(v, '\0', 61); + stp_zprintf(v, "\033u"); dyesub_nputc(v, '\0', 62); +} + + +/* Canon CP-10 */ +static const dyesub_resolution_t res_300dpi[] = +{ + { "300x300", 300, 300}, +}; + +LIST(dyesub_resolution_list_t, res_300dpi_list, dyesub_resolution_t, res_300dpi); + +static const dyesub_pagesize_t cp10_page[] = +{ + { "w155h244", "Card 54x86mm", 159, 250, 6, 6, 29, 29, DYESUB_PORTRAIT}, + { "Custom", NULL, -1, -1, 6, 6, 29, 29, DYESUB_PORTRAIT}, }; -static const olymp_printsize_list_t cpx00_printsize_list = +LIST(dyesub_pagesize_list_t, cp10_page_list, dyesub_pagesize_t, cp10_page); + +static const dyesub_printsize_t cp10_printsize[] = +{ + { "300x300", "w155h244", 662, 1040}, + { "300x300", "Custom", 662, 1040}, +}; + +LIST(dyesub_printsize_list_t, cp10_printsize_list, dyesub_printsize_t, cp10_printsize); + + +/* Canon CP-100 series */ +static const dyesub_pagesize_t cpx00_page[] = +{ + { "Postcard", "Postcard 100x148mm", 296, 434, 13, 13, 16, 19, DYESUB_PORTRAIT}, + { "w253h337", "CP_L 89x119mm", 264, 350, 13, 13, 15, 15, DYESUB_PORTRAIT}, + { "w155h244", "Card 54x86mm", 162, 250, 13, 13, 15, 15, DYESUB_LANDSCAPE}, + { "Custom", NULL, 296, 434, 13, 13, 16, 19, DYESUB_PORTRAIT}, +}; + +LIST(dyesub_pagesize_list_t, cpx00_page_list, dyesub_pagesize_t, cpx00_page); + +static const dyesub_printsize_t cpx00_printsize[] = { - cpx00_printsize, sizeof(cpx00_printsize) / sizeof(olymp_printsize_t) + { "300x300", "Postcard", 1232, 1808}, + { "300x300", "w253h337", 1100, 1456}, + { "300x300", "w155h244", 672, 1040}, + { "300x300", "Custom", 1232, 1808}, }; +LIST(dyesub_printsize_list_t, cpx00_printsize_list, dyesub_printsize_t, cpx00_printsize); + static void cpx00_printer_init_func(stp_vars_t *v) { char pg = (strcmp(privdata.pagesize, "Postcard") == 0 ? '\1' : (strcmp(privdata.pagesize, "w253h337") == 0 ? '\2' : - (strcmp(privdata.pagesize, "w244h155") == 0 ? '\3' : + (strcmp(privdata.pagesize, "w155h244") == 0 ? + (strcmp(stp_get_driver(v),"canon-cp10") == 0 ? + '\0' : '\3' ) : (strcmp(privdata.pagesize, "w283h566") == 0 ? '\4' : '\1' )))); stp_put16_be(0x4000, v); stp_putc('\0', v); stp_putc(pg, v); - stp_zfwrite(zero, 1, 8, v); + dyesub_nputc(v, '\0', 8); } static void cpx00_plane_init_func(stp_vars_t *v) @@ -714,7 +784,7 @@ static void cpx00_plane_init_func(stp_vars_t *v) stp_put16_be(0x4001, v); stp_put16_le(3 - privdata.plane, v); stp_put32_le(privdata.xsize * privdata.ysize, v); - stp_zfwrite(zero, 1, 4, v); + dyesub_nputc(v, '\0', 4); } static const char cpx00_adj_cyan[] = @@ -758,79 +828,139 @@ static const char cpx00_adj_yellow[] = /* Canon CP-220 series */ -static const olymp_pagesize_t cp220_page[] = +static const dyesub_pagesize_t cp220_page[] = { - { "Postcard", "Postcard 148x100mm", -1, -1, 13, 13, 16, 18}, - { "w253h337", "CP_L 89x119mm", -1, -1, 13, 13, 15, 15}, - { "w244h155", "Card 54x86mm", -1, -1, 15, 15, 13, 13}, - { "w283h566", "Wide 200x100mm", -1, -1, 13, 13, 20, 20}, - { "Custom", NULL, -1, -1, 13, 13, 16, 18}, + { "Postcard", "Postcard 100x148mm", 296, 434, 13, 13, 16, 19, DYESUB_PORTRAIT}, + { "w253h337", "CP_L 89x119mm", 264, 350, 13, 13, 15, 15, DYESUB_PORTRAIT}, + { "w155h244", "Card 54x86mm", 162, 250, 13, 13, 15, 15, DYESUB_LANDSCAPE}, + { "w283h566", "Wide 100x200mm", 296, 580, 13, 13, 20, 20, DYESUB_PORTRAIT}, + { "Custom", NULL, 296, 434, 13, 13, 16, 19, DYESUB_PORTRAIT}, }; -static const olymp_pagesize_list_t cp220_page_list = +LIST(dyesub_pagesize_list_t, cp220_page_list, dyesub_pagesize_t, cp220_page); + +static const dyesub_printsize_t cp220_printsize[] = { - cp220_page, sizeof(cp220_page) / sizeof(olymp_pagesize_t) + { "300x300", "Postcard", 1232, 1808}, + { "300x300", "w253h337", 1100, 1456}, + { "300x300", "w155h244", 672, 1040}, + { "300x300", "w283h566", 1232, 2416}, + { "300x300", "Custom", 1232, 1808}, }; -static const olymp_printsize_t cp220_printsize[] = +LIST(dyesub_printsize_list_t, cp220_printsize_list, dyesub_printsize_t, cp220_printsize); + + +/* Sony DPP-EX5, DPP-EX7 */ +static const dyesub_resolution_t res_403dpi[] = { - { "314x314", "Postcard", 1232, 1808}, - { "314x314", "w253h337", 1100, 1456}, - { "314x314", "w244h155", 1040, 672}, - { "314x314", "w283h566", 1232, 2416}, - { "314x314", "Custom", 1232, 1808}, + { "403x403", 403, 403}, }; -static const olymp_printsize_list_t cp220_printsize_list = +LIST(dyesub_resolution_list_t, res_403dpi_list, dyesub_resolution_t, res_403dpi); + +/* only Postcard pagesize is supported */ +static const dyesub_pagesize_t dppex5_page[] = { - cp220_printsize, sizeof(cp220_printsize) / sizeof(olymp_printsize_t) + { "w288h432", "Postcard", PT(1664,403)+1, PT(2466,403)+1, 13, 14, 18, 17, + DYESUB_PORTRAIT}, + { "Custom", NULL, PT(1664,403)+1, PT(2466,403)+1, 13, 14, 18, 17, + DYESUB_PORTRAIT}, }; +LIST(dyesub_pagesize_list_t, dppex5_page_list, dyesub_pagesize_t, dppex5_page); -/* Sony UP-DP10 */ -static const olymp_resolution_t updp10_res[] = +static const dyesub_printsize_t dppex5_printsize[] = { - { "300x300", 300, 300}, + { "403x403", "w288h432", 1664, 2466}, + { "403x403", "Custom", 1664, 2466}, }; -static const olymp_resolution_list_t updp10_res_list = +LIST(dyesub_printsize_list_t, dppex5_printsize_list, dyesub_printsize_t, dppex5_printsize); + +static void dppex5_printer_init(stp_vars_t *v) { - updp10_res, sizeof(updp10_res) / sizeof(olymp_resolution_t) -}; + stp_zfwrite("DPEX\0\0\0\x80", 1, 8, v); + stp_zfwrite("DPEX\0\0\0\x82", 1, 8, v); + stp_zfwrite("DPEX\0\0\0\x84", 1, 8, v); + stp_put32_be(privdata.xsize, v); + stp_put32_be(privdata.ysize, v); + stp_zfwrite("S\0o\0n\0y\0 \0D\0P\0P\0-\0E\0X\0\x35\0", 1, 24, v); + dyesub_nputc(v, '\0', 40); + stp_zfwrite("\1\4\0\4\xdc\0\x24\0\3\3\1\0\1\0\x82\0", 1, 16, v); + stp_zfwrite("\xf4\5\xf8\3\x64\0\1\0\x0e\0\x93\1\2\0\1\0", 1, 16, v); + stp_zfwrite("\x93\1\1\0\0\0", 1, 6, v); + stp_zfwrite("P\0o\0s\0t\0 \0c\0a\0r\0d\0", 1, 18, v); + dyesub_nputc(v, '\0', 46); + stp_zfwrite("\x93\1\x18", 1, 3, v); + dyesub_nputc(v, '\0', 19); + stp_zfwrite("\2\0\0\0\3\0\0\0\1\0\0\0\1", 1, 13, v); + dyesub_nputc(v, '\0', 19); + stp_zprintf(v, "5EPD"); + dyesub_nputc(v, '\0', 4); + stp_zfwrite((privdata.laminate->seq).data, 1, + (privdata.laminate->seq).bytes, v); /*laminate pattern*/ + stp_zfwrite("\0d\0d\0d", 1, 6, v); + dyesub_nputc(v, '\0', 21); +} + +static void dppex5_block_init(stp_vars_t *v) +{ + stp_zfwrite("DPEX\0\0\0\x85", 1, 8, v); + stp_put32_be((privdata.block_max_x - privdata.block_min_x + 1) + * (privdata.block_max_y - privdata.block_min_y + 1) * 3, v); +} -static const olymp_pagesize_t updp10_page[] = +static void dppex5_printer_end(stp_vars_t *v) { - { "w288h432", "UPC-10P23 (2:3)", -1, -1, 12, 12, 18, 18}, - { "w288h387", "UPC-10P34 (3:4)", -1, -1, 12, 12, 16, 16}, - { "w288h432", "UPC-10S01 (Sticker)", -1, -1, 12, 12, 18, 18}, - { "Custom", NULL, -1, -1, 12, 12, 0, 0}, + stp_zfwrite("DPEX\0\0\0\x83", 1, 8, v); + stp_zfwrite("DPEX\0\0\0\x81", 1, 8, v); +} + +static const laminate_t dppex5_laminate[] = +{ + {"Glossy", N_("Glossy"), {1, "\x00"}}, + {"Texture", N_("Texture"), {1, "\x01"}}, }; -static const olymp_pagesize_list_t updp10_page_list = +LIST(laminate_list_t, dppex5_laminate_list, laminate_t, dppex5_laminate); + + +/* Sony UP-DP10 */ +static const dyesub_pagesize_t updp10_page[] = { - updp10_page, sizeof(updp10_page) / sizeof(olymp_pagesize_t) + { "w288h432", "UPC-10P23 (2:3)", -1, -1, 12, 12, 18, 18, DYESUB_LANDSCAPE}, + { "w288h387", "UPC-10P34 (3:4)", -1, 384, 12, 12, 16, 16, DYESUB_LANDSCAPE}, + { "w288h432", "UPC-10S01 (Sticker)", -1, -1, 12, 12, 18, 18, DYESUB_LANDSCAPE}, + { "Custom", NULL, -1, -1, 12, 12, 0, 0, DYESUB_LANDSCAPE}, }; -static const olymp_printsize_t updp10_printsize[] = +LIST(dyesub_pagesize_list_t, updp10_page_list, dyesub_pagesize_t, updp10_page); + +static const dyesub_printsize_t updp10_printsize[] = { { "300x300", "w288h432", 1200, 1800}, { "300x300", "w288h387", 1200, 1600}, { "300x300", "Custom", 1200, 1800}, }; -static const olymp_printsize_list_t updp10_printsize_list = -{ - updp10_printsize, sizeof(updp10_printsize) / sizeof(olymp_printsize_t) -}; +LIST(dyesub_printsize_list_t, updp10_printsize_list, dyesub_printsize_t, updp10_printsize); static void updp10_printer_init_func(stp_vars_t *v) { stp_zfwrite("\x98\xff\xff\xff\xff\xff\xff\xff" - "\x14\x00\x00\x00\x1b\x15\x00\x00" - "\x00\x0d\x00\x00\x00\x00\x00\xc7" - "\x00\x00\x00\x00", 1, 28, v); + "\x09\x00\x00\x00\x1b\xee\x00\x00" + "\x00\x04", 1, 34, v); + stp_zfwrite((privdata.laminate->seq).data, 1, + (privdata.laminate->seq).bytes, v); /*laminate pattern*/ + stp_zfwrite("\x00\x00\x00\x00", 1, 4, v); + stp_put16_be(privdata.ysize, v); stp_put16_be(privdata.xsize, v); + stp_zfwrite("\x14\x00\x00\x00\x1b\x15\x00\x00" + "\x00\x0d\x00\x00\x00\x00\x00\x07" + "\x00\x00\x00\x00", 1, 20, v); stp_put16_be(privdata.ysize, v); + stp_put16_be(privdata.xsize, v); stp_put32_le(privdata.xsize*privdata.ysize*3+11, v); stp_zfwrite("\x1b\xea\x00\x00\x00\x00", 1, 6, v); stp_put32_be(privdata.xsize*privdata.ysize*3, v); @@ -839,19 +969,10 @@ static void updp10_printer_init_func(stp_vars_t *v) static void updp10_printer_end_func(stp_vars_t *v) { - stp_zfwrite("\x12\x00\x00\x00\x1b\xe1\x00\x00" - "\x00\xb0\x00\x00\04", 1, 13, v); - stp_zfwrite((privdata.laminate->seq).data, 1, - (privdata.laminate->seq).bytes, v); /*laminate pattern*/ - stp_zfwrite("\x00\x00\x00\x00" , 1, 4, v); - stp_put16_be(privdata.ysize, v); - stp_put16_be(privdata.xsize, v); - stp_zfwrite("\xff\xff\xff\xff\x09\x00\x00\x00" - "\x1b\xee\x00\x00\x00\x02\x00\x00" - "\x01\x07\x00\x00\x00\x1b\x0a\x00" - "\x00\x00\x00\x00\xfd\xff\xff\xff" - "\xff\xff\xff\xff\xf8\xff\xff\xff" - , 1, 40, v); + stp_zfwrite("\xff\xff\xff\xff\x07\x00\x00\x00" + "\x1b\x0a\x00\x00\x00\x00\x00\xfd" + "\xff\xff\xff\xff\xff\xff\xff" + , 1, 23, v); } static const laminate_t updp10_laminate[] = @@ -861,10 +982,7 @@ static const laminate_t updp10_laminate[] = {"Matte", N_("Matte"), {1, "\x0c"}}, }; -static const laminate_list_t updp10_laminate_list = -{ - updp10_laminate, sizeof(updp10_laminate) / sizeof(laminate_t) -}; +LIST(laminate_list_t, updp10_laminate_list, laminate_t, updp10_laminate); static const char updp10_adj_cyan[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" @@ -909,45 +1027,94 @@ static const char updp10_adj_yellow[] = "</gutenprint>\n"; -/* Sony UP-DR150 */ -static const olymp_resolution_t updr150_res[] = +/* Sony UP-DR100 */ +static const dyesub_pagesize_t updr100_page[] = { - { "346x346", 346, 346}, + { "w288h432", "4x6", 298, 442, 0, 0, 0, 0, DYESUB_LANDSCAPE}, + { "B7", "3.5x5", 261, 369, 0, 0, 0, 0, DYESUB_LANDSCAPE}, + { "w360h504", "5x7", 369, 514, 0, 0, 0, 0, DYESUB_PORTRAIT}, + { "w432h576", "6x8", 442, 588, 0, 0, 0, 0, DYESUB_PORTRAIT}, + { "Custom", NULL, 298, 442, 0, 0, 0, 0, DYESUB_LANDSCAPE}, }; -static const olymp_resolution_list_t updr150_res_list = +LIST(dyesub_pagesize_list_t, updr100_page_list, dyesub_pagesize_t, updr100_page); + +static const dyesub_printsize_t updr100_printsize[] = { - updr150_res, sizeof(updr150_res) / sizeof(olymp_resolution_t) + { "334x334", "w288h432", 1382, 2048}, + { "334x334", "B7", 1210, 1710}, + { "334x334", "w360h504", 1710, 2380}, + { "334x334", "w432h576", 2048, 2724}, + { "334x334", "Custom", 1382, 2048}, }; -static const olymp_pagesize_t updr150_page[] = +LIST(dyesub_printsize_list_t, updr100_printsize_list, dyesub_printsize_t, updr100_printsize); + +static void updr100_printer_init_func(stp_vars_t *v) +{ + + stp_zfwrite("UPD8D\x00\x00\x00\x10\x03\x00\x00", 1, 12, v); + stp_put32_le(privdata.xsize, v); + stp_put32_le(privdata.ysize, v); + stp_zfwrite("\x1e\x00\x03\x00\x01\x00\x4e\x01\x00\x00", 1, 10, v); + stp_zfwrite((privdata.laminate->seq).data, 1, + (privdata.laminate->seq).bytes, v); /* laminate pattern */ + dyesub_nputc(v, '\0', 13); + stp_zfwrite("\x01\x00\x01\x00\x03", 1, 5, v); + dyesub_nputc(v, '\0', 19); +} + +static void updr100_printer_end_func(stp_vars_t *v) +{ + stp_zfwrite("UPD8D\x00\x00\x00\x02", 1, 9, v); + dyesub_nputc(v, '\0', 25); + stp_zfwrite("\x9d\x02\x00\x04\x00\x00\xc0\xe7" + "\x9d\x02\x54\xe9\x9d\x02\x9d\x71" + "\x00\x73\xfa\x71\x00\x73\xf4\xea" + "\x9d\x02\xa8\x3e\x00\x73\x9c\xeb\x9d\x02" + , 1, 34, v); +} + +static const laminate_t updr100_laminate[] = { - { "w288h432", "2UPC-153 (4x6)", -1, -1, 0, 0, 3, 2}, - { "B7", "2UPC-154 (3.5x5)", -1, -1, 3, 2, 0, 0}, - { "w360h504", "2UPC-155 (5x7)", -1, -1, 0, 0, 4, 4}, - { "w432h576", "2UPC-156 (6x8)", -1, -1, 3, 2, 5, 4}, - { "Custom", NULL, -1, -1, 0, 0, 3, 2}, + {"Glossy", N_("Glossy"), {1, "\x01"}}, + {"Texture", N_("Texture"), {1, "\x03"}}, + {"Matte", N_("Matte"), {1, "\x04"}}, }; -static const olymp_pagesize_list_t updr150_page_list = +LIST(laminate_list_t, updr100_laminate_list, laminate_t, updr100_laminate); + + +/* Sony UP-DR150 */ +static const dyesub_resolution_t res_334dpi[] = { - updr150_page, sizeof(updr150_page) / sizeof(olymp_pagesize_t) + { "334x334", 334, 334}, }; -static const olymp_printsize_t updr150_printsize[] = +LIST(dyesub_resolution_list_t, res_334dpi_list, dyesub_resolution_t, res_334dpi); + +static const dyesub_pagesize_t updr150_page[] = { - { "346x346", "w288h432", 1382, 2048}, - { "346x346", "B7", 1210, 1728}, - { "346x346", "w360h504", 1728, 2380}, - { "346x346", "w432h576", 2048, 2724}, - { "346x346", "Custom", 1382, 2048}, + { "w288h432", "2UPC-153 (4x6)", 298, 442, 0, 0, 0, 0, DYESUB_LANDSCAPE}, + { "B7", "2UPC-154 (3.5x5)", 261, 373, 0, 0, 0, 0, DYESUB_LANDSCAPE}, + { "w360h504", "2UPC-155 (5x7)", 373, 514, 0, 0, 0, 0, DYESUB_PORTRAIT}, + { "w432h576", "2UPC-156 (6x8)", 442, 588, 0, 0, 0, 0, DYESUB_PORTRAIT}, + { "Custom", NULL, 298, 442, 0, 0, 0, 0, DYESUB_LANDSCAPE}, }; -static const olymp_printsize_list_t updr150_printsize_list = +LIST(dyesub_pagesize_list_t, updr150_page_list, dyesub_pagesize_t, updr150_page); + +static const dyesub_printsize_t updr150_printsize[] = { - updr150_printsize, sizeof(updr150_printsize) / sizeof(olymp_printsize_t) + { "334x334", "w288h432", 1382, 2048}, + { "334x334", "B7", 1210, 1728}, + { "334x334", "w360h504", 1728, 2380}, + { "334x334", "w432h576", 2048, 2724}, + { "334x334", "Custom", 1382, 2048}, }; +LIST(dyesub_printsize_list_t, updr150_printsize_list, dyesub_printsize_t, updr150_printsize); + static void updr150_printer_init_func(stp_vars_t *v) { char pg = '\0'; @@ -975,14 +1142,14 @@ static void updr150_printer_init_func(stp_vars_t *v) "\x1b\x15\x00\x00\x00\x0d\x00\x0d" "\x00\x00\x00\x00\x00\x00\x00\x07" "\x00\x00\x00\x00", 1, 91, v); - stp_put16_be(privdata.xsize, v); stp_put16_be(privdata.ysize, v); + stp_put16_be(privdata.xsize, v); stp_zfwrite("\xf9\xff\xff\xff\x07\x00\x00\x00" "\x1b\xe1\x00\x00\x00\x0b\x00\x0b" "\x00\x00\x00\x00\x80\x00\x00\x00" "\x00\x00", 1, 26, v); - stp_put16_be(privdata.xsize, v); stp_put16_be(privdata.ysize, v); + stp_put16_be(privdata.xsize, v); stp_zfwrite("\xf8\xff\xff\xff\x0b\x00\x00\x00\x1b\xea" "\x00\x00\x00\x00", 1, 14, v); stp_put32_be(privdata.xsize*privdata.ysize*3, v); @@ -1000,50 +1167,35 @@ static void updr150_printer_end_func(stp_vars_t *v) , 1, 34, v); } -/* Fujifilm CX-400 */ -static const olymp_resolution_t cx400_res[] = -{ - { "317x316", 317, 316}, -}; - -static const olymp_resolution_list_t cx400_res_list = -{ - cx400_res, sizeof(cx400_res) / sizeof(olymp_resolution_t) -}; -static const olymp_pagesize_t cx400_page[] = +/* Fujifilm CX-400 */ +static const dyesub_pagesize_t cx400_page[] = { - { "w288h432", NULL, -1, -1, 23, 23, 28, 28}, - { "w288h387", "4x5 3/8 (Digital Camera 3:4)", -1, -1, 23, 23, 27, 26}, - { "w288h504", NULL, -1, -1, 23, 23, 23, 22}, - { "Custom", NULL, -1, -1, 0, 0, 0, 0}, + { "w288h432", NULL, 295, 428, 24, 24, 23, 22, DYESUB_PORTRAIT}, + { "w288h387", "4x5 3/8 (Digital Camera 3:4)", 295, 386, 24, 24, 23, 23, DYESUB_PORTRAIT}, + { "w288h504", NULL, 295, 513, 24, 24, 23, 22, DYESUB_PORTRAIT}, + { "Custom", NULL, 295, 428, 0, 0, 0, 0, DYESUB_PORTRAIT}, }; -static const olymp_pagesize_list_t cx400_page_list = -{ - cx400_page, sizeof(cx400_page) / sizeof(olymp_pagesize_t) -}; +LIST(dyesub_pagesize_list_t, cx400_page_list, dyesub_pagesize_t, cx400_page); -static const olymp_printsize_t cx400_printsize[] = +static const dyesub_printsize_t cx400_printsize[] = { - { "317x316", "w288h387", 1268, 1658}, - { "317x316", "w288h432", 1268, 1842}, - { "317x316", "w288h504", 1268, 2208}, - { "317x316", "Custom", 1268, 1842}, + { "310x310", "w288h387", 1268, 1658}, + { "310x310", "w288h432", 1268, 1842}, + { "310x310", "w288h504", 1268, 2208}, + { "310x310", "Custom", 1268, 1842}, }; -static const olymp_printsize_list_t cx400_printsize_list = -{ - cx400_printsize, sizeof(cx400_printsize) / sizeof(olymp_printsize_t) -}; +LIST(dyesub_printsize_list_t, cx400_printsize_list, dyesub_printsize_t, cx400_printsize); static void cx400_printer_init_func(stp_vars_t *v) { char pg = '\0'; const char *pname = "XXXXXX"; - stp_deprintf(STP_DBG_OLYMPUS, - "olympus: fuji driver %s\n", stp_get_driver(v)); + stp_deprintf(STP_DBG_DYESUB, + "dyesub: fuji driver %s\n", stp_get_driver(v)); if (strcmp(stp_get_driver(v),"fujifilm-cx400") == 0) pname = "NX1000"; else if (strcmp(stp_get_driver(v),"fujifilm-cx550") == 0) @@ -1068,33 +1220,94 @@ static void cx400_printer_init_func(stp_vars_t *v) stp_putc('\1', v); } -static const olymp_resolution_t all_resolutions[] = + +/* Fujifilm NX-500 */ +static const dyesub_resolution_t res_306dpi[] = { { "306x306", 306, 306}, - { "153x153", 153, 153}, - { "314x314", 314, 314}, - { "300x300", 300, 300}, - { "317x316", 317, 316}, - { "320x320", 320, 320}, - { "346x346", 346, 346}, }; -static const olymp_resolution_list_t all_res_list = +LIST(dyesub_resolution_list_t, res_306dpi_list, dyesub_resolution_t, res_306dpi); + +static const dyesub_pagesize_t nx500_page[] = +{ + { "Postcard", NULL, -1, -1, 21, 21, 29, 29, DYESUB_PORTRAIT}, + { "Custom", NULL, -1, -1, 21, 21, 29, 29, DYESUB_PORTRAIT}, +}; + +LIST(dyesub_pagesize_list_t, nx500_page_list, dyesub_pagesize_t, nx500_page); + +static const dyesub_printsize_t nx500_printsize[] = +{ + { "306x306", "Postcard", 1024, 1518}, + { "306x306", "Custom", 1024, 1518}, +}; + +LIST(dyesub_printsize_list_t, nx500_printsize_list, dyesub_printsize_t, nx500_printsize); + +static void nx500_printer_init_func(stp_vars_t *v) +{ + stp_zfwrite("INFO-QX-20--MKS\x00\x00\x00M\x00W\00A\x00R\00E", 1, 27, v); + dyesub_nputc(v, '\0', 21); + stp_zfwrite("\x80\x00\x02", 1, 3, v); + dyesub_nputc(v, '\0', 20); + stp_zfwrite("\x02\x01\x01", 1, 3, v); + dyesub_nputc(v, '\0', 2); + stp_put16_le(privdata.ysize, v); + stp_put16_le(privdata.xsize, v); + stp_zfwrite("\x00\x02\x00\x70\x2f", 1, 5, v); + dyesub_nputc(v, '\0', 43); +} + + +/* Kodak Easyshare Dock family */ +static const dyesub_pagesize_t kodak_dock_page[] = +{ + { "w288h432", NULL, PT(1248,300)+1, PT(1856,300)+1, 0, 0, 0, 0, + DYESUB_PORTRAIT}, /* 4x6 */ + { "Custom", NULL, PT(1248,300)+1, PT(1856,300)+1, 0, 0, 0, 0, + DYESUB_PORTRAIT}, /* 4x6 */ +}; + +LIST(dyesub_pagesize_list_t, kodak_dock_page_list, dyesub_pagesize_t, kodak_dock_page); + +static const dyesub_printsize_t kodak_dock_printsize[] = { - all_resolutions, sizeof(all_resolutions) / sizeof(olymp_resolution_t) + { "300x300", "w288h432", 1248, 1856}, + { "300x300", "Custom", 1248, 1856}, }; -static const olympus_cap_t olympus_model_capabilities[] = +LIST(dyesub_printsize_list_t, kodak_dock_printsize_list, dyesub_printsize_t, kodak_dock_printsize); + +static void kodak_dock_printer_init(stp_vars_t *v) +{ + stp_put16_be(0x3000, v); + dyesub_nputc(v, '\0', 10); +} + +static void kodak_dock_plane_init(stp_vars_t *v) +{ + stp_put16_be(0x3001, v); + stp_put16_le(3 - privdata.plane, v); + stp_put32_le(privdata.xsize*privdata.ysize, v); + dyesub_nputc(v, '\0', 4); +} + + + +/* Model capabilities */ + +static const dyesub_cap_t dyesub_model_capabilities[] = { { /* Olympus P-10, P-11 */ 2, &rgb_ink_list, - &res_320dpi_list, + &res_310dpi_list, &p10_page_list, &p10_printsize_list, - OLYMPUS_INTERLACE_PLANE, - 1848, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_FULL_HEIGHT, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_PLANE_INTERLACE, &p10_printer_init_func, &p10_printer_end_func, NULL, NULL, &p10_block_init_func, NULL, @@ -1107,9 +1320,9 @@ static const olympus_cap_t olympus_model_capabilities[] = &res_320dpi_list, &p200_page_list, &p200_printsize_list, - OLYMPUS_INTERLACE_PLANE, - 1280, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_BLOCK_ALIGN, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_BLOCK_ALIGN + | DYESUB_FEATURE_PLANE_INTERLACE, &p200_printer_init_func, &p200_printer_end_func, &p200_plane_init_func, NULL, NULL, NULL, @@ -1122,9 +1335,9 @@ static const olympus_cap_t olympus_model_capabilities[] = &p300_res_list, &p300_page_list, &p300_printsize_list, - OLYMPUS_INTERLACE_PLANE, 16, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_BLOCK_ALIGN, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_BLOCK_ALIGN + | DYESUB_FEATURE_PLANE_INTERLACE, &p300_printer_init_func, NULL, NULL, &p300_plane_end_func, &p300_block_init_func, NULL, @@ -1137,9 +1350,9 @@ static const olympus_cap_t olympus_model_capabilities[] = &res_314dpi_list, &p400_page_list, &p400_printsize_list, - OLYMPUS_INTERLACE_PLANE, 180, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_FULL_HEIGHT, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_PLANE_INTERLACE, &p400_printer_init_func, NULL, &p400_plane_init_func, &p400_plane_end_func, &p400_block_init_func, NULL, @@ -1152,25 +1365,54 @@ static const olympus_cap_t olympus_model_capabilities[] = &res_314dpi_list, &p440_page_list, &p440_printsize_list, - OLYMPUS_INTERLACE_NONE, 128, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_FULL_HEIGHT, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT, &p440_printer_init_func, &p440_printer_end_func, NULL, NULL, &p440_block_init_func, &p440_block_end_func, NULL, NULL, NULL, /* color profile/adjustment is built into printer */ &p10_laminate_list, }, + { /* Olympus P-S100 */ + 20, + &rgb_ink_list, + &res_306dpi_list, + &ps100_page_list, + &ps100_printsize_list, + 1808, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT, + &ps100_printer_init_func, &ps100_printer_end_func, + NULL, NULL, + NULL, NULL, + NULL, NULL, NULL, /* color profile/adjustment is built into printer */ + NULL, + }, + { /* Canon CP-10 */ + 1002, + &ymc_ink_list, + &res_300dpi_list, + &cp10_page_list, + &cp10_printsize_list, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_BORDERLESS | DYESUB_FEATURE_WHITE_BORDER + | DYESUB_FEATURE_PLANE_INTERLACE, + &cpx00_printer_init_func, NULL, + &cpx00_plane_init_func, NULL, + NULL, NULL, + cpx00_adj_cyan, cpx00_adj_magenta, cpx00_adj_yellow, + NULL, + }, { /* Canon CP-100, CP-200, CP-300 */ 1000, &ymc_ink_list, - &res_314dpi_list, + &res_300dpi_list, &cpx00_page_list, &cpx00_printsize_list, - OLYMPUS_INTERLACE_PLANE, - 1808, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_FULL_HEIGHT - | OLYMPUS_FEATURE_BORDERLESS | OLYMPUS_FEATURE_WHITE_BORDER, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_BORDERLESS | DYESUB_FEATURE_WHITE_BORDER + | DYESUB_FEATURE_PLANE_INTERLACE, &cpx00_printer_init_func, NULL, &cpx00_plane_init_func, NULL, NULL, NULL, @@ -1181,44 +1423,71 @@ static const olympus_cap_t olympus_model_capabilities[] = SELPHY CP-600, SELPHY CP-710 */ 1001, &ymc_ink_list, - &res_314dpi_list, + &res_300dpi_list, &cp220_page_list, &cp220_printsize_list, - OLYMPUS_INTERLACE_PLANE, - 1808, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_FULL_HEIGHT - | OLYMPUS_FEATURE_BORDERLESS | OLYMPUS_FEATURE_WHITE_BORDER, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_BORDERLESS | DYESUB_FEATURE_WHITE_BORDER + | DYESUB_FEATURE_PLANE_INTERLACE, &cpx00_printer_init_func, NULL, &cpx00_plane_init_func, NULL, NULL, NULL, cpx00_adj_cyan, cpx00_adj_magenta, cpx00_adj_yellow, NULL, }, + { /* Sony DPP-EX5, DPP-EX7 */ + 2002, + &rgb_ink_list, + &res_403dpi_list, + &dppex5_page_list, + &dppex5_printsize_list, + 100, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_BORDERLESS, + &dppex5_printer_init, &dppex5_printer_end, + NULL, NULL, + &dppex5_block_init, NULL, + NULL, NULL, NULL, + &dppex5_laminate_list, + }, { /* Sony UP-DP10 */ 2000, &cmy_ink_list, - &updp10_res_list, + &res_300dpi_list, &updp10_page_list, &updp10_printsize_list, - OLYMPUS_INTERLACE_NONE, - 1800, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_FULL_HEIGHT - | OLYMPUS_FEATURE_BORDERLESS, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_BORDERLESS, &updp10_printer_init_func, &updp10_printer_end_func, NULL, NULL, NULL, NULL, updp10_adj_cyan, updp10_adj_magenta, updp10_adj_yellow, &updp10_laminate_list, }, + { /* Sony UP-DR100 */ + 2003, + &rgb_ink_list, + &res_334dpi_list, + &updr100_page_list, + &updr100_printsize_list, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT, + &updr100_printer_init_func, &updr100_printer_end_func, + NULL, NULL, + NULL, NULL, + NULL, NULL, NULL, + &updr100_laminate_list, + }, { /* Sony UP-DR150 */ 2001, &rgb_ink_list, - &updr150_res_list, + &res_334dpi_list, &updr150_page_list, &updr150_printsize_list, - OLYMPUS_INTERLACE_NONE, - 1800, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_FULL_HEIGHT, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT, &updr150_printer_init_func, &updr150_printer_end_func, NULL, NULL, NULL, NULL, @@ -1228,13 +1497,12 @@ static const olympus_cap_t olympus_model_capabilities[] = { /* Fujifilm Printpix CX-400 */ 3000, &rgb_ink_list, - &cx400_res_list, + &res_310dpi_list, &cx400_page_list, &cx400_printsize_list, - OLYMPUS_INTERLACE_NONE, - 2208, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_FULL_HEIGHT - | OLYMPUS_FEATURE_BORDERLESS, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_BORDERLESS, &cx400_printer_init_func, NULL, NULL, NULL, NULL, NULL, @@ -1244,19 +1512,47 @@ static const olympus_cap_t olympus_model_capabilities[] = { /* Fujifilm Printpix CX-550 */ 3001, &rgb_ink_list, - &cx400_res_list, + &res_310dpi_list, &cx400_page_list, &cx400_printsize_list, - OLYMPUS_INTERLACE_NONE, - 2208, - OLYMPUS_FEATURE_FULL_WIDTH | OLYMPUS_FEATURE_FULL_HEIGHT - | OLYMPUS_FEATURE_BORDERLESS, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_BORDERLESS, &cx400_printer_init_func, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* color profile/adjustment is built into printer */ NULL, }, + { /* Fujifilm FinePix NX-500 */ + 3002, + &rgb_ink_list, + &res_306dpi_list, + &nx500_page_list, + &nx500_printsize_list, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT, + &nx500_printer_init_func, NULL, + NULL, NULL, + NULL, NULL, + NULL, NULL, NULL, /* color profile/adjustment is built into printer */ + NULL, + }, + { /* Kodak Easyshare Dock family */ + 4000, + &ymc_ink_list, + &res_300dpi_list, + &kodak_dock_page_list, + &kodak_dock_printsize_list, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_PLANE_INTERLACE, + &kodak_dock_printer_init, NULL, + &kodak_dock_plane_init, NULL, + NULL, NULL, + NULL, NULL, NULL, + NULL, + }, }; static const stp_parameter_t the_parameters[] = @@ -1362,25 +1658,25 @@ static const float_param_t float_parameters[] = static const int float_parameter_count = sizeof(float_parameters) / sizeof(const float_param_t); -static const olympus_cap_t* olympus_get_model_capabilities(int model) +static const dyesub_cap_t* dyesub_get_model_capabilities(int model) { int i; - int models = sizeof(olympus_model_capabilities) / sizeof(olympus_cap_t); + int models = sizeof(dyesub_model_capabilities) / sizeof(dyesub_cap_t); for (i=0; i<models; i++) { - if (olympus_model_capabilities[i].model == model) - return &(olympus_model_capabilities[i]); + if (dyesub_model_capabilities[i].model == model) + return &(dyesub_model_capabilities[i]); } - stp_deprintf(STP_DBG_OLYMPUS, - "olympus: model %d not found in capabilities list.\n", model); - return &(olympus_model_capabilities[0]); + stp_deprintf(STP_DBG_DYESUB, + "dyesub: model %d not found in capabilities list.\n", model); + return &(dyesub_model_capabilities[0]); } -static const laminate_t* olympus_get_laminate_pattern(stp_vars_t *v) +static const laminate_t* dyesub_get_laminate_pattern(stp_vars_t *v) { const char *lpar = stp_get_string_parameter(v, "Laminate"); - const olympus_cap_t *caps = olympus_get_model_capabilities( + const dyesub_cap_t *caps = dyesub_get_model_capabilities( stp_get_model_id(v)); const laminate_list_t *llist = caps->laminate; const laminate_t *l = NULL; @@ -1396,16 +1692,16 @@ static const laminate_t* olympus_get_laminate_pattern(stp_vars_t *v) } static void -olympus_printsize(const stp_vars_t *v, +dyesub_printsize(const stp_vars_t *v, int *width, int *height) { int i; const char *page = stp_get_string_parameter(v, "PageSize"); const char *resolution = stp_get_string_parameter(v, "Resolution"); - const olympus_cap_t *caps = olympus_get_model_capabilities( + const dyesub_cap_t *caps = dyesub_get_model_capabilities( stp_get_model_id(v)); - const olymp_printsize_list_t *p = caps->printsize; + const dyesub_printsize_list_t *p = caps->printsize; for (i = 0; i < p->n_items; i++) { @@ -1417,18 +1713,18 @@ olympus_printsize(const stp_vars_t *v, return; } } - stp_erprintf("olympus_printsize: printsize not found (%s, %s)\n", + stp_erprintf("dyesub_printsize: printsize not found (%s, %s)\n", page, resolution); } static int -olympus_feature(const olympus_cap_t *caps, int feature) +dyesub_feature(const dyesub_cap_t *caps, int feature) { return ((caps->features & feature) == feature); } static stp_parameter_list_t -olympus_list_parameters(const stp_vars_t *v) +dyesub_list_parameters(const stp_vars_t *v) { stp_parameter_list_t *ret = stp_parameter_list_create(); int i; @@ -1441,11 +1737,11 @@ olympus_list_parameters(const stp_vars_t *v) } static void -olympus_parameters(const stp_vars_t *v, const char *name, +dyesub_parameters(const stp_vars_t *v, const char *name, stp_parameter_t *description) { int i; - const olympus_cap_t *caps = olympus_get_model_capabilities( + const dyesub_cap_t *caps = dyesub_get_model_capabilities( stp_get_model_id(v)); description->p_type = STP_PARAMETER_TYPE_INVALID; @@ -1472,7 +1768,7 @@ olympus_parameters(const stp_vars_t *v, const char *name, if (strcmp(name, "PageSize") == 0) { int default_specified = 0; - const olymp_pagesize_list_t *p = caps->pages; + const dyesub_pagesize_list_t *p = caps->pages; const char* text; description->bounds.str = stp_string_list_create(); @@ -1507,7 +1803,7 @@ olympus_parameters(const stp_vars_t *v, const char *name, else if (strcmp(name, "Resolution") == 0) { char res_text[24]; - const olymp_resolution_list_t *r = caps->resolution; + const dyesub_resolution_list_t *r = caps->resolution; description->bounds.str = stp_string_list_create(); for (i = 0; i < r->n_items; i++) @@ -1552,7 +1848,7 @@ olympus_parameters(const stp_vars_t *v, const char *name, } else if (strcmp(name, "Borderless") == 0) { - if (olympus_feature(caps, OLYMPUS_FEATURE_BORDERLESS)) + if (dyesub_feature(caps, DYESUB_FEATURE_BORDERLESS)) description->is_active = 1; } else if (strcmp(name, "PrintingMode") == 0) @@ -1568,104 +1864,129 @@ olympus_parameters(const stp_vars_t *v, const char *name, } +static const dyesub_pagesize_t* +dyesub_current_pagesize(const stp_vars_t *v) +{ + const char *page = stp_get_string_parameter(v, "PageSize"); + const stp_papersize_t *pt = stp_get_papersize_by_name(page); + const dyesub_cap_t *caps = dyesub_get_model_capabilities( + stp_get_model_id(v)); + const dyesub_pagesize_list_t *p = caps->pages; + int i; + + for (i = 0; i < p->n_items; i++) + { + if (strcmp(p->item[i].name,pt->name) == 0) + return &(p->item[i]); + } + return NULL; +} + static void -olympus_imageable_area_internal(const stp_vars_t *v, +dyesub_media_size(const stp_vars_t *v, + int *width, + int *height) +{ + const dyesub_pagesize_t *p = dyesub_current_pagesize(v); + stp_default_media_size(v, width, height); + + if (p && p->width_pt > 0) + *width = p->width_pt; + if (p && p->height_pt > 0) + *height = p->height_pt; +} + +static void +dyesub_imageable_area_internal(const stp_vars_t *v, int use_maximum_area, int *left, int *right, int *bottom, - int *top) + int *top, + int *print_mode) { int width, height; - int i; - const char *page = stp_get_string_parameter(v, "PageSize"); - const stp_papersize_t *pt = stp_get_papersize_by_name(page); - const olympus_cap_t *caps = olympus_get_model_capabilities( + const dyesub_pagesize_t *p = dyesub_current_pagesize(v); + const dyesub_cap_t *caps = dyesub_get_model_capabilities( stp_get_model_id(v)); - const olymp_pagesize_list_t *p = caps->pages; - for (i = 0; i < p->n_items; i++) + dyesub_media_size(v, &width, &height); + if (use_maximum_area + || (dyesub_feature(caps, DYESUB_FEATURE_BORDERLESS) && + stp_get_boolean_parameter(v, "Borderless")) + || !p) { - if (strcmp(p->item[i].name,pt->name) == 0) - { -/* - if (p->item[i].width_pt >= 0) - stp_set_page_width(v, p->item[i].width_pt); - if (p->item[i].height_pt >= 0) - stp_set_page_height(v, p->item[i].height_pt); -*/ - - stp_default_media_size(v, &width, &height); - - - if (use_maximum_area || - (olympus_feature(caps, OLYMPUS_FEATURE_BORDERLESS) && - stp_get_boolean_parameter(v, "Borderless"))) - { - *left = 0; - *top = 0; - *right = width; - *bottom = height; - } - else - { - *left = p->item[i].border_pt_left; - *top = p->item[i].border_pt_top; - *right = width - p->item[i].border_pt_right; - *bottom = height - p->item[i].border_pt_bottom; - } - break; - } + *left = 0; + *top = 0; + *right = width; + *bottom = height; } + else + { + *left = p->border_pt_left; + *top = p->border_pt_top; + *right = width - p->border_pt_right; + *bottom = height - p->border_pt_bottom; + } + if (p) + *print_mode = p->print_mode; + else + *print_mode = DYESUB_PORTRAIT; } static void -olympus_imageable_area(const stp_vars_t *v, +dyesub_imageable_area(const stp_vars_t *v, int *left, int *right, int *bottom, int *top) { - olympus_imageable_area_internal(v, 0, left, right, bottom, top); + int not_used; + dyesub_imageable_area_internal(v, 0, left, right, bottom, top, ¬_used); } static void -olympus_maximum_imageable_area(const stp_vars_t *v, +dyesub_maximum_imageable_area(const stp_vars_t *v, int *left, int *right, int *bottom, int *top) { - olympus_imageable_area_internal(v, 1, left, right, bottom, top); + int not_used; + dyesub_imageable_area_internal(v, 1, left, right, bottom, top, ¬_used); } static void -olympus_limit(const stp_vars_t *v, /* I */ +dyesub_limit(const stp_vars_t *v, /* I */ int *width, int *height, int *min_width, int *min_height) { - *width = 65535; - *height = 65535; - *min_width = 1; + *width = SHRT_MAX; + *height = SHRT_MAX; + *min_width = 1; *min_height = 1; } static void -olympus_describe_resolution(const stp_vars_t *v, int *x, int *y) +dyesub_describe_resolution(const stp_vars_t *v, int *x, int *y) { const char *resolution = stp_get_string_parameter(v, "Resolution"); + const dyesub_cap_t *caps = dyesub_get_model_capabilities( + stp_get_model_id(v)); + const dyesub_resolution_list_t *r = caps->resolution; int i; *x = -1; *y = -1; if (resolution) { - for (i = 0; i < all_res_list.n_items; i++) + for (i = 0; i < r->n_items; i++) { - if (strcmp(resolution, all_res_list.item[i].name) == 0) + if (strcmp(resolution, r->item[i].name) == 0) { - *x = all_res_list.item[i].xdpi; - *y = all_res_list.item[i].ydpi; + *x = r->item[i].xdpi; + *y = r->item[i].ydpi; + break; } } } @@ -1673,87 +1994,304 @@ olympus_describe_resolution(const stp_vars_t *v, int *x, int *y) } static const char * -olympus_describe_output(const stp_vars_t *v) +dyesub_describe_output_internal(const stp_vars_t *v, dyesub_print_vars_t *pv) { - return "CMY"; + const char *ink_type = stp_get_string_parameter(v, "InkType"); + const dyesub_cap_t *caps = dyesub_get_model_capabilities( + stp_get_model_id(v)); + const char *output_type; + int i; + + pv->ink_channels = 1; + pv->ink_order = NULL; + output_type = "CMY"; + + if (ink_type) + { + for (i = 0; i < caps->inks->n_items; i++) + if (strcmp(ink_type, caps->inks->item[i].name) == 0) + { + output_type = caps->inks->item[i].output_type; + pv->ink_channels = caps->inks->item[i].output_channels; + pv->ink_order = caps->inks->item[i].channel_order; + break; + } + } + + return output_type; } -static unsigned short * -olympus_get_cached_output(stp_vars_t *v, - stp_image_t *image, - unsigned short **cache, - int line, int size) +static const char * +dyesub_describe_output(const stp_vars_t *v) +{ + dyesub_print_vars_t ipv; + return dyesub_describe_output_internal(v, &ipv); +} + +static void +dyesub_nputc(stp_vars_t *v, char byte, int count) +{ + int i; + for (i = 0; i < count; i++) + stp_putc(byte, v); +} + +static void +dyesub_swap_ints(int *a, int *b) +{ + int t = *a; + *a = *b; + *b = t; +} + +static void +dyesub_adjust_curve(stp_vars_t *v, + const char *color_adj, + const char *color_curve) +{ + stp_curve_t *adjustment = NULL; + + if (color_adj && + !stp_check_curve_parameter(v, color_curve, STP_PARAMETER_ACTIVE)) + { + adjustment = stp_curve_create_from_string(color_adj); + stp_set_curve_parameter(v, color_curve, adjustment); + stp_set_curve_parameter_active(v, color_curve, STP_PARAMETER_ACTIVE); + stp_curve_destroy(adjustment); + } +} + +static void +dyesub_exec(stp_vars_t *v, + void (*func)(stp_vars_t *), + const char *debug_string) +{ + if (func) + { + stp_deprintf(STP_DBG_DYESUB, "dyesub: %s\n", debug_string); + (*func)(v); + } +} + +static int +dyesub_interpolate(int oldval, int oldsize, int newsize) +{ + /* + * This is simple linear interpolation algorithm. + * When imagesize <> printsize I need rescale image somehow... :-/ + */ + return (int)(oldval * newsize / oldsize); +} + +static void +dyesub_free_image(unsigned short** image_data, stp_image_t *image) { - unsigned zero_mask; + int image_px_height = stp_image_height(image); + int i; + + for (i = 0; i< image_px_height; i++) + if (image_data[i]) + stp_free(image_data[i]); + if (image_data) + stp_free(image_data); +} + +static unsigned short ** +dyesub_read_image(stp_vars_t *v, + dyesub_print_vars_t *pv, + stp_image_t *image) +{ + int image_px_width = stp_image_width(image); + int image_px_height = stp_image_height(image); + int row_size = image_px_width * pv->ink_channels * pv->bytes_per_out_channel; + unsigned short **image_data; + unsigned int zero_mask; + int i; - stp_deprintf(STP_DBG_OLYMPUS, "olympus: get row %d", line); - if (cache[line] == NULL) + image_data = stp_zalloc(image_px_height * sizeof(unsigned short *)); + if (!image_data) + return NULL; /* ? out of memory ? */ + + for (i = 0; i < image_px_height; i++) { - stp_deprintf(STP_DBG_OLYMPUS, " (calling stp_color_get_row())\n"); - if (!stp_color_get_row(v, image, line, &zero_mask)) + if (stp_color_get_row(v, image, i, &zero_mask)) + { + stp_deprintf(STP_DBG_DYESUB, + "dyesub_read_image: " + "stp_color_get_row(..., %d, ...) == 0\n", i); + dyesub_free_image(image_data, image); + return NULL; + } + image_data[i] = stp_malloc(row_size); + if (!image_data[i]) { - cache[line] = stp_malloc(size); - memcpy(cache[line], stp_channel_get_output(v), size); + stp_deprintf(STP_DBG_DYESUB, + "dyesub_read_image: " + "(image_data[%d] = stp_malloc()) == NULL\n", i); + dyesub_free_image(image_data, image); + return NULL; + } + memcpy(image_data[i], stp_channel_get_output(v), row_size); + } + stp_image_conclude(image); + + return image_data; +} + +static int +dyesub_print_pixel(stp_vars_t *v, + dyesub_print_vars_t *pv, + int row, + int col, + int plane) +{ + unsigned short ink[MAX_INK_CHANNELS * MAX_BYTES_PER_CHANNEL], *out; + unsigned char *ink_u8; + int i, j; + + if (pv->print_mode == DYESUB_LANDSCAPE) + { /* "rotate" image */ + dyesub_swap_ints(&col, &row); + row = (pv->imgw_px - 1) - row; + } + + out = &(pv->image_data[row][col * pv->out_channels]); + + for (i = 0; i < pv->ink_channels; i++) + { + if (pv->out_channels == pv->ink_channels) + { /* copy out_channel (image) to equiv ink_channel (printer) */ + ink[i] = out[i]; + } + else if (pv->out_channels < pv->ink_channels) + { /* several ink_channels (printer) "share" same out_channel (image) */ + ink[i] = out[i * pv->out_channels / pv->ink_channels]; } + else /* (pv->out_channels > pv->ink_channels) */ + { /* merge several out_channels (image) into ink_channel (printer) */ + int avg = 0; + for (j = 0; j < pv->out_channels / pv->ink_channels; j++) + avg += out[j + i * pv->out_channels / pv->ink_channels]; + ink[i] = avg * pv->ink_channels / pv->out_channels; + } } + + if (pv->bytes_per_ink_channel == 1) /* convert 16bits to 8bit */ + { + ink_u8 = (unsigned char *) ink; + for (i = 0; i < pv->ink_channels; i++) + ink_u8[i] = ink[i] / 257; + } + + if (pv->plane_interlacing) + stp_zfwrite((char *) ink + plane, pv->bytes_per_ink_channel, 1, v); else + stp_zfwrite((char *) ink, pv->bytes_per_ink_channel, pv->ink_channels, v); + + return 1; +} + +static int +dyesub_print_row(stp_vars_t *v, + dyesub_print_vars_t *pv, + int row, + int plane) +{ + int ret = 0; + int w, col; + + for (w = 0; w < pv->outw_px; w++) + { + col = dyesub_interpolate(w, pv->outw_px, pv->imgw_px); + ret = dyesub_print_pixel(v, pv, row, col, plane); + if (ret > 1) + break; + } + return ret; +} + +static int +dyesub_print_plane(stp_vars_t *v, + dyesub_print_vars_t *pv, + const dyesub_cap_t *caps, + int plane) +{ + int ret = 0; + int h, row; + int out_bytes = (pv->plane_interlacing ? 1 : pv->ink_channels) + * pv->bytes_per_ink_channel; + + + for (h = 0; h <= pv->prnb_px - pv->prnt_px; h++) { - stp_deprintf(STP_DBG_OLYMPUS, " (cached)\n"); + if (h % caps->block_size == 0) + { /* block init */ + privdata.block_min_y = h + pv->prnt_px; + privdata.block_min_x = pv->prnl_px; + privdata.block_max_y = MIN(h + pv->prnt_px + caps->block_size - 1, + pv->prnb_px); + privdata.block_max_x = pv->prnr_px; + + dyesub_exec(v, caps->block_init_func, "caps->block_init"); + } + + if (h + pv->prnt_px < pv->outt_px || h + pv->prnt_px >= pv->outb_px) + { /* empty part above or below image area */ + dyesub_nputc(v, pv->empty_byte, out_bytes * pv->prnw_px); + } + else + { + if (dyesub_feature(caps, DYESUB_FEATURE_FULL_WIDTH) + && pv->outl_px > 0) + { /* empty part left of image area */ + dyesub_nputc(v, pv->empty_byte, out_bytes * pv->outl_px); + } + + row = dyesub_interpolate(h + pv->prnt_px - pv->outt_px, + pv->outh_px, pv->imgh_px); + stp_deprintf(STP_DBG_DYESUB, + "dyesub_print_plane: h = %d, row = %d\n", h, row); + ret = dyesub_print_row(v, pv, row, plane); + + if (dyesub_feature(caps, DYESUB_FEATURE_FULL_WIDTH) + && pv->outr_px < pv->prnw_px) + { /* empty part right of image area */ + dyesub_nputc(v, pv->empty_byte, out_bytes + * (pv->prnw_px - pv->outr_px)); + } + } + + if (h + pv->prnt_px == privdata.block_max_y) + { /* block end */ + dyesub_exec(v, caps->block_end_func, "caps->block_end"); + } } - return cache[line]; + return ret; } /* - * olympus_print() + * dyesub_print() */ static int -olympus_do_print(stp_vars_t *v, stp_image_t *image) +dyesub_do_print(stp_vars_t *v, stp_image_t *image) { - int i, j; - int y, min_y, max_y; /* Looping vars */ - int min_x, max_x; - int out_channels, out_bytes; - unsigned short *final_out = NULL; - unsigned char *char_out = NULL; - unsigned short *real_out = NULL; - unsigned short *err_out = NULL; - unsigned short **rows = NULL; /* "cache" of rows read from image */ - int char_out_width; + int i; + dyesub_print_vars_t pv; int status = 1; - int ink_channels = 1; - const char *ink_order = NULL; - stp_curve_t *adjustment = NULL; - - int r_errdiv, r_errmod; - int r_errval = 0; - int r_errlast = -1; - int r_errline = 0; - int c_errdiv, c_errmod; - int c_errval = 0; - int c_errlast = -1; - int c_errcol = 0; const int model = stp_get_model_id(v); - const char *ink_type = stp_get_string_parameter(v, "InkType"); - const olympus_cap_t *caps = olympus_get_model_capabilities(model); + const char *ink_type; + const dyesub_cap_t *caps = dyesub_get_model_capabilities(model); int max_print_px_width = 0; int max_print_px_height = 0; int xdpi, ydpi; /* Resolution */ - /* image in pixels */ - int image_px_width; - int image_px_height; - /* output in 1/72" */ int out_pt_width = stp_get_width(v); int out_pt_height = stp_get_height(v); int out_pt_left = stp_get_left(v); int out_pt_top = stp_get_top(v); - /* output in pixels */ - int out_px_width, out_px_height; - int out_px_left, out_px_right, out_px_top, out_px_bottom; - /* page in 1/72" */ int page_pt_width = stp_get_page_width(v); int page_pt_height = stp_get_page_height(v); @@ -1761,13 +2299,11 @@ olympus_do_print(stp_vars_t *v, stp_image_t *image) int page_pt_right = 0; int page_pt_top = 0; int page_pt_bottom = 0; + int page_mode; - /* page w/out borders in pixels (according to selected dpi) */ - int print_px_width; - int print_px_height; - int pl; - unsigned char *zeros = NULL; + + if (!stp_verify(v)) { @@ -1776,51 +2312,46 @@ olympus_do_print(stp_vars_t *v, stp_image_t *image) } stp_image_init(image); - image_px_width = stp_image_width(image); - image_px_height = stp_image_height(image); + pv.imgw_px = stp_image_width(image); + pv.imgh_px = stp_image_height(image); stp_describe_resolution(v, &xdpi, &ydpi); - olympus_printsize(v, &max_print_px_width, &max_print_px_height); + dyesub_printsize(v, &max_print_px_width, &max_print_px_height); privdata.pagesize = stp_get_string_parameter(v, "PageSize"); if (caps->laminate) - privdata.laminate = olympus_get_laminate_pattern(v); + privdata.laminate = dyesub_get_laminate_pattern(v); - if (olympus_feature(caps, OLYMPUS_FEATURE_WHITE_BORDER)) - stp_default_media_size(v, &page_pt_right, &page_pt_bottom); - else - olympus_imageable_area(v, &page_pt_left, &page_pt_right, - &page_pt_bottom, &page_pt_top); + dyesub_imageable_area_internal(v, + (dyesub_feature(caps, DYESUB_FEATURE_WHITE_BORDER) ? 1 : 0), + &page_pt_left, &page_pt_right, &page_pt_bottom, &page_pt_top, + &page_mode); - print_px_width = MIN(max_print_px_width, - (page_pt_right - page_pt_left) * xdpi / 72); - print_px_height = MIN(max_print_px_height, - (page_pt_bottom - page_pt_top) * ydpi / 72); - out_px_width = out_pt_width * xdpi / 72; - out_px_height = out_pt_height * ydpi / 72; + pv.prnw_px = MIN(max_print_px_width, + PX(page_pt_right - page_pt_left, xdpi)); + pv.prnh_px = MIN(max_print_px_height, + PX(page_pt_bottom - page_pt_top, ydpi)); + pv.outw_px = PX(out_pt_width, xdpi); + pv.outh_px = PX(out_pt_height, ydpi); /* if image size is close enough to output size send out original size */ - if (out_px_width - image_px_width > -5 - && out_px_width - image_px_width < 5 - && out_px_height - image_px_height > -5 - && out_px_height - image_px_height < 5) - { - out_px_width = image_px_width; - out_px_height = image_px_height; - } - - out_px_width = MIN(out_px_width, print_px_width); - out_px_height = MIN(out_px_height, print_px_height); - out_px_left = MIN(((out_pt_left - page_pt_left) * xdpi / 72), - print_px_width - out_px_width); - out_px_top = MIN(((out_pt_top - page_pt_top) * ydpi / 72), - print_px_height - out_px_height); - out_px_right = out_px_left + out_px_width; - out_px_bottom = out_px_top + out_px_height; + if (abs(pv.outw_px - pv.imgw_px) < SIZE_THRESHOLD) + pv.outw_px = pv.imgw_px; + if (abs(pv.outh_px - pv.imgh_px) < SIZE_THRESHOLD) + pv.outh_px = pv.imgh_px; + + pv.outw_px = MIN(pv.outw_px, pv.prnw_px); + pv.outh_px = MIN(pv.outh_px, pv.prnh_px); + pv.outl_px = MIN(PX(out_pt_left - page_pt_left, xdpi), + pv.prnw_px - pv.outw_px); + pv.outt_px = MIN(PX(out_pt_top - page_pt_top, ydpi), + pv.prnh_px - pv.outh_px); + pv.outr_px = pv.outl_px + pv.outw_px; + pv.outb_px = pv.outt_px + pv.outh_px; - stp_deprintf(STP_DBG_OLYMPUS, + stp_deprintf(STP_DBG_DYESUB, "paper (pt) %d x %d\n" "image (px) %d x %d\n" "image (pt) %d x %d\n" @@ -1832,357 +2363,139 @@ olympus_do_print(stp_vars_t *v, stp_image_t *image) "printable pixels (px) %d x %d\n" "res (dpi) %d x %d\n", page_pt_width, page_pt_height, - image_px_width, image_px_height, - image_px_width * 72 / xdpi, image_px_height * 72 / ydpi, + pv.imgw_px, pv.imgh_px, + PT(pv.imgw_px, xdpi), PT(pv.imgh_px, ydpi), out_pt_width, out_pt_height, - out_px_width, out_px_height, + pv.outw_px, pv.outh_px, out_pt_left, out_pt_top, - out_px_left, out_px_top, + pv.outl_px, pv.outt_px, page_pt_right, page_pt_left, page_pt_right - page_pt_left, page_pt_bottom, page_pt_top, page_pt_bottom - page_pt_top, - print_px_width, print_px_height, + pv.prnw_px, pv.prnh_px, xdpi, ydpi ); privdata.xdpi = xdpi; privdata.ydpi = ydpi; - privdata.xsize = print_px_width; - privdata.ysize = print_px_height; - - stp_set_string_parameter(v, "STPIOutputType", "CMY"); - - if (caps->adj_cyan && - !stp_check_curve_parameter(v, "CyanCurve", STP_PARAMETER_ACTIVE)) - { - adjustment = stp_curve_create_from_string(caps->adj_cyan); - stp_set_curve_parameter(v, "CyanCurve", adjustment); - stp_set_curve_parameter_active(v, "CyanCurve", STP_PARAMETER_ACTIVE); - stp_curve_destroy(adjustment); - } - if (caps->adj_magenta && - !stp_check_curve_parameter(v, "MagentaCurve", STP_PARAMETER_ACTIVE)) - { - adjustment = stp_curve_create_from_string(caps->adj_magenta); - stp_set_curve_parameter(v, "MagentaCurve", adjustment); - stp_set_curve_parameter_active(v, "MagentaCurve", STP_PARAMETER_ACTIVE); - stp_curve_destroy(adjustment); - } - if (caps->adj_yellow && - !stp_check_curve_parameter(v, "YellowCurve", STP_PARAMETER_ACTIVE)) - { - adjustment = stp_curve_create_from_string(caps->adj_yellow); - stp_set_curve_parameter(v, "YellowCurve", adjustment); - stp_set_curve_parameter_active(v, "YellowCurve", STP_PARAMETER_ACTIVE); - stp_curve_destroy(adjustment); - } + privdata.xsize = pv.prnw_px; + privdata.ysize = pv.prnh_px; - if (ink_type) - { - for (i = 0; i < caps->inks->n_items; i++) - if (strcmp(ink_type, caps->inks->item[i].name) == 0) - { - stp_set_string_parameter(v, "STPIOutputType", - caps->inks->item[i].output_type); - ink_channels = caps->inks->item[i].output_channels; - ink_order = caps->inks->item[i].channel_order; - break; - } - } + /* FIXME: move this into print_init_drv */ + ink_type = dyesub_describe_output_internal(v, &pv); + stp_set_string_parameter(v, "STPIOutputType", ink_type); stp_channel_reset(v); - for (i = 0; i < ink_channels; i++) + for (i = 0; i < pv.ink_channels; i++) stp_channel_add(v, i, 0, 1.0); - - out_channels = stp_color_init(v, image, 65536); - -#if 0 - if (out_channels != ink_channels && out_channels != 1 && ink_channels != 1) - { - stp_eprintf(v, "Internal error! Output channels or input channels must be 1\n"); - return 0; - } -#endif - - rows = stp_zalloc(image_px_height * sizeof(unsigned short *)); - err_out = stp_malloc(print_px_width * ink_channels * 2); - if (out_channels != ink_channels) - final_out = stp_malloc(print_px_width * ink_channels * 2); - + pv.out_channels = stp_color_init(v, image, 65536); + pv.bytes_per_ink_channel = 1; /* FIXME: this is printer dependent */ + pv.bytes_per_out_channel = 2; /* FIXME: this is ??? */ + pv.image_data = dyesub_read_image(v, &pv, image); + pv.empty_byte = (ink_type && + (strcmp(ink_type, "RGB") == 0 || strcmp(ink_type, "BGR") == 0) + ? '\xff' : '\0'); + pv.plane_interlacing = dyesub_feature(caps, DYESUB_FEATURE_PLANE_INTERLACE); + pv.print_mode = page_mode; + if (!pv.image_data) + return 2; + /* /FIXME */ + + + dyesub_adjust_curve(v, caps->adj_cyan, "CyanCurve"); + dyesub_adjust_curve(v, caps->adj_magenta, "MagentaCurve"); + dyesub_adjust_curve(v, caps->adj_yellow, "YellowCurve"); stp_set_float_parameter(v, "Density", 1.0); - if (ink_type && - (strcmp(ink_type, "RGB") == 0 || strcmp(ink_type, "BGR") == 0)) - { - zeros = stp_malloc(ink_channels * print_px_width + 1); - (void) memset(zeros, '\xff', ink_channels * print_px_width + 1); - } - else - zeros = stp_zalloc(ink_channels * print_px_width + 1); - - out_bytes = (caps->interlacing == OLYMPUS_INTERLACE_PLANE ? 1 : ink_channels); - - /* printer init */ - if (caps->printer_init_func) - { - stp_deprintf(STP_DBG_OLYMPUS, "olympus: caps->printer_init\n"); - (*(caps->printer_init_func))(v); - } - if (olympus_feature(caps, OLYMPUS_FEATURE_FULL_HEIGHT)) + if (dyesub_feature(caps, DYESUB_FEATURE_FULL_HEIGHT)) { - min_y = 0; - max_y = print_px_height - 1; + pv.prnt_px = 0; + pv.prnb_px = pv.prnh_px - 1; } - else if (olympus_feature(caps, OLYMPUS_FEATURE_BLOCK_ALIGN)) + else if (dyesub_feature(caps, DYESUB_FEATURE_BLOCK_ALIGN)) { - min_y = out_px_top - (out_px_top % caps->block_size); + pv.prnt_px = pv.outt_px - (pv.outt_px % caps->block_size); /* floor to multiple of block_size */ - max_y = (out_px_bottom - 1) + (caps->block_size - 1) - - ((out_px_bottom - 1) % caps->block_size); + pv.prnb_px = (pv.outb_px - 1) + (caps->block_size - 1) + - ((pv.outb_px - 1) % caps->block_size); /* ceil to multiple of block_size */ } else { - min_y = out_px_top; - max_y = out_px_bottom - 1; + pv.prnt_px = pv.outt_px; + pv.prnb_px = pv.outb_px - 1; } - if (olympus_feature(caps, OLYMPUS_FEATURE_FULL_WIDTH)) + if (dyesub_feature(caps, DYESUB_FEATURE_FULL_WIDTH)) { - min_x = 0; - max_x = print_px_width - 1; + pv.prnl_px = 0; + pv.prnr_px = pv.prnw_px - 1; } else { - min_x = out_px_left; - max_x = out_px_right; + pv.prnl_px = pv.outl_px; + pv.prnr_px = pv.outr_px; } - r_errdiv = image_px_height / out_px_height; - r_errmod = image_px_height % out_px_height; - c_errdiv = image_px_width / out_px_width; - c_errmod = image_px_width % out_px_width; - - for (pl = 0; pl < (caps->interlacing == OLYMPUS_INTERLACE_PLANE - ? ink_channels : 1); pl++) + if (pv.print_mode == DYESUB_LANDSCAPE) { - r_errval = 0; - r_errlast = -1; - r_errline = 0; + dyesub_swap_ints(&pv.outh_px, &pv.outw_px); + dyesub_swap_ints(&pv.outt_px, &pv.outl_px); + dyesub_swap_ints(&pv.outb_px, &pv.outr_px); + + dyesub_swap_ints(&pv.prnh_px, &pv.prnw_px); + dyesub_swap_ints(&pv.prnt_px, &pv.prnl_px); + dyesub_swap_ints(&pv.prnb_px, &pv.prnr_px); + + dyesub_swap_ints(&pv.imgh_px, &pv.imgw_px); + } - privdata.plane = ink_order[pl]; - stp_deprintf(STP_DBG_OLYMPUS, "olympus: plane %d\n", privdata.plane); + /* printer init */ + dyesub_exec(v, caps->printer_init_func, "caps->printer_init"); + + for (pl = 0; pl < (pv.plane_interlacing ? pv.ink_channels : 1); pl++) + { + privdata.plane = pv.ink_order[pl]; + stp_deprintf(STP_DBG_DYESUB, "dyesub: plane %d\n", privdata.plane); /* plane init */ - if (caps->plane_init_func) - { - stp_deprintf(STP_DBG_OLYMPUS, "olympus: caps->plane_init\n"); - (*(caps->plane_init_func))(v); - } - - for (y = min_y; y <= max_y; y++) - { - unsigned short *out; - int duplicate_line = 1; -/* unsigned zero_mask; */ - - if (((y - min_y) % caps->block_size) == 0) - { - /* block init */ - privdata.block_min_y = y; - privdata.block_min_x = min_x; - privdata.block_max_y = MIN(y + caps->block_size - 1, max_y); - privdata.block_max_x = max_x; - - if (caps->block_init_func) - { - stp_deprintf(STP_DBG_OLYMPUS, - "olympus: caps->block_init\n"); - (*(caps->block_init_func))(v); - } - } - - if (y < out_px_top || y >= out_px_bottom) - stp_zfwrite((char *) zeros, out_bytes, print_px_width, v); - else - { - if (olympus_feature(caps, OLYMPUS_FEATURE_FULL_WIDTH) - && out_px_left > 0) - { - stp_zfwrite((char *) zeros, out_bytes, out_px_left, v); - /* stp_erprintf("left %d ", out_px_left); */ - } - -#if 0 - if (r_errline != r_errlast) - { - r_errlast = r_errline; - duplicate_line = 0; - - /* stp_erprintf("r_errline %d, ", r_errline); */ - if (stp_color_get_row(v, image, r_errline, &zero_mask)) - { - status = 2; - break; - } - } - - out = stp_channel_get_output(v); -#endif - if (r_errline != r_errlast) - { - r_errlast = r_errline; - duplicate_line = 0; - } - - out = olympus_get_cached_output(v, image, rows, r_errline, - image_px_width * ink_channels * 2); - if (out == NULL) - { - status = 2; - break; - } - - c_errval = 0; - c_errlast = -1; - c_errcol = 0; - for (i = 0; i < out_px_width; i++) - { - if (c_errcol != c_errlast) - c_errlast = c_errcol; - for (j = 0; j < ink_channels; j++) - err_out[i * ink_channels + j] = - out[c_errcol * ink_channels + ink_order[j]-1]; - - c_errval += c_errmod; - c_errcol += c_errdiv; - if (c_errval >= out_px_width) - { - c_errval -= out_px_width; - c_errcol ++; - } - } - - real_out = err_out; - if (out_channels != ink_channels) - { - real_out = final_out; - if (out_channels < ink_channels) - { - for (i = 0; i < out_px_width; i++) - { - for (j = 0; j < ink_channels; j++) - final_out[i * ink_channels + j] = err_out[i]; - } - } - else - { - for (i = 0; i < out_px_width; i++) - { - int avg = 0; - for (j = 0; j < out_channels; j++) - avg += err_out[i * out_channels + j]; - final_out[i] = avg / out_channels; - } - } - } - char_out = (unsigned char *) real_out; - char_out_width = (caps->interlacing == OLYMPUS_INTERLACE_PLANE ? - out_px_width : out_px_width * out_channels); - for (i = 0; i < char_out_width; i++) - { - if (caps->interlacing == OLYMPUS_INTERLACE_PLANE) - j = i * ink_channels + pl; - else if (caps->interlacing == OLYMPUS_INTERLACE_LINE) - j = (i % out_px_width) + (i / out_px_width); - else /* OLYMPUS_INTERLACE_NONE */ - j = i; - - char_out[i] = real_out[j] / 257; - } - - stp_zfwrite((char *) real_out, 1, char_out_width, v); - /* stp_erprintf("data %d ", out_px_width); */ - if (olympus_feature(caps, OLYMPUS_FEATURE_FULL_WIDTH) - && out_px_right < print_px_width) - { - stp_zfwrite((char *) zeros, out_bytes, - print_px_width - out_px_right, v); - /* stp_erprintf("right %d ", print_px_width-out_px_right); */ - } - /* stp_erprintf("\n"); */ + dyesub_exec(v, caps->plane_init_func, "caps->plane_init"); - r_errval += r_errmod; - r_errline += r_errdiv; - if (r_errval >= out_px_height) - { - r_errval -= out_px_height; - r_errline ++; - } - } - - if (y == privdata.block_max_y) - { - /* block end */ - if (caps->block_end_func) - { - stp_deprintf(STP_DBG_OLYMPUS, "olympus: caps->block_end\n"); - (*(caps->block_end_func))(v); - } - } - } + dyesub_print_plane(v, &pv, caps, (int) pv.ink_order[pl] - 1); /* plane end */ - if (caps->plane_end_func) { - stp_deprintf(STP_DBG_OLYMPUS, "olympus: caps->plane_end\n"); - (*(caps->plane_end_func))(v); - } + dyesub_exec(v, caps->plane_end_func, "caps->plane_end"); } /* printer end */ - if (caps->printer_end_func) - { - stp_deprintf(STP_DBG_OLYMPUS, "olympus: caps->printer_end\n"); - (*(caps->printer_end_func))(v); - } - stp_image_conclude(image); - if (final_out) - stp_free(final_out); - if (err_out) - stp_free(err_out); - if (zeros) - stp_free(zeros); - if (rows) - { - for (i = 0; i <image_px_height; i++) - stp_free(rows[i]); - stp_free(rows); - } + dyesub_exec(v, caps->printer_end_func, "caps->printer_end"); + + dyesub_free_image(pv.image_data, image); return status; } static int -olympus_print(const stp_vars_t *v, stp_image_t *image) +dyesub_print(const stp_vars_t *v, stp_image_t *image) { int status; stp_vars_t *nv = stp_vars_create_copy(v); stp_prune_inactive_options(nv); - status = olympus_do_print(nv, image); + status = dyesub_do_print(nv, image); stp_vars_destroy(nv); return status; } -static const stp_printfuncs_t print_olympus_printfuncs = -{ - olympus_list_parameters, - olympus_parameters, - stp_default_media_size, - olympus_imageable_area, - olympus_maximum_imageable_area, - olympus_limit, - olympus_print, - olympus_describe_resolution, - olympus_describe_output, +static const stp_printfuncs_t print_dyesub_printfuncs = +{ + dyesub_list_parameters, + dyesub_parameters, + dyesub_media_size, + dyesub_imageable_area, + dyesub_maximum_imageable_area, + dyesub_limit, + dyesub_print, + dyesub_describe_resolution, + dyesub_describe_output, stp_verify_printer_params, NULL, NULL @@ -2191,24 +2504,24 @@ static const stp_printfuncs_t print_olympus_printfuncs = -static stp_family_t print_olympus_module_data = +static stp_family_t print_dyesub_module_data = { - &print_olympus_printfuncs, + &print_dyesub_printfuncs, NULL }; static int -print_olympus_module_init(void) +print_dyesub_module_init(void) { - return stp_family_register(print_olympus_module_data.printer_list); + return stp_family_register(print_dyesub_module_data.printer_list); } static int -print_olympus_module_exit(void) +print_dyesub_module_exit(void) { - return stp_family_unregister(print_olympus_module_data.printer_list); + return stp_family_unregister(print_dyesub_module_data.printer_list); } @@ -2225,8 +2538,8 @@ stp_module_t stp_module_data = "Olympus family driver", STP_MODULE_CLASS_FAMILY, NULL, - print_olympus_module_init, - print_olympus_module_exit, - (void *) &print_olympus_module_data + print_dyesub_module_init, + print_dyesub_module_exit, + (void *) &print_dyesub_module_data }; |