diff options
author | Roger Leigh <rleigh@debian.org> | 2009-08-02 12:01:21 +0100 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2009-08-02 12:01:21 +0100 |
commit | 0f09a5be038c93c1bd5ca2988e152345bbf74c00 (patch) | |
tree | 279995ae9eece33b9b05cd82993f4fce98356fe8 /src/main | |
parent | a68ece422e0be1a0101dae2fa2408ef0e533c2e9 (diff) |
Imported Upstream version 5.2.4
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/Makefile.in | 33 | ||||
-rw-r--r-- | src/main/bit-ops.c | 1086 | ||||
-rw-r--r-- | src/main/channel.c | 8 | ||||
-rw-r--r-- | src/main/escp2-channels.c | 10 | ||||
-rw-r--r-- | src/main/escp2-papers.c | 5 | ||||
-rw-r--r-- | src/main/print-escp2.c | 272 | ||||
-rw-r--r-- | src/main/print-escp2.h | 13 | ||||
-rw-r--r-- | src/main/print-olympus.c | 174 | ||||
-rw-r--r-- | src/main/print-weave.c | 114 |
9 files changed, 986 insertions, 729 deletions
diff --git a/src/main/Makefile.in b/src/main/Makefile.in index cd04b9d..8fbf0f9 100644 --- a/src/main/Makefile.in +++ b/src/main/Makefile.in @@ -45,11 +45,14 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/isc-posix.m4 \ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/nls.m4 \ - $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/stp.m4 $(top_srcdir)/m4/stp_cups.m4 \ - $(top_srcdir)/m4/stp_gimp.m4 $(top_srcdir)/m4/stp_option.m4 \ - $(top_srcdir)/m4/stp_release.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/stp.m4 \ + $(top_srcdir)/m4/stp_cups.m4 $(top_srcdir)/m4/stp_gimp.m4 \ + $(top_srcdir)/m4/stp_option.m4 $(top_srcdir)/m4/stp_release.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs @@ -217,10 +220,6 @@ CUPS_CFLAGS = @CUPS_CFLAGS@ CUPS_CONFIG = @CUPS_CONFIG@ CUPS_LIBS = @CUPS_LIBS@ CUPS_PPD_PS_LEVEL = @CUPS_PPD_PS_LEVEL@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DB2HTML = @DB2HTML@ DB2PDF = @DB2PDF@ @@ -230,16 +229,15 @@ DEPDIR = @DEPDIR@ DIALOG = @DIALOG@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ DVIPDF = @DVIPDF@ DVIPS = @DVIPS@ -ECHO = @ECHO@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ +FGREP = @FGREP@ FIND = @FIND@ FOOMATIC_CONFIGURE = @FOOMATIC_CONFIGURE@ FOOMATIC_KITLOAD = @FOOMATIC_KITLOAD@ @@ -284,6 +282,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LD = @LD@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ @@ -295,6 +294,7 @@ LIBREADLINE_DEPS = @LIBREADLINE_DEPS@ LIBS = $(INTLLIBS) @LIBS@ LIBTOOL = @LIBTOOL@ LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIPO = @LIPO@ LN_S = @LN_S@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ @@ -307,8 +307,12 @@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NM = @NM@ NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -342,8 +346,7 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -388,6 +391,7 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -400,6 +404,7 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include $(LOCAL_CPPFLAGS) $(GNUCFLAGS) diff --git a/src/main/bit-ops.c b/src/main/bit-ops.c index a110adf..6ecf227 100644 --- a/src/main/bit-ops.c +++ b/src/main/bit-ops.c @@ -1,5 +1,5 @@ /* - * "$Id: bit-ops.c,v 1.12 2007/03/08 13:34:27 faust3 Exp $" + * "$Id: bit-ops.c,v 1.14 2009/06/07 15:21:22 rlk Exp $" * * Softweave calculator for Gutenprint. * @@ -49,7 +49,7 @@ stp_fold(const unsigned char *line, unsigned char l1 = line[single_length]; if (l0 || l1) { - outbuf[0] = + outbuf[0] = /* B7 A7 B6 A6 B5 A5 B4 A4 */ ((l0 & (1 << 7)) >> 1) + ((l0 & (1 << 6)) >> 2) + ((l0 & (1 << 5)) >> 3) + @@ -58,7 +58,7 @@ stp_fold(const unsigned char *line, ((l1 & (1 << 6)) >> 1) + ((l1 & (1 << 5)) >> 2) + ((l1 & (1 << 4)) >> 3); - outbuf[1] = + outbuf[1] = /* B3 A3 B2 A2 B1 A1 B0 A0 */ ((l0 & (1 << 3)) << 3) + ((l0 & (1 << 2)) << 2) + ((l0 & (1 << 1)) << 1) + @@ -80,34 +80,41 @@ stp_fold_3bit(const unsigned char *line, { int i; memset(outbuf, 0, single_length * 3); - for (i = 0; i < single_length; i++) { - outbuf[0] = - ((line[0] & (1 << 7)) >> 2) | - ((line[0] & (1 << 6)) >> 4) | - ((line[single_length] & (1 << 7)) >> 1) | - ((line[single_length] & (1 << 6)) >> 3) | - ((line[single_length] & (1 << 5)) >> 5) | - ((line[2*single_length] & (1 << 7)) << 0) | - ((line[2*single_length] & (1 << 6)) >> 2) | - ((line[2*single_length] & (1 << 5)) >> 4); - outbuf[1] = - ((line[0] & (1 << 5)) << 2) | - ((line[0] & (1 << 4)) << 0) | - ((line[0] & (1 << 3)) >> 2) | - ((line[single_length] & (1 << 4)) << 1) | - ((line[single_length] & (1 << 3)) >> 1) | - ((line[2*single_length] & (1 << 4)) << 2) | - ((line[2*single_length] & (1 << 3)) << 0) | - ((line[2*single_length] & (1 << 2)) >> 2); - outbuf[2] = - ((line[0] & (1 << 2)) << 4) | - ((line[0] & (1 << 1)) << 2) | - ((line[0] & (1 << 0)) << 0) | - ((line[single_length] & (1 << 2)) << 5) | - ((line[single_length] & (1 << 1)) << 3) | - ((line[single_length] & (1 << 0)) << 1) | - ((line[2*single_length] & (1 << 1)) << 4) | - ((line[2*single_length] & (1 << 0)) << 2); + for (i = 0; i < single_length; i++) + { + unsigned char l0 = line[0]; + unsigned char l1 = line[single_length]; + unsigned char l2 = line[single_length * 2]; + if (l0 || l1 || l2) + { + outbuf[0] = /* C7 B7 A7 C6 B6 A6 C5 B5 */ + ((l0 & (1 << 7)) >> 2) | + ((l0 & (1 << 6)) >> 4) | + ((l1 & (1 << 7)) >> 1) | + ((l1 & (1 << 6)) >> 3) | + ((l1 & (1 << 5)) >> 5) | + ((l2 & (1 << 7)) << 0) | + ((l2 & (1 << 6)) >> 2) | + ((l2 & (1 << 5)) >> 4); + outbuf[1] = /* A5 C4 B4 A4 C3 B3 A3 C2 */ + ((l0 & (1 << 5)) << 2) | + ((l0 & (1 << 4)) << 0) | + ((l0 & (1 << 3)) >> 2) | + ((l1 & (1 << 4)) << 1) | + ((l1 & (1 << 3)) >> 1) | + ((l2 & (1 << 4)) << 2) | + ((l2 & (1 << 3)) << 0) | + ((l2 & (1 << 2)) >> 2); + outbuf[2] = /* B2 A2 C1 B1 A1 C0 B0 A0 */ + ((l0 & (1 << 2)) << 4) | + ((l0 & (1 << 1)) << 2) | + ((l0 & (1 << 0)) << 0) | + ((l1 & (1 << 2)) << 5) | + ((l1 & (1 << 1)) << 3) | + ((l1 & (1 << 0)) << 1) | + ((l2 & (1 << 1)) << 4) | + ((l2 & (1 << 0)) << 2); + } line++; outbuf += 3; } @@ -115,100 +122,101 @@ stp_fold_3bit(const unsigned char *line, void stp_fold_3bit_323(const unsigned char *line, - int single_length, - unsigned char *outbuf) + int single_length, + unsigned char *outbuf) { - unsigned char A0,A1,A2,B0,B1,B2,C0,C1,C2; - const unsigned char *last= line+single_length; + const unsigned char *last= line + single_length; memset(outbuf, 0, single_length * 3); - for (; line < last; line+=3, outbuf+=8) { - - A0= line[0]; B0= line[single_length]; C0= line[2*single_length]; - - if (line<last-2) { - A1= line[1]; B1= line[single_length+1]; C1= line[2*single_length+1]; - } else { - A1= 0; B1= 0; C1= 0; - } - if (line<last-1) { - A2= line[2]; B2= line[single_length+2]; C2= line[2*single_length+2]; - } else { - A2= 0; B2= 0; C2= 0; + for (; line < last; line += 3) + { + unsigned char A0 = line[0]; + unsigned char B0 = line[single_length]; + unsigned char C0 = line[2*single_length]; + unsigned char A1 = (line < last - 2) ? line[1] : 0; + unsigned char B1 = (line < last - 2) ? line[single_length + 1] : 0; + unsigned char C1 = (line < last - 2) ? line[(single_length * 2) + 1] : 0; + unsigned char A2 = (line < last - 1) ? line[2] : 0; + unsigned char B2 = (line < last - 1) ? line[single_length + 2] : 0; + unsigned char C2 = (line < last - 1) ? line[(single_length * 2) + 2] : 0; + + if (A0 || A1 || A2 || B0 || B1 || B2 || C0 || C1 || C2) + { + /* Missing: C0_6, C0_3, C0_0, C1_5, C1_2, C2_7, C2_4, C2_1 ??? */ + outbuf[0] = /* C0_7 B0_7 A0_7 B0_6 A0_6 C0_5 B0_5 A0_5 */ + ((C0 & (1 << 7)) >> 0) | + ((B0 & (1 << 7)) >> 1) | + ((A0 & (1 << 7)) >> 2) | + ((B0 & (1 << 6)) >> 2) | + ((A0 & (1 << 6)) >> 3) | + ((C0 & (1 << 5)) >> 3) | + ((B0 & (1 << 5)) >> 4) | + ((A0 & (1 << 5)) >> 5); + outbuf[1] = /* C0_4 B0_4 A0_4 B0_3 A0_3 C0_2 B0_2 A0_2 */ + ((C0 & (1 << 4)) << 3) | + ((B0 & (1 << 4)) << 2) | + ((A0 & (1 << 4)) << 1) | + ((B0 & (1 << 3)) << 1) | + ((A0 & (1 << 3)) << 0) | + ((C0 & (1 << 2)) >> 0) | + ((B0 & (1 << 2)) >> 1) | + ((A0 & (1 << 2)) >> 2); + outbuf[2] = /* C0_1 B0_1 A0_1 B0_0 A0_0 C1_7 B1_7 A1_7 */ + ((C0 & (1 << 1)) << 6) | + ((B0 & (1 << 1)) << 5) | + ((A0 & (1 << 1)) << 4) | + ((B0 & (1 << 0)) << 4) | + ((A0 & (1 << 0)) << 3) | + ((C1 & (1 << 7)) >> 5) | + ((B1 & (1 << 7)) >> 6) | + ((A1 & (1 << 7)) >> 7); + outbuf[3] = /* C1_6 B1_6 A1_6 B1_5 A1_5 C1_4 B1_4 A1_4 */ + ((C1 & (1 << 6)) << 1) | + ((B1 & (1 << 6)) << 0) | + ((A1 & (1 << 6)) >> 1) | + ((B1 & (1 << 5)) >> 1) | + ((A1 & (1 << 5)) >> 2) | + ((C1 & (1 << 4)) >> 2) | + ((B1 & (1 << 4)) >> 3) | + ((A1 & (1 << 4)) >> 4); + outbuf[4] = /* C1_3 B1_3 A1_3 B1_2 A1_2 C1_1 B1_1 A1_1 */ + ((C1 & (1 << 3)) << 4) | + ((B1 & (1 << 3)) << 3) | + ((A1 & (1 << 3)) << 2) | + ((B1 & (1 << 2)) << 2) | + ((A1 & (1 << 2)) << 1) | + ((C1 & (1 << 1)) << 1) | + ((B1 & (1 << 1)) >> 0) | + ((A1 & (1 << 1)) >> 1); + outbuf[5] = /* C1_0 B1_0 A1_0 B2_7 A2_7 C2_6 B2_6 A2_6 */ + ((C1 & (1 << 0)) << 7) | + ((B1 & (1 << 0)) << 6) | + ((A1 & (1 << 0)) << 5) | + ((B2 & (1 << 7)) >> 3) | + ((A2 & (1 << 7)) >> 4) | + ((C2 & (1 << 6)) >> 4) | + ((B2 & (1 << 6)) >> 5) | + ((A2 & (1 << 6)) >> 6); + outbuf[6] = /* C2_5 B2_5 A2_5 B2_4 A2_4 C2_3 B2_3 A2_3 */ + ((C2 & (1 << 5)) << 2) | + ((B2 & (1 << 5)) << 1) | + ((A2 & (1 << 5)) << 0) | + ((B2 & (1 << 4)) >> 0) | + ((A2 & (1 << 4)) >> 1) | + ((C2 & (1 << 3)) >> 1) | + ((B2 & (1 << 3)) >> 2) | + ((A2 & (1 << 3)) >> 3); + outbuf[7] = /* C2_2 B2_2 A2_2 B2_1 A2_1 C2_0 B2_0 A2_0 */ + ((C2 & (1 << 2)) << 5) | + ((B2 & (1 << 2)) << 4) | + ((A2 & (1 << 2)) << 3) | + ((B2 & (1 << 1)) << 3) | + ((A2 & (1 << 1)) << 2) | + ((C2 & (1 << 0)) << 2) | + ((B2 & (1 << 0)) << 1) | + ((A2 & (1 << 0)) << 0); + } + outbuf += 8; } - - outbuf[0] = - ((C0 & 0x80) >> 0) | - ((B0 & 0x80) >> 1) | - ((A0 & 0x80) >> 2) | - ((B0 & 0x40) >> 2) | - ((A0 & 0x40) >> 3) | - ((C0 & 0x20) >> 3) | - ((B0 & 0x20) >> 4) | - ((A0 & 0x20) >> 5); - outbuf[1] = - ((C0 & 0x10) << 3) | - ((B0 & 0x10) << 2) | - ((A0 & 0x10) << 1) | - ((B0 & 0x08) << 1) | - ((A0 & 0x08) << 0) | - ((C0 & 0x04) >> 0) | - ((B0 & 0x04) >> 1) | - ((A0 & 0x04) >> 2); - outbuf[2] = - ((C0 & 0x02) << 6) | - ((B0 & 0x02) << 5) | - ((A0 & 0x02) << 4) | - ((B0 & 0x01) << 4) | - ((A0 & 0x01) << 3) | - ((C1 & 0x80) >> 5) | - ((B1 & 0x80) >> 6) | - ((A1 & 0x80) >> 7); - outbuf[3] = - ((C1 & 0x40) << 1) | - ((B1 & 0x40) << 0) | - ((A1 & 0x40) >> 1) | - ((B1 & 0x20) >> 1) | - ((A1 & 0x20) >> 2) | - ((C1 & 0x10) >> 2) | - ((B1 & 0x10) >> 3) | - ((A1 & 0x10) >> 4); - outbuf[4] = - ((C1 & 0x08) << 4) | - ((B1 & 0x08) << 3) | - ((A1 & 0x08) << 2) | - ((B1 & 0x04) << 2) | - ((A1 & 0x04) << 1) | - ((C1 & 0x02) << 1) | - ((B1 & 0x02) >> 0) | - ((A1 & 0x02) >> 1); - outbuf[5] = - ((C1 & 0x01) << 7) | - ((B1 & 0x01) << 6) | - ((A1 & 0x01) << 5) | - ((B2 & 0x80) >> 3) | - ((A2 & 0x80) >> 4) | - ((C2 & 0x40) >> 4) | - ((B2 & 0x40) >> 5) | - ((A2 & 0x40) >> 6); - outbuf[6] = - ((C2 & 0x20) << 2) | - ((B2 & 0x20) << 1) | - ((A2 & 0x20) << 0) | - ((B2 & 0x10) >> 0) | - ((A2 & 0x10) >> 1) | - ((C2 & 0x08) >> 1) | - ((B2 & 0x08) >> 2) | - ((A2 & 0x08) >> 3); - outbuf[7] = - ((C2 & 0x04) << 5) | - ((B2 & 0x04) << 4) | - ((A2 & 0x04) << 3) | - ((B2 & 0x02) << 3) | - ((A2 & 0x02) << 2) | - ((C2 & 0x01) << 2) | - ((B2 & 0x01) << 1) | - ((A2 & 0x01) << 0); - } } void @@ -218,158 +226,120 @@ stp_fold_4bit(const unsigned char *line, { int i; memset(outbuf, 0, single_length * 4); - for (i = 0; i < single_length; i++){ - unsigned char l0 = line[0]; - unsigned char l1 = line[single_length]; - unsigned char l2 = line[single_length*2]; - unsigned char l3 = line[single_length*3]; - if(l0 || l1 || l2 || l3){ - outbuf[0] = - ((l3 & (1<<7)) >> 0)| - ((l2 & (1<<7)) >> 1)| - ((l1 & (1<<7)) >> 2)| - ((l0 & (1<<7)) >> 3)| - ((l3 & (1<<6)) >> 3)| - ((l2 & (1<<6)) >> 4)| - ((l1 & (1<<6)) >> 5)| - ((l0 & (1<<6)) >> 6); - - outbuf[1] = - ((l3 & (1<<5)) << 2)| - ((l2 & (1<<5)) << 1)| - ((l1 & (1<<5)) << 0)| - ((l0 & (1<<5)) >> 1)| - ((l3 & (1<<4)) >> 1)| - ((l2 & (1<<4)) >> 2)| - ((l1 & (1<<4)) >> 3)| - ((l0 & (1<<4)) >> 4); - - outbuf[2] = - ((l3 & (1<<3)) << 4)| - ((l2 & (1<<3)) << 3)| - ((l1 & (1<<3)) << 2)| - ((l0 & (1<<3)) << 1)| - ((l3 & (1<<2)) << 1)| - ((l2 & (1<<2)) << 0)| - ((l1 & (1<<2)) >> 1)| - ((l0 & (1<<2)) >> 2); - outbuf[3] = - ((l3 & (1<<1)) << 6)| - ((l2 & (1<<1)) << 5)| - ((l1 & (1<<1)) << 4)| - ((l0 & (1<<1)) << 3)| - ((l3 & (1<<0)) << 3)| - ((l2 & (1<<0)) << 2)| - ((l1 & (1<<0)) << 1)| - ((l0 & (1<<0)) << 0); - } - line++; - outbuf += 4; - } -} - -static void -stpi_split_2_1(int length, - const unsigned char *in, - unsigned char *outhi, - unsigned char *outlo) -{ - unsigned char *outs[2]; - int i; - int row = 0; - int limit = length; - outs[0] = outhi; - outs[1] = outlo; - memset(outs[1], 0, limit); - for (i = 0; i < limit; i++) + for (i = 0; i < single_length; i++) { - unsigned char inbyte = in[i]; - outs[0][i] = 0; - if (inbyte == 0) - continue; - /* For some reason gcc isn't unrolling this, even with -funroll-loops */ - if (inbyte & 1) - { - outs[row][i] |= 1 & inbyte; - row = row ^ 1; - } - if (inbyte & (1 << 1)) - { - outs[row][i] |= (1 << 1) & inbyte; - row = row ^ 1; - } - if (inbyte & (1 << 2)) - { - outs[row][i] |= (1 << 2) & inbyte; - row = row ^ 1; - } - if (inbyte & (1 << 3)) - { - outs[row][i] |= (1 << 3) & inbyte; - row = row ^ 1; - } - if (inbyte & (1 << 4)) - { - outs[row][i] |= (1 << 4) & inbyte; - row = row ^ 1; - } - if (inbyte & (1 << 5)) - { - outs[row][i] |= (1 << 5) & inbyte; - row = row ^ 1; - } - if (inbyte & (1 << 6)) - { - outs[row][i] |= (1 << 6) & inbyte; - row = row ^ 1; - } - if (inbyte & (1 << 7)) + unsigned char l0 = line[0]; + unsigned char l1 = line[single_length]; + unsigned char l2 = line[single_length*2]; + unsigned char l3 = line[single_length*3]; + if (l0 || l1 || l2 || l3) { - outs[row][i] |= (1 << 7) & inbyte; - row = row ^ 1; + outbuf[0] = /* D7 C7 B7 A7 D6 C6 B6 A6 */ + ((l3 & (1 << 7)) >> 0)| + ((l2 & (1 << 7)) >> 1)| + ((l1 & (1 << 7)) >> 2)| + ((l0 & (1 << 7)) >> 3)| + ((l3 & (1 << 6)) >> 3)| + ((l2 & (1 << 6)) >> 4)| + ((l1 & (1 << 6)) >> 5)| + ((l0 & (1 << 6)) >> 6); + + outbuf[1] = /* D5 C5 B5 A5 D4 C4 B4 A4 */ + ((l3 & (1 << 5)) << 2)| + ((l2 & (1 << 5)) << 1)| + ((l1 & (1 << 5)) << 0)| + ((l0 & (1 << 5)) >> 1)| + ((l3 & (1 << 4)) >> 1)| + ((l2 & (1 << 4)) >> 2)| + ((l1 & (1 << 4)) >> 3)| + ((l0 & (1 << 4)) >> 4); + + outbuf[2] = /* D3 C3 B3 A3 D2 C2 B2 A2 */ + ((l3 & (1 << 3)) << 4)| + ((l2 & (1 << 3)) << 3)| + ((l1 & (1 << 3)) << 2)| + ((l0 & (1 << 3)) << 1)| + ((l3 & (1 << 2)) << 1)| + ((l2 & (1 << 2)) << 0)| + ((l1 & (1 << 2)) >> 1)| + ((l0 & (1 << 2)) >> 2); + + outbuf[3] = /* D1 C1 B1 A1 D0 C0 B0 A0 */ + ((l3 & (1 << 1)) << 6)| + ((l2 & (1 << 1)) << 5)| + ((l1 & (1 << 1)) << 4)| + ((l0 & (1 << 1)) << 3)| + ((l3 & (1 << 0)) << 3)| + ((l2 & (1 << 0)) << 2)| + ((l1 & (1 << 0)) << 1)| + ((l0 & (1 << 0)) << 0); } + line++; + outbuf += 4; } } -static void -stp_split_2_2(int length, - const unsigned char *in, - unsigned char *outhi, - unsigned char *outlo) +#define SPLIT_MASK(k, b) (((1 << (b)) - 1) << ((k) * (b))) + +#define SPLIT_STEP(k, b, i, o, in, r, inc, rl) \ +do \ + { \ + if (in & SPLIT_MASK(k, b)) \ + { \ + o[r][i] |= SPLIT_MASK(k, b) & in; \ + r += inc; \ + if (r >= rl) \ + r = 0; \ + } \ + } while (0) + +void +stp_split(int length, + int bits, + int n, + const unsigned char *in, + int increment, + unsigned char **outs) { - unsigned char *outs[2]; + int row = 0; + int limit = length * bits; + int rlimit = n * increment; int i; - unsigned row = 0; - int limit = length * 2; - outs[0] = outhi; - outs[1] = outlo; - memset(outs[1], 0, limit); - for (i = 0; i < limit; i++) + for (i = 1; i < n; i++) + memset(outs[i * increment], 0, limit); + + if (bits == 1) { - unsigned char inbyte = in[i]; - outs[0][i] = 0; - if (inbyte == 0) - continue; - /* For some reason gcc isn't unrolling this, even with -funroll-loops */ - if (inbyte & 3) - { - outs[row][i] |= (3 & inbyte); - row = row ^ 1; - } - if (inbyte & (3 << 2)) + for (i = 0; i < limit; i++) { - outs[row][i] |= ((3 << 2) & inbyte); - row = row ^ 1; + unsigned char inbyte = in[i]; + outs[0][i] = 0; + if (inbyte == 0) + continue; + /* For some reason gcc isn't unrolling this, even with -funroll-loops */ + SPLIT_STEP(0, 1, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(1, 1, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(2, 1, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(3, 1, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(4, 1, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(5, 1, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(6, 1, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(7, 1, i, outs, inbyte, row, increment, rlimit); } - if (inbyte & (3 << 4)) - { - outs[row][i] |= ((3 << 4) & inbyte); - row = row ^ 1; - } - if (inbyte & (3 << 6)) + } + else + { + for (i = 0; i < limit; i++) { - outs[row][i] |= ((3 << 6) & inbyte); - row = row ^ 1; + unsigned char inbyte = in[i]; + outs[0][i] = 0; + if (inbyte == 0) + continue; + /* For some reason gcc isn't unrolling this, even with -funroll-loops */ + SPLIT_STEP(0, 2, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(1, 2, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(2, 2, i, outs, inbyte, row, increment, rlimit); + SPLIT_STEP(3, 2, i, outs, inbyte, row, increment, rlimit); } } } @@ -381,128 +351,10 @@ stp_split_2(int length, unsigned char *outhi, unsigned char *outlo) { - if (bits == 2) - stp_split_2_2(length, in, outhi, outlo); - else - stpi_split_2_1(length, in, outhi, outlo); -} - -static void -stpi_split_4_1(int length, - const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3) -{ - unsigned char *outs[4]; - int i; - int row = 0; - int limit = length; - outs[0] = out0; - outs[1] = out1; - outs[2] = out2; - outs[3] = out3; - memset(outs[1], 0, limit); - memset(outs[2], 0, limit); - memset(outs[3], 0, limit); - for (i = 0; i < limit; i++) - { - unsigned char inbyte = in[i]; - outs[0][i] = 0; - if (inbyte == 0) - continue; - /* For some reason gcc isn't unrolling this, even with -funroll-loops */ - if (inbyte & 1) - { - outs[row][i] |= 1 & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (1 << 1)) - { - outs[row][i] |= (1 << 1) & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (1 << 2)) - { - outs[row][i] |= (1 << 2) & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (1 << 3)) - { - outs[row][i] |= (1 << 3) & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (1 << 4)) - { - outs[row][i] |= (1 << 4) & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (1 << 5)) - { - outs[row][i] |= (1 << 5) & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (1 << 6)) - { - outs[row][i] |= (1 << 6) & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (1 << 7)) - { - outs[row][i] |= (1 << 7) & inbyte; - row = (row + 1) & 3; - } - } -} - -static void -stpi_split_4_2(int length, - const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3) -{ - unsigned char *outs[4]; - int i; - int row = 0; - int limit = length * 2; - outs[0] = out0; - outs[1] = out1; - outs[2] = out2; - outs[3] = out3; - memset(outs[1], 0, limit); - memset(outs[2], 0, limit); - memset(outs[3], 0, limit); - for (i = 0; i < limit; i++) - { - unsigned char inbyte = in[i]; - outs[0][i] = 0; - if (inbyte == 0) - continue; - /* For some reason gcc isn't unrolling this, even with -funroll-loops */ - if (inbyte & 3) - { - outs[row][i] |= 3 & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (3 << 2)) - { - outs[row][i] |= (3 << 2) & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (3 << 4)) - { - outs[row][i] |= (3 << 4) & inbyte; - row = (row + 1) & 3; - } - if (inbyte & (3 << 6)) - { - outs[row][i] |= (3 << 6) & inbyte; - row = (row + 1) & 3; - } - } + unsigned char *outs[2]; + outs[0] = outhi; + outs[1] = outlo; + stp_split(length, bits, 2, in, 1, outs); } void @@ -514,26 +366,19 @@ stp_split_4(int length, unsigned char *out2, unsigned char *out3) { - if (bits == 2) - stpi_split_4_2(length, in, out0, out1, out2, out3); - else - stpi_split_4_1(length, in, out0, out1, out2, out3); + unsigned char *outs[4]; + outs[0] = out0; + outs[1] = out1; + outs[2] = out2; + outs[3] = out3; + stp_split(length, bits, 4, in, 1, outs); } -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define SH20 0 -#define SH21 8 -#else -#define SH20 8 -#define SH21 0 -#endif - static void stpi_unpack_2_1(int length, const unsigned char *in, - unsigned char *out0, - unsigned char *out1) + unsigned char **outs) { unsigned char tempin, bit, temp0, temp1; @@ -570,8 +415,8 @@ stpi_unpack_2_1(int length, else { bit = 128; - *out0++ = temp0; - *out1++ = temp1; + *outs[0]++ = temp0; + *outs[1]++ = temp1; temp0 = 0; temp1 = 0; @@ -580,16 +425,15 @@ stpi_unpack_2_1(int length, if (bit < 128) { - *out0++ = temp0; - *out1++ = temp1; + *outs[0]++ = temp0; + *outs[1]++ = temp1; } } static void stpi_unpack_2_2(int length, - const unsigned char *in, - unsigned char *out0, - unsigned char *out1) + const unsigned char *in, + unsigned char **outs) { if (length <= 0) return; @@ -600,11 +444,11 @@ stpi_unpack_2_2(int length, ti0 = in[0]; ti1 = in[1]; - *out0++ = (ti0 & 0xc0) << 0 + *outs[0]++ = (ti0 & 0xc0) << 0 | (ti0 & 0x0c) << 2 | (ti1 & 0xc0) >> 4 | (ti1 & 0x0c) >> 2; - *out1++ = (ti0 & 0x30) << 2 + *outs[1]++ = (ti0 & 0x30) << 2 | (ti0 & 0x03) << 4 | (ti1 & 0x30) >> 2 | (ti1 & 0x03) >> 0; @@ -612,38 +456,10 @@ stpi_unpack_2_2(int length, } } -void -stp_unpack_2(int length, - int bits, - const unsigned char *in, - unsigned char *outlo, - unsigned char *outhi) -{ - if (bits == 1) - stpi_unpack_2_1(length, in, outlo, outhi); - else - stpi_unpack_2_2(length, in, outlo, outhi); -} - -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define SH40 0 -#define SH41 8 -#define SH42 16 -#define SH43 24 -#else -#define SH40 24 -#define SH41 16 -#define SH42 8 -#define SH43 0 -#endif - static void stpi_unpack_4_1(int length, const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3) + unsigned char **outs) { unsigned char tempin, bit, temp0, temp1, temp2, temp3; @@ -678,10 +494,10 @@ stpi_unpack_4_1(int length, else { bit = 128; - *out0++ = temp0; - *out1++ = temp1; - *out2++ = temp2; - *out3++ = temp3; + *outs[0]++ = temp0; + *outs[1]++ = temp1; + *outs[2]++ = temp2; + *outs[3]++ = temp3; temp0 = 0; temp1 = 0; @@ -692,20 +508,17 @@ stpi_unpack_4_1(int length, if (bit < 128) { - *out0++ = temp0; - *out1++ = temp1; - *out2++ = temp2; - *out3++ = temp3; + *outs[0]++ = temp0; + *outs[1]++ = temp1; + *outs[2]++ = temp2; + *outs[3]++ = temp3; } } static void stpi_unpack_4_2(int length, const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3) + unsigned char **outs) { unsigned char tempin, shift, @@ -741,10 +554,10 @@ stpi_unpack_4_2(int length, else { shift = 0; - *out0++ = temp0; - *out1++ = temp1; - *out2++ = temp2; - *out3++ = temp3; + *outs[0]++ = temp0; + *outs[1]++ = temp1; + *outs[2]++ = temp2; + *outs[3]++ = temp3; temp0 = 0; temp1 = 0; @@ -755,39 +568,17 @@ stpi_unpack_4_2(int length, if (shift) { - *out0++ = temp0; - *out1++ = temp1; - *out2++ = temp2; - *out3++ = temp3; + *outs[0]++ = temp0; + *outs[1]++ = temp1; + *outs[2]++ = temp2; + *outs[3]++ = temp3; } } -void -stp_unpack_4(int length, - int bits, - const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3) -{ - if (bits == 1) - stpi_unpack_4_1(length, in, out0, out1, out2, out3); - else - stpi_unpack_4_2(length, in, out0, out1, out2, out3); -} - static void stpi_unpack_8_1(int length, const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3, - unsigned char *out4, - unsigned char *out5, - unsigned char *out6, - unsigned char *out7) + unsigned char **outs) { unsigned char tempin, bit, temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; @@ -824,14 +615,14 @@ stpi_unpack_8_1(int length, else { bit = 128; - *out0++ = temp0; - *out1++ = temp1; - *out2++ = temp2; - *out3++ = temp3; - *out4++ = temp4; - *out5++ = temp5; - *out6++ = temp6; - *out7++ = temp7; + *outs[0]++ = temp0; + *outs[1]++ = temp1; + *outs[2]++ = temp2; + *outs[3]++ = temp3; + *outs[4]++ = temp4; + *outs[5]++ = temp5; + *outs[6]++ = temp6; + *outs[7]++ = temp7; temp0 = 0; temp1 = 0; @@ -846,28 +637,21 @@ stpi_unpack_8_1(int length, if (bit < 128) { - *out0++ = temp0; - *out1++ = temp1; - *out2++ = temp2; - *out3++ = temp3; - *out4++ = temp4; - *out5++ = temp5; - *out6++ = temp6; - *out7++ = temp7; + *outs[0]++ = temp0; + *outs[1]++ = temp1; + *outs[2]++ = temp2; + *outs[3]++ = temp3; + *outs[4]++ = temp4; + *outs[5]++ = temp5; + *outs[6]++ = temp6; + *outs[7]++ = temp7; } } static void stpi_unpack_8_2(int length, const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3, - unsigned char *out4, - unsigned char *out5, - unsigned char *out6, - unsigned char *out7) + unsigned char **outs) { unsigned char tempin, shift, @@ -918,14 +702,14 @@ stpi_unpack_8_2(int length, else { shift = 0; - *out0++ = temp0; - *out1++ = temp1; - *out2++ = temp2; - *out3++ = temp3; - *out4++ = temp4; - *out5++ = temp5; - *out6++ = temp6; - *out7++ = temp7; + *outs[0]++ = temp0; + *outs[1]++ = temp1; + *outs[2]++ = temp2; + *outs[3]++ = temp3; + *outs[4]++ = temp4; + *outs[5]++ = temp5; + *outs[6]++ = temp6; + *outs[7]++ = temp7; temp0 = 0; temp1 = 0; @@ -940,61 +724,25 @@ stpi_unpack_8_2(int length, if (shift) { - *out0++ = temp0; - *out1++ = temp1; - *out2++ = temp2; - *out3++ = temp3; - *out4++ = temp4; - *out5++ = temp5; - *out6++ = temp6; - *out7++ = temp7; + *outs[0]++ = temp0; + *outs[1]++ = temp1; + *outs[2]++ = temp2; + *outs[3]++ = temp3; + *outs[4]++ = temp4; + *outs[5]++ = temp5; + *outs[6]++ = temp6; + *outs[7]++ = temp7; } } -void -stp_unpack_8(int length, - int bits, - const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3, - unsigned char *out4, - unsigned char *out5, - unsigned char *out6, - unsigned char *out7) -{ - if (bits == 1) - stpi_unpack_8_1(length, in, out0, out1, out2, out3, - out4, out5, out6, out7); - else - stpi_unpack_8_2(length, in, out0, out1, out2, out3, - out4, out5, out6, out7); -} - - static void stpi_unpack_16_1(int length, const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3, - unsigned char *out4, - unsigned char *out5, - unsigned char *out6, - unsigned char *out7, - unsigned char *out8, - unsigned char *out9, - unsigned char *out10, - unsigned char *out11, - unsigned char *out12, - unsigned char *out13, - unsigned char *out14, - unsigned char *out15) + unsigned char **outs) { unsigned char tempin, bit; unsigned char temp[16]; + int j; if (length <= 0) return; @@ -1046,70 +794,26 @@ stpi_unpack_16_1(int length, else { bit = 128; - *out0++ = temp[0]; - *out1++ = temp[1]; - *out2++ = temp[2]; - *out3++ = temp[3]; - *out4++ = temp[4]; - *out5++ = temp[5]; - *out6++ = temp[6]; - *out7++ = temp[7]; - *out8++ = temp[8]; - *out9++ = temp[9]; - *out10++ = temp[10]; - *out11++ = temp[11]; - *out12++ = temp[12]; - *out13++ = temp[13]; - *out14++ = temp[14]; - *out15++ = temp[15]; + for (j = 0; j < 16; j++) + *outs[j]++ = temp[j]; memset(temp, 0, 16); } } if (bit < 128) - { - *out0++ = temp[0]; - *out1++ = temp[1]; - *out2++ = temp[2]; - *out3++ = temp[3]; - *out4++ = temp[4]; - *out5++ = temp[5]; - *out6++ = temp[6]; - *out7++ = temp[7]; - *out8++ = temp[8]; - *out9++ = temp[9]; - *out10++ = temp[10]; - *out11++ = temp[11]; - *out12++ = temp[12]; - *out13++ = temp[13]; - *out14++ = temp[14]; - *out15++ = temp[15]; - } + for (j = 0; j < 16; j++) + *outs[j]++ = temp[j]; } static void stpi_unpack_16_2(int length, const unsigned char *in, - unsigned char *out0, - unsigned char *out1, - unsigned char *out2, - unsigned char *out3, - unsigned char *out4, - unsigned char *out5, - unsigned char *out6, - unsigned char *out7, - unsigned char *out8, - unsigned char *out9, - unsigned char *out10, - unsigned char *out11, - unsigned char *out12, - unsigned char *out13, - unsigned char *out14, - unsigned char *out15) + unsigned char **outs) { unsigned char tempin, shift; unsigned char temp[16]; + int j; if (length <= 0) return; @@ -1175,46 +879,120 @@ stpi_unpack_16_2(int length, else { shift = 0; - *out0++ = temp[0]; - *out1++ = temp[1]; - *out2++ = temp[2]; - *out3++ = temp[3]; - *out4++ = temp[4]; - *out5++ = temp[5]; - *out6++ = temp[6]; - *out7++ = temp[7]; - *out8++ = temp[8]; - *out9++ = temp[9]; - *out10++ = temp[10]; - *out11++ = temp[11]; - *out12++ = temp[12]; - *out13++ = temp[13]; - *out14++ = temp[14]; - *out15++ = temp[15]; + for (j = 0; j < 16; j++) + *outs[j]++ = temp[j]; memset(temp, 0, 16); } } if (shift) - { - *out0++ = temp[0]; - *out1++ = temp[1]; - *out2++ = temp[2]; - *out3++ = temp[3]; - *out4++ = temp[4]; - *out5++ = temp[5]; - *out6++ = temp[6]; - *out7++ = temp[7]; - *out8++ = temp[8]; - *out9++ = temp[9]; - *out10++ = temp[10]; - *out11++ = temp[11]; - *out12++ = temp[12]; - *out13++ = temp[13]; - *out14++ = temp[14]; - *out15++ = temp[15]; - } + for (j = 0; j < 16; j++) + *outs[j]++ = temp[j]; +} + +void +stp_unpack(int length, + int bits, + int n, + const unsigned char *in, + unsigned char **outs) +{ + unsigned char **touts; + int i; + if (n < 2) + return; + touts = stp_malloc(sizeof(unsigned char *) * n); + for (i = 0; i < n; i++) + touts[i] = outs[i]; + if (bits == 1) + switch (n) + { + case 2: + stpi_unpack_2_1(length, in, touts); + break; + case 4: + stpi_unpack_4_1(length, in, touts); + break; + case 8: + stpi_unpack_8_1(length, in, touts); + break; + case 16: + stpi_unpack_16_1(length, in, touts); + break; + } + else + switch (n) + { + case 2: + stpi_unpack_2_2(length, in, touts); + break; + case 4: + stpi_unpack_4_2(length, in, touts); + break; + case 8: + stpi_unpack_8_2(length, in, touts); + break; + case 16: + stpi_unpack_16_2(length, in, touts); + break; + } + stp_free(touts); +} + +void +stp_unpack_2(int length, + int bits, + const unsigned char *in, + unsigned char *outhi, + unsigned char *outlo) +{ + unsigned char *outs[2]; + outs[0] = outhi; + outs[1] = outlo; + stp_unpack(length, bits, 2, in, outs); +} + +void +stp_unpack_4(int length, + int bits, + const unsigned char *in, + unsigned char *out0, + unsigned char *out1, + unsigned char *out2, + unsigned char *out3) +{ + unsigned char *outs[4]; + outs[0] = out0; + outs[1] = out1; + outs[2] = out2; + outs[3] = out3; + stp_unpack(length, bits, 4, in, outs); +} + +void +stp_unpack_8(int length, + int bits, + const unsigned char *in, + unsigned char *out0, + unsigned char *out1, + unsigned char *out2, + unsigned char *out3, + unsigned char *out4, + unsigned char *out5, + unsigned char *out6, + unsigned char *out7) +{ + unsigned char *outs[8]; + outs[0] = out0; + outs[1] = out1; + outs[2] = out2; + outs[3] = out3; + outs[4] = out4; + outs[5] = out5; + outs[6] = out6; + outs[7] = out7; + stp_unpack(length, bits, 8, in, outs); } void @@ -1238,14 +1016,24 @@ stp_unpack_16(int length, unsigned char *out14, unsigned char *out15) { - if (bits == 1) - stpi_unpack_16_1(length, in, - out0, out1, out2, out3, out4, out5, out6, out7, - out8, out9, out10, out11, out12, out13, out14, out15); - else - stpi_unpack_16_2(length, in, - out0, out1, out2, out3, out4, out5, out6, out7, - out8, out9, out10, out11, out12, out13, out14, out15); + unsigned char *outs[16]; + outs[0] = out0; + outs[1] = out1; + outs[2] = out2; + outs[3] = out3; + outs[4] = out4; + outs[5] = out5; + outs[6] = out6; + outs[7] = out7; + outs[8] = out8; + outs[9] = out9; + outs[10] = out10; + outs[11] = out11; + outs[12] = out12; + outs[13] = out13; + outs[14] = out14; + outs[15] = out15; + stp_unpack(length, bits, 16, in, outs); } static void diff --git a/src/main/channel.c b/src/main/channel.c index b31a4f6..96043a2 100644 --- a/src/main/channel.c +++ b/src/main/channel.c @@ -1,5 +1,5 @@ /* - * "$Id: channel.c,v 1.31 2008/10/29 00:10:42 easysw Exp $" + * "$Id: channel.c,v 1.32 2009/03/01 17:14:15 rlk Exp $" * * Dither routine entrypoints * @@ -618,9 +618,9 @@ stp_channel_initialize(stp_vars_t *v, stp_image_t *image, stp_dprintf(STP_DBG_INK, v, " black_channel %d\n", cg->black_channel); stp_dprintf(STP_DBG_INK, v, " gloss_channel %d\n", cg->gloss_channel); stp_dprintf(STP_DBG_INK, v, " gloss_physical %d\n", cg->gloss_physical_channel); - stp_dprintf(STP_DBG_INK, v, " cyan %.3f", cg->cyan_balance); - stp_dprintf(STP_DBG_INK, v, " magenta %.3f", cg->magenta_balance); - stp_dprintf(STP_DBG_INK, v, " yellow %.3f", cg->yellow_balance); + stp_dprintf(STP_DBG_INK, v, " cyan %.3f\n", cg->cyan_balance); + stp_dprintf(STP_DBG_INK, v, " magenta %.3f\n", cg->magenta_balance); + stp_dprintf(STP_DBG_INK, v, " yellow %.3f\n", cg->yellow_balance); stp_dprintf(STP_DBG_INK, v, " input_data %p\n", (void *) cg->input_data); stp_dprintf(STP_DBG_INK, v, " multi_tmp %p\n", diff --git a/src/main/escp2-channels.c b/src/main/escp2-channels.c index b899c78..5f16887 100644 --- a/src/main/escp2-channels.c +++ b/src/main/escp2-channels.c @@ -1,5 +1,5 @@ /* - * "$Id: escp2-channels.c,v 1.87 2008/10/29 00:10:42 easysw Exp $" + * "$Id: escp2-channels.c,v 1.89 2009/03/07 19:38:00 rlk Exp $" * * Print plug-in EPSON ESC/P2 driver for the GIMP. * @@ -47,6 +47,12 @@ load_subchannel(stp_mxml_node_t *node, stp_mxml_node_t *root, physical_subchanne name = stp_mxmlElementGetAttr(node, "headOffset"); if (name) icl->head_offset = stp_xmlstrtol(name); + name = stp_mxmlElementGetAttr(node, "name"); + if (name) + icl->name = stp_strdup(name); + name = stp_mxmlElementGetAttr(node, "text"); + if (name) + icl->text = stp_strdup(name); while (child) { if (child->type == STP_MXML_ELEMENT) @@ -234,6 +240,8 @@ load_inkname(stp_mxml_node_t *node, stp_mxml_node_t *root, inkname_t *inl) inl->inkset = INKSET_CcMmYKk; else if (!strcmp(name, "Quadtone")) inl->inkset = INKSET_QUADTONE; + else if (!strcmp(name, "Hextone")) + inl->inkset = INKSET_HEXTONE; else if (!strcmp(name, "OTHER")) inl->inkset = INKSET_OTHER; else if (!strcmp(name, "Extended")) diff --git a/src/main/escp2-papers.c b/src/main/escp2-papers.c index 457aa0c..05593e9 100644 --- a/src/main/escp2-papers.c +++ b/src/main/escp2-papers.c @@ -1,5 +1,5 @@ /* - * "$Id: escp2-papers.c,v 1.117 2008/07/06 02:17:43 rlk Exp $" + * "$Id: escp2-papers.c,v 1.118 2009/07/21 11:07:06 rlk Exp $" * * Print plug-in EPSON ESC/P2 driver for the GIMP. * @@ -449,6 +449,9 @@ build_input_slot(const stp_vars_t *v, const char *name) n1 = stp_mxmlFindElement(node, node, "DeinitSequence", NULL, NULL, STP_MXML_DESCEND); if (n1 && n1->child && n1->child->type == STP_MXML_TEXT) answer->deinit_sequence = stp_xmlstrtoraw(n1->child->value.text.string); + n1 = stp_mxmlFindElement(node, node, "ExtraHeight", NULL, NULL, STP_MXML_DESCEND); + if (n1 && n1->child && n1->child->type == STP_MXML_TEXT) + answer->extra_height = stp_xmlstrtoul(n1->child->value.text.string); return answer; } diff --git a/src/main/print-escp2.c b/src/main/print-escp2.c index 096fb43..0ccc74c 100644 --- a/src/main/print-escp2.c +++ b/src/main/print-escp2.c @@ -1,5 +1,5 @@ /* - * "$Id: print-escp2.c,v 1.416 2008/11/22 20:34:29 rlk Exp $" + * "$Id: print-escp2.c,v 1.424 2009/07/21 11:07:06 rlk Exp $" * * Print plug-in EPSON ESC/P2 driver for the GIMP. * @@ -317,6 +317,12 @@ static const stp_parameter_t the_parameters[] = STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0 }, { + "RawChannelNames", N_("Raw Channel Names"), N_("Advanced Printer Functionality"), + N_("Raw Channel Names"), + STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE, + STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0 + }, + { "ChannelNames", N_("Channel Names"), N_("Advanced Printer Functionality"), N_("Channel Names"), STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE, @@ -740,6 +746,126 @@ static const float_param_t float_parameters[] = }, { { + "HGray5Value", N_("Hextone Gray 5 Value"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 5 (Darkest) Value"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray5Trans", N_("Hextone Gray 5 Transition"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 5 (Darkest) Transition"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray5Scale", N_("Hextone Gray 5 Density Scale"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 5 (Darkest) Density Scale"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray4Value", N_("Hextone Gray 4 Value"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 4 Value"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray4Trans", N_("Hextone Gray 4 Transition"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 4 Transition"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray4Scale", N_("Hextone Gray 4 Density Scale"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 4 Density Scale"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray3Value", N_("Hextone Gray 3 Value"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 3 Value"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray3Trans", N_("Hextone Gray 3 Transition"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 3 Transition"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray3Scale", N_("Hextone Gray 3 Density Scale"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 3 Density Scale"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray2Value", N_("Hextone Gray 2 Value"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 2 Value"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray2Trans", N_("Hextone Gray 2 Transition"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 2 Transition"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray2Scale", N_("Hextone Gray 2 Density Scale"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 2 Density Scale"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray1Value", N_("Hextone Gray 1 Value"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 1 (Lightest) Value"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray1Trans", N_("Hextone Gray 1 Transition"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 1 (Lightest) Transition"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { + "HGray1Scale", N_("Hextone Gray 1 Density Scale"), N_("Advanced Ink Adjustment"), + N_("Hextone Gray 1 (Lightest) Density Scale"), + STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, + STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0.0, 5.0, 1.0, 1 + }, + { + { "BlackTrans", N_("GCR Transition"), N_("Advanced Output Control"), N_("Adjust the gray component transition rate"), STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, @@ -796,6 +922,14 @@ static const int_param_t int_parameters[] = { { { + "QualityEnhancement", N_("Quality Enhancement"), N_("Advanced Printer Functionality"), + N_("Enhance print quality by additional passes"), + STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE, + STP_PARAMETER_LEVEL_ADVANCED2, 0, 1, STP_CHANNEL_NONE, 1, 0 + }, 0, 4, 0 + }, + { + { "PaperThickness", N_("Paper Thickness"), N_("Advanced Printer Functionality"), N_("Set printer paper thickness"), STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE, @@ -837,6 +971,7 @@ static const int_param_t int_parameters[] = { { "FeedAdjustment", N_("Feed Adjustment"), N_("Advanced Printer Functionality"), + /* xgettext:no-c-format */ N_("Set paper feed adjustment (0.01% units)"), STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE, STP_PARAMETER_LEVEL_ADVANCED3, 0, 1, STP_CHANNEL_NONE, 1, 0 @@ -1544,6 +1679,40 @@ get_inktype(const stp_vars_t *v) return &(ink_list->inknames[0]); } +static const inkname_t * +get_inktype_only(const stp_vars_t *v) +{ + const char *ink_type = stp_get_string_parameter(v, "InkType"); + + if (!ink_type) + return NULL; + else + return get_inktype(v); +} + +static int +printer_supports_inkset(const stp_vars_t *v, inkset_id_t inkset) +{ + const inkgroup_t *ink_group = escp2_inkgroup(v); + int i; + for (i = 0; i < ink_group->n_inklists; i++) + { + const inklist_t *ink_list = &(ink_group->inklists[i]); + if (ink_list) + { + int j; + for (j = 0; j < ink_list->n_inks; j++) + { + if (ink_list->inknames[j].inkset == inkset) + { + return 1; + } + } + } + } + return 0; +} + static const stp_vars_t * get_media_adjustment(const stp_vars_t *v) { @@ -1680,9 +1849,13 @@ set_gray_value_parameter(const stp_vars_t *v, stp_parameter_t *description, int expected_channels) { - const inkname_t *ink_name = get_inktype(v); + const inkname_t *ink_name = get_inktype_only(v); description->is_active = 0; - if (ink_name && + if (!ink_name && + ((expected_channels == 4 && printer_supports_inkset(v, INKSET_QUADTONE)) || + (expected_channels == 6 && printer_supports_inkset(v, INKSET_HEXTONE)))) + fill_value_parameters(v, description, STP_ECOLOR_K); + else if (ink_name && (ink_name->channels[STP_ECOLOR_K].n_subchannels == expected_channels)) fill_value_parameters(v, description, STP_ECOLOR_K); @@ -1727,8 +1900,12 @@ set_gray_transition_parameter(const stp_vars_t *v, stp_parameter_t *description, int expected_channels) { - const inkname_t *ink_name = get_inktype(v); + const inkname_t *ink_name = get_inktype_only(v); description->is_active = 0; + if (!ink_name && + ((expected_channels == 4 && printer_supports_inkset(v, INKSET_QUADTONE)) || + (expected_channels == 6 && printer_supports_inkset(v, INKSET_HEXTONE)))) + fill_transition_parameters(v, description, STP_ECOLOR_K); if (ink_name && (ink_name->channels[STP_ECOLOR_K].n_subchannels == expected_channels)) @@ -1768,8 +1945,12 @@ set_gray_scale_parameter(const stp_vars_t *v, stp_parameter_t *description, int expected_channels) { - const inkname_t *ink_name = get_inktype(v); + const inkname_t *ink_name = get_inktype_only(v); description->is_active = 0; + if (!ink_name && + ((expected_channels == 4 && printer_supports_inkset(v, INKSET_QUADTONE)) || + (expected_channels == 6 && printer_supports_inkset(v, INKSET_HEXTONE)))) + fill_transition_parameters(v, description, STP_ECOLOR_K); if (ink_name && (ink_name->channels[STP_ECOLOR_K].n_subchannels == expected_channels)) @@ -1941,6 +2122,30 @@ find_resolution_from_quality(const stp_vars_t *v, const char *quality, return NULL; } +static const inkname_t * +get_raw_inktype(const stp_vars_t *v) +{ + if (strcmp(stp_get_string_parameter(v, "InputImageType"), "Raw") == 0) + { + const inklist_t *inks = stp_escp2_inklist(v); + int ninktypes = inks->n_inks; + int i; + const char *channel_name = stp_get_string_parameter(v, "RawChannels"); + const channel_count_t *count; + if (!channel_name) + goto none; + count = get_channel_count_by_name(channel_name); + if (!count) + goto none; + for (i = 0; i < ninktypes; i++) + if (inks->inknames[i].inkset == INKSET_EXTENDED && + (inks->inknames[i].channel_count == count->count)) + return &(inks->inknames[i]); + } + none: + return get_inktype(v); +} + static void escp2_parameters(const stp_vars_t *v, const char *name, stp_parameter_t *description) @@ -2455,7 +2660,7 @@ escp2_parameters(const stp_vars_t *v, const char *name, const inklist_t *inks = stp_escp2_inklist(v); int ninktypes = inks->n_inks; description->bounds.str = stp_string_list_create(); - if (ninktypes > 1) + if (ninktypes >= 1) { stp_string_list_add_string(description->bounds.str, "None", "None"); for (i = 0; i < ninktypes; i++) @@ -2470,9 +2675,41 @@ escp2_parameters(const stp_vars_t *v, const char *name, description->deflt.str = stp_string_list_param(description->bounds.str, 0)->name; } - if (ninktypes <= 1) + else description->is_active = 0; } + else if (strcmp(name, "RawChannelNames") == 0) + { + const inkname_t *ink_name = get_raw_inktype(v); + if (ink_name) + { + description->bounds.str = stp_string_list_create(); + for (i = 0; i < ink_name->channel_count; i++) + { + int j; + const ink_channel_t *ic = &(ink_name->channels[i]); + if (ic) + for (j = 0; j < ic->n_subchannels; j++) + if (ic->subchannels[j].name) + stp_string_list_add_string(description->bounds.str, + ic->subchannels[j].name, + gettext(ic->subchannels[j].text)); + } + for (i = 0; i < ink_name->aux_channel_count; i++) + { + int j; + const ink_channel_t *ic = &(ink_name->aux_channels[i]); + if (ic) + for (j = 0; j < ic->n_subchannels; j++) + if (ic->subchannels[j].name) + stp_string_list_add_string(description->bounds.str, + ic->subchannels[j].name, + gettext(ic->subchannels[j].text)); + } + description->deflt.str = + stp_string_list_param(description->bounds.str, 0)->name; + } + } else if (strcmp(name, "MultiChannelLimit") == 0) { description->is_active = 0; @@ -2500,6 +2737,10 @@ escp2_parameters(const stp_vars_t *v, const char *name, if (stp_escp2_has_media_feature(v, name)) description->is_active = 1; } + else if (strcmp(name, "QualityEnhancement") == 0) + { + description->is_active = 1; + } } const res_t * @@ -2790,6 +3031,7 @@ escp2_describe_output(const stp_vars_t *v) switch (ink_type->inkset) { case INKSET_QUADTONE: + case INKSET_HEXTONE: return "Grayscale"; case INKSET_OTHER: case INKSET_CMYK: @@ -3638,6 +3880,7 @@ setup_printer_weave_parameters(stp_vars_t *v) pd->nozzle_start = 0; pd->min_nozzles = 1; pd->use_black_parameters = 0; + pd->extra_vertical_passes = 1; } static void @@ -3665,6 +3908,7 @@ setup_head_parameters(stp_vars_t *v) pd->printer_weave = get_printer_weave(v); + pd->extra_vertical_passes = 1 << stp_get_int_parameter(v, "QualityEnhancement"); if (stp_escp2_has_cap(v, MODEL_FAST_360, MODEL_FAST_360_YES) && (pd->inkname->inkset == INKSET_CMYK || pd->physical_channels == 1) && pd->res->hres == pd->physical_xdpi && pd->res->vres == 360) @@ -3806,7 +4050,11 @@ setup_page(stp_vars_t *v) } else { - pd->page_extra_height = 0; + if (input_slot) + pd->page_extra_height = input_slot->extra_height * + pd->page_management_units / escp2_base_separation(v); + else + pd->page_extra_height = 0; pd->paper_extra_bottom = escp2_paper_extra_bottom(v); } internal_imageable_area(v, 0, 0, &pd->page_left, &pd->page_right, @@ -4051,7 +4299,7 @@ escp2_print_page(stp_vars_t *v, stp_image_t *image) pd->nozzles, pd->nozzle_separation * pd->res->vres / escp2_base_separation(v), pd->horizontal_passes, - pd->res->vertical_passes, + pd->res->vertical_passes * pd->extra_vertical_passes, 1, pd->channels_in_use, pd->bitwidth, @@ -4135,6 +4383,12 @@ escp2_do_print(stp_vars_t *v, stp_image_t *image, int print_op) stp_eprintf(v, "Warning: Quadtone inkset only available in MONO\n"); stp_set_string_parameter(v, "PrintingMode", "BW"); } + if (pd->inkname && pd->inkname->inkset == INKSET_HEXTONE && + strcmp(stp_get_string_parameter(v, "PrintingMode"), "BW") != 0) + { + stp_eprintf(v, "Warning: Hextone inkset only available in MONO\n"); + stp_set_string_parameter(v, "PrintingMode", "BW"); + } pd->channels_in_use = count_channels(pd->inkname, pd->use_aux_channels); setup_basic(v); diff --git a/src/main/print-escp2.h b/src/main/print-escp2.h index 4f27add..465cab1 100644 --- a/src/main/print-escp2.h +++ b/src/main/print-escp2.h @@ -1,5 +1,5 @@ /* - * "$Id: print-escp2.h,v 1.133 2008/11/22 20:28:04 rlk Exp $" + * "$Id: print-escp2.h,v 1.137 2009/07/21 11:07:06 rlk Exp $" * * Print plug-in EPSON ESC/P2 driver for the GIMP. * @@ -161,6 +161,8 @@ typedef struct const char *subchannel_transition; const char *subchannel_value; const char *subchannel_scale; + const char *name; + const char *text; short *split_channels; } physical_subchannel_t; @@ -180,8 +182,9 @@ typedef enum INKSET_CcMmYyK = 2, INKSET_CcMmYKk = 3, INKSET_QUADTONE = 4, - INKSET_OTHER = 5, - INKSET_EXTENDED = 6 + INKSET_HEXTONE = 5, + INKSET_OTHER = 6, + INKSET_EXTENDED = 7 } inkset_id_t; typedef struct @@ -241,6 +244,7 @@ typedef struct short is_cd; short is_roll_feed; short duplex; + short extra_height; unsigned roll_feed_cut_flags; const stp_raw_t *init_sequence; const stp_raw_t *deinit_sequence; @@ -555,6 +559,7 @@ typedef struct const res_t *res; /* Description of the printing resolution */ const stp_raw_t *printer_weave; /* Printer weave parameters */ int use_printer_weave; /* Use the printer weaving mechanism */ + int extra_vertical_passes; /* Quality enhancement */ /* page parameters */ /* Indexed from top left */ int page_left; /* Left edge of page (points) */ @@ -614,5 +619,5 @@ extern void stpi_escp2_terminate_page(stp_vars_t *v); #endif /* GUTENPRINT_INTERNAL_ESCP2_H */ /* - * End of "$Id: print-escp2.h,v 1.133 2008/11/22 20:28:04 rlk Exp $". + * End of "$Id: print-escp2.h,v 1.137 2009/07/21 11:07:06 rlk Exp $". */ diff --git a/src/main/print-olympus.c b/src/main/print-olympus.c index a0dc7e0..29836ed 100644 --- a/src/main/print-olympus.c +++ b/src/main/print-olympus.c @@ -1,5 +1,5 @@ /* - * "$Id: print-olympus.c,v 1.89 2008/08/14 01:01:41 rlk Exp $" + * "$Id: print-olympus.c,v 1.94 2009/06/22 11:58:34 rlk Exp $" * * Print plug-in DyeSub driver (formerly Olympus driver) for the GIMP. * @@ -50,6 +50,7 @@ #define DYESUB_FEATURE_BORDERLESS 0x00000008 #define DYESUB_FEATURE_WHITE_BORDER 0x00000010 #define DYESUB_FEATURE_PLANE_INTERLACE 0x00000020 +#define DYESUB_FEATURE_PLANE_LEFTTORIGHT 0x00000040 #define DYESUB_PORTRAIT 0 #define DYESUB_LANDSCAPE 1 @@ -168,6 +169,7 @@ typedef struct { int prnh_px, prnw_px, prnt_px, prnb_px, prnl_px, prnr_px; int print_mode; /* portrait or landscape */ int image_rows; + int plane_lefttoright; } dyesub_print_vars_t; typedef struct /* printer specific parameters */ @@ -851,6 +853,37 @@ static const dyesub_printsize_t cp220_printsize[] = LIST(dyesub_printsize_list_t, cp220_printsize_list, dyesub_printsize_t, cp220_printsize); + +/* Canon SELPHY CP-520 */ +static void cp520_printer_init_func(stp_vars_t *v) +{ + char pg = (strcmp(privdata.pagesize, "Postcard") == 0 ? '\1' : + (strcmp(privdata.pagesize, "w253h337") == 0 ? '\2' : + (strcmp(privdata.pagesize, "w155h244") == 0 ? '\3' : + (strcmp(privdata.pagesize, "w283h566") == 0 ? '\4' : + '\1' )))); + + stp_put16_be(0x4000, v); + stp_putc('\0', v); + stp_putc(pg, v); + dyesub_nputc(v, '\0', 8); + /* The CP520 does not want the printer_init and plane_init command to be sent + in the same USB-packet so we fill up first USB-Packet with '\0'. */ + dyesub_nputc(v, '\0', 1012); +} + +static void cp520_plane_init_func(stp_vars_t *v) +{ + stp_put16_be(0x4001, v); + stp_putc(3 - privdata.plane, v); /* The CP520 differs from the cp-printer + in that it reqires the plane in the 3rd + byte not in the 4th */ + stp_putc('\0', v); + stp_put32_le(privdata.w_size * privdata.h_size, v); + dyesub_nputc(v, '\0', 4); +} + + /* Canon SELPHY ES series */ static void es1_printer_init_func(stp_vars_t *v) { @@ -1406,6 +1439,89 @@ static void shinko_chcs9045_printer_init(stp_vars_t *v) } +/* Dai Nippon Printing DS40 */ +static const dyesub_pagesize_t dnpds40_dock_page[] = +{ + { "w288h432", "4x6", PT(1920,300)+1, PT(1240,300)+1, 0, 0, 0, 0, + DYESUB_PORTRAIT}, + { "w432h576", "6x9", PT(1920,300)+1, PT(2740,300)+1, 0, 0, 0, 0, + DYESUB_PORTRAIT}, + { "A5", "6x8", PT(1920,300)+1, PT(2436,300)+1, 0, 0, 0, 0, + DYESUB_PORTRAIT}, +}; + +LIST(dyesub_pagesize_list_t, dnpds40_dock_page_list, dyesub_pagesize_t, dnpds40_dock_page); + +static const dyesub_printsize_t dnpds40_dock_printsize[] = +{ + { "300x300", "w288h432", 1920, 1240}, + { "300x300", "w432h576", 1920, 2740}, + { "300x300", "A5", 1920, 2436}, +}; + +LIST(dyesub_printsize_list_t, dnpds40_dock_printsize_list, dyesub_printsize_t, dnpds40_dock_printsize); + +static void dnpds40_printer_end(stp_vars_t *v) +{ + stp_zprintf(v, "\033PCNTRL START"); dyesub_nputc(v, ' ', 19); +} + +static void dnpds40_plane_init(stp_vars_t *v) +{ + char p = (privdata.plane == 3 ? 'Y' : + (privdata.plane == 2 ? 'M' : + 'C' )); + + long RFSize = (privdata.w_size*privdata.h_size) + 1024 + 54; + long AdSize = (32 - (RFSize % 32)); + long FSize = RFSize + AdSize; + + stp_zprintf(v, "\033PCNTRL RETENTION 0000000800000000"); + stp_zprintf(v, "\033PIMAGE %cPLANE", p); dyesub_nputc(v, ' ', 10); + + stp_zprintf(v, "0%ld", FSize); + stp_zprintf(v, "BM"); + stp_put32_le(FSize, v); + dyesub_nputc(v, '\0', 4); + stp_put32_le(1088, v); + stp_put32_le(40, v); + stp_put32_le(privdata.w_size, v); + stp_put32_le(privdata.h_size, v); + stp_put16_le(1, v); + stp_put16_le(8, v); + dyesub_nputc(v, '\0', 24); + dyesub_nputc(v, '\0', 1024); /*RGB Array*/ + dyesub_nputc(v, '\0', AdSize); /*Locate to 32bit border */ +} + + + +/* Dai Nippon Printing DS80 */ +static const dyesub_pagesize_t dnpds80_dock_page[] = +{ + { "c8x10", "8x10", PT(2560,300)+1, PT(3036,300)+1, 0, 0, 0, 0, DYESUB_PORTRAIT}, + { "C6", "8x4", PT(2560,300)+1, PT(1236,300)+1, 0, 0, 0, 0, DYESUB_PORTRAIT},/* 8x4 */ + { "C5", "8x5", PT(2560,300)+1, PT(1536,300)+1, 0, 0, 0, 0, DYESUB_PORTRAIT}, + { "C4", "8x6", PT(2560,300)+1, PT(1836,300)+1, 0, 0, 0, 0, DYESUB_PORTRAIT}, + { "C3", "8x8", PT(2560,300)+1, PT(2436,300)+1, 0, 0, 0, 0, DYESUB_PORTRAIT}, + { "C2", "8x12", PT(2560,300)+1, PT(3636,300)+1, 0, 0, 0, 0, DYESUB_PORTRAIT}, + { "C1", "A4 Length", PT(2560,300)+1, PT(3544,300)+1, 0, 0, 0, 0, DYESUB_PORTRAIT}, +}; + +LIST(dyesub_pagesize_list_t, dnpds80_dock_page_list, dyesub_pagesize_t, dnpds80_dock_page); + +static const dyesub_printsize_t dnpds80_dock_printsize[] = +{ + { "300x300", "c8x10", 2560, 3036}, + { "300x300", "C6", 2560, 1236}, + { "300x300", "C5", 2560, 1536}, + { "300x300", "C4", 2560, 1836}, + { "300x300", "C3", 2560, 2436}, + { "300x300", "C2", 2560, 3636}, + { "300x300", "C1", 2560, 3544}, +}; + +LIST(dyesub_printsize_list_t, dnpds80_dock_printsize_list, dyesub_printsize_t, dnpds80_dock_printsize); /* Model capabilities */ @@ -1549,6 +1665,22 @@ static const dyesub_cap_t dyesub_model_capabilities[] = cpx00_adj_cyan, cpx00_adj_magenta, cpx00_adj_yellow, NULL, }, + { /* Canon CP-520 */ + 1004, + &ymc_ink_list, + &res_300dpi_list, + &cp220_page_list, + &cp220_printsize_list, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_BORDERLESS | DYESUB_FEATURE_WHITE_BORDER + | DYESUB_FEATURE_PLANE_INTERLACE, + &cp520_printer_init_func, NULL, + &cp520_plane_init_func, NULL, + NULL, NULL, + cpx00_adj_cyan, cpx00_adj_magenta, cpx00_adj_yellow, + NULL, + }, { /* Canon SELPHY ES1, ES2, ES20 (!experimental) */ 1003, &ymc_ink_list, @@ -1696,6 +1828,36 @@ static const dyesub_cap_t dyesub_model_capabilities[] = NULL, NULL, NULL, NULL, }, + { /* Dai Nippon Printing DS40 */ + 6000, + &rgb_ink_list, + &res_300dpi_list, + &dnpds40_dock_page_list, + &dnpds40_dock_printsize_list, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_PLANE_INTERLACE | DYESUB_FEATURE_PLANE_LEFTTORIGHT, + NULL, &dnpds40_printer_end, + &dnpds40_plane_init, NULL, + NULL, NULL, + NULL, NULL, NULL, + NULL, + }, + { /* Dai Nippon Printing DS80 */ + 6001, + &rgb_ink_list, + &res_300dpi_list, + &dnpds80_dock_page_list, + &dnpds80_dock_printsize_list, + SHRT_MAX, + DYESUB_FEATURE_FULL_WIDTH | DYESUB_FEATURE_FULL_HEIGHT + | DYESUB_FEATURE_PLANE_INTERLACE | DYESUB_FEATURE_PLANE_LEFTTORIGHT, + NULL, &dnpds40_printer_end, + &dnpds40_plane_init, NULL, + NULL, NULL, + NULL, NULL, NULL, + NULL, + }, }; static const stp_parameter_t the_parameters[] = @@ -1731,6 +1893,10 @@ static const stp_parameter_t the_parameters[] = STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0 }, { + /* TRANSLATORS: Some dye sublimation printers are able achieve */ + /* better durability of output by covering it with transparent */ + /* laminate surface. This surface can be of different patterns: */ + /* common are matte, glossy or texture. */ "Laminate", N_("Laminate Pattern"), N_("Advanced Printer Setup"), N_("Laminate Pattern"), STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE, @@ -2365,7 +2531,10 @@ dyesub_print_row(stp_vars_t *v, 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 (pv->plane_lefttoright) + ret = dyesub_print_pixel(v, pv, row, pv->imgw_px - col - 1, plane); + else + ret = dyesub_print_pixel(v, pv, row, col, plane); if (ret > 1) break; } @@ -2553,6 +2722,7 @@ dyesub_do_print(stp_vars_t *v, stp_image_t *image) (strcmp(ink_type, "RGB") == 0 || strcmp(ink_type, "BGR") == 0) ? '\xff' : '\0'); pv.plane_interlacing = dyesub_feature(caps, DYESUB_FEATURE_PLANE_INTERLACE); + pv.plane_lefttoright = dyesub_feature(caps, DYESUB_FEATURE_PLANE_LEFTTORIGHT); pv.print_mode = page_mode; if (!pv.image_data) { diff --git a/src/main/print-weave.c b/src/main/print-weave.c index 0207082..98eae16 100644 --- a/src/main/print-weave.c +++ b/src/main/print-weave.c @@ -1,5 +1,5 @@ /* - * "$Id: print-weave.c,v 1.72 2008/10/29 00:10:42 easysw Exp $" + * "$Id: print-weave.c,v 1.75 2009/05/24 01:53:53 rlk Exp $" * * Softweave calculator for Gutenprint. * @@ -1149,6 +1149,10 @@ stp_initialize_weave(stp_vars_t *v, sw->horizontal_width = (sw->compute_linewidth)(v, ((sw->linewidth + sw->horizontal_weave - 1) / sw->horizontal_weave)); + stp_dprintf(STP_DBG_WEAVE_PARAMS, v, + "Computing linewidth for linewidth %d weave %d => %d (%d)\n", + sw->linewidth, sw->horizontal_weave, sw->horizontal_width, + ((sw->horizontal_width + 7) / 8)); sw->horizontal_width = ((sw->horizontal_width + 7) / 8); for (i = 0; i < sw->vmod; i++) @@ -1173,6 +1177,10 @@ stp_initialize_weave(stp_vars_t *v, sw->oversample, sw->vmod, sw->vmod * sw->virtual_jets * sw->bitwidth * sw->ncolors * sw->horizontal_width, page_height); + stp_dprintf(STP_DBG_WEAVE_PARAMS, v, + " ***Buffer limit %d (vj %d bw %d hw %d)\n", + sw->virtual_jets * sw->bitwidth * sw->horizontal_width, + sw->virtual_jets, sw->bitwidth, sw->horizontal_width); stp_allocate_component_data(v, "Weave", NULL, stpi_destroy_weave, sw); return; } @@ -1499,9 +1507,44 @@ add_to_row(stp_vars_t *v, stpi_softweave_t *sw, int row, unsigned char *buf, size_t count = linecount->v[color]; if (place + nbytes > sw->virtual_jets * sw->bitwidth * sw->horizontal_width) { - stp_eprintf(v, "Buffer overflow: limit %d, actual %ld, count %ld\n", + int i; + stp_eprintf(v, "ERROR: %s\n", _("Fatal error!")); + stp_eprintf(v, "ERROR: Static weave data follows:\n"); + stp_eprintf(v, "ERROR: jets: %d\n", sw->jets); + stp_eprintf(v, "ERROR: virtual_jets: %d\n", sw->virtual_jets); + stp_eprintf(v, "ERROR: separation: %d\n", sw->separation); + stp_eprintf(v, "ERROR: horizontal_weave: %d\n", sw->horizontal_weave); + stp_eprintf(v, "ERROR: vertical_subpasses: %d\n", sw->vertical_subpasses); + stp_eprintf(v, "ERROR: vmod: %d\n", sw->vmod); + stp_eprintf(v, "ERROR: oversample: %d\n", sw->oversample); + stp_eprintf(v, "ERROR: repeat_count: %d\n", sw->repeat_count); + stp_eprintf(v, "ERROR: ncolors: %d\n", sw->ncolors); + stp_eprintf(v, "ERROR: linewidth: %d\n", sw->linewidth); + stp_eprintf(v, "ERROR: vertical_height: %d\n", sw->vertical_height); + stp_eprintf(v, "ERROR: firstline: %d\n", sw->firstline); + stp_eprintf(v, "ERROR: bitwidth: %d\n", sw->bitwidth); + stp_eprintf(v, "ERROR: vertical_oversample: %d\n", sw->vertical_oversample); + stp_eprintf(v, "ERROR: horizontal_width: %d\n", sw->horizontal_width); + if (sw->head_offset) + { + stp_eprintf(v, "ERROR: head_offset:\n"); + for (i = 0; i < sw->ncolors; i++) + stp_eprintf(v, "ERROR: head %d: %d\n", i, sw->head_offset[i]); + } + stp_eprintf(v, "ERROR: Dynamic weave data follows:\n"); + stp_eprintf(v, "ERROR: last_pass_offset: %d\n", sw->last_pass_offset); + stp_eprintf(v, "ERROR: last_pass: %d\n", sw->last_pass); + stp_eprintf(v, "ERROR: lineno: %d\n", sw->lineno); + stp_eprintf(v, "ERROR: current_vertical_subpass: %d\n", sw->current_vertical_subpass); + stp_eprintf(v, "ERROR: rcache: %d\n", sw->rcache); + stp_eprintf(v, "ERROR: vcache: %d\n", sw->vcache); + stp_eprintf(v, "ERROR: Other parameters: row %d color %d setactive %d hpass %d\n", + row, color, setactive, h_pass); + stp_eprintf(v, "ERROR: Buffer overflow: limit %d (jets %d bits %d horizontal %d), actual %ld (current %d added %d), count %ld\n", sw->virtual_jets * sw->bitwidth * sw->horizontal_width, - (long)(place + nbytes), (long)count); + sw->virtual_jets, sw->bitwidth, sw->horizontal_width, + (long) (place + nbytes), (int) place, (int) nbytes, (long) count); + stp_eprintf(v, "ERROR: %s\n", _("Please report the above information to gimp-print-devel@lists.sourceforge.net")); stp_abort(); } memcpy(bufs->v[color] + lineoffs->v[color], buf, nbytes); @@ -1582,10 +1625,23 @@ stp_write_weave(stp_vars_t *v, unsigned char *const cols[]) int cpass = sw->current_vertical_subpass * h_passes; if (!sw->fold_buf) - sw->fold_buf = stp_zalloc(sw->bitwidth * ylength); + { + stp_dprintf(STP_DBG_WEAVE_PARAMS, v, + "fold buffer allocation: length %d lw %d weave %d xlength %d ylength %d\n", + length, sw->linewidth, sw->horizontal_weave, xlength, ylength); + stp_dprintf(STP_DBG_WEAVE_PARAMS, v, + "Allocating fold buf %d * %d (%d)\n", ylength, sw->bitwidth, + sw->bitwidth * ylength); + sw->fold_buf = stp_zalloc(sw->bitwidth * ylength); + } if (!sw->comp_buf) - sw->comp_buf = stp_zalloc(sw->bitwidth * - (sw->compute_linewidth)(v,ylength)); + { + stp_dprintf(STP_DBG_WEAVE_PARAMS, v, + "Allocating compression buffer based on %d, %d\n", + sw->bitwidth, ylength); + sw->comp_buf = stp_zalloc(sw->bitwidth * + (sw->compute_linewidth)(v,ylength)); + } if (sw->current_vertical_subpass == 0) initialize_row(v, sw, sw->lineno, xlength, cols); @@ -1622,47 +1678,15 @@ stp_write_weave(stp_vars_t *v, unsigned char *const cols[]) } else in = cols[j]; - switch (sw->horizontal_weave) - { - case 1: - memcpy(sw->s[0], in, length * sw->bitwidth); - break; - case 2: - stp_unpack_2(length, sw->bitwidth, in, sw->s[0], sw->s[1]); - break; - case 4: - stp_unpack_4(length, sw->bitwidth, in, - sw->s[0], sw->s[1], sw->s[2], sw->s[3]); - break; - case 8: - stp_unpack_8(length, sw->bitwidth, in, - sw->s[0], sw->s[1], sw->s[2], sw->s[3], - sw->s[4], sw->s[5], sw->s[6], sw->s[7]); - break; - case 16: - stp_unpack_16(length, sw->bitwidth, in, - sw->s[0], sw->s[1], sw->s[2], sw->s[3], - sw->s[4], sw->s[5], sw->s[6], sw->s[7], - sw->s[8], sw->s[9], sw->s[10], sw->s[11], - sw->s[12], sw->s[13], sw->s[14], sw->s[15]); - break; - } - switch (sw->vertical_subpasses) + if (sw->horizontal_weave == 1) + memcpy(sw->s[0], in, length * sw->bitwidth); + else + stp_unpack(length, sw->bitwidth, sw->horizontal_weave, in, sw->s); + if (sw->vertical_subpasses > 1) { - case 4: - for (idx = 0; idx < sw->horizontal_weave; idx++) - stp_split_4(length, sw->bitwidth, sw->s[idx], sw->s[idx], - sw->s[idx + sw->horizontal_weave], - sw->s[idx + sw->horizontal_weave * 2], - sw->s[idx + sw->horizontal_weave * 3]); - break; - case 2: for (idx = 0; idx < sw->horizontal_weave; idx++) - stp_split_2(length, sw->bitwidth, sw->s[idx], sw->s[idx], - sw->s[idx + sw->horizontal_weave]); - break; - /* case 1 is taken care of because the various unpack */ - /* functions will do the trick themselves */ + stp_split(length, sw->bitwidth, sw->vertical_subpasses, + sw->s[idx], sw->horizontal_weave, &(sw->s[idx])); } for (i = 0; i < h_passes; i++) { |