[sane-devel] Canon DR-C125: Wrong colors when scanning Duplex

m. allan noah kitno455 at gmail.com
Wed Mar 16 00:33:55 UTC 2016


I have attached a patch for the sane-backends source code. This
attempts to provide alternate color de-interlacing for your scanner.
It does not attempt to fix any edge cropping issues. Let me know if
you need more instructions.

allan

On Tue, Mar 15, 2016 at 7:59 PM, m. allan noah <kitno455 at gmail.com> wrote:
> Canon scanners often have this variable interlacing at different
> resolutions, so I am not surprised to see this. However, this
> particular scanner has the weirdest interlacing that canon does. If
> you can compile from source, I can send you some patches to try. See
> http://www.sane-project.org/README.linux
>
> allan
>
> On Tue, Mar 15, 2016 at 9:17 AM, el-ti <tl at ewetel.net> wrote:
>> Unfortunately, yes.
>>
>> I uninstalled "cndrvsane-drc125" and restartet the system. The color shift is still there.
>>
>> And there is also the problem, that there is a 1/2 cm cut on the long edge of the scanned page (the "duplex-offset" option only handles the short edge) – but I guess this is another problem.
>>
>> If you need more information, do not hesitate to tell me.
>>
>> el-ti
>>
>> Am 15.03.2016 um 12:41 schrieb m. allan noah:
>>> If you uninstall the Canon "DR-C125 Driver for Linux V1.0 (v1.0)"
>>> software, does this color shift still happen?
>>>
>>> allan
>>>
>>> On Tue, Mar 15, 2016 at 7:37 AM, el-ti <tl at ewetel.net> wrote:
>>> > The system is using the libsane version from the PPA: 1.0.26-git20160305-wily0
>>> >
>>> > It was installed above the one from Ubuntu’s repositories, when I added the PPA.
>>> >
>>> > el-ti
>>> >
>>> > Am 15.03.2016 um 12:22 schrieb m. allan noah:
>>> >> You have installed both sane-backends, and canon's driver? Which one
>>> >> are you using? Assuming you are actually using sane-backends, we will
>>> >> have to modify the code to control the color descrambling.
>>> >>
>>> >> allan
>>> >>
>>> >> On Tue, Mar 15, 2016 at 6:08 AM, el-ti <tl at ewetel.net> wrote:
>>> >>> Hello,
>>> >>>
>>> >>> I have an appendix to make – maybe someone has a hint for me, why the
>>> >>> scanner behaves really strange:
>>> >>>
>>> >>> Depending on the scanning resolution, the shifting on the color range is
>>> >>> different! I used the following command to test this:
>>> >>>
>>> >>> scanimage --batch --source "ADF Duplex" --page-width 210
>>> >>> --page-height=297 -l 0 -t 0 -x 210 -y 297 --mode Color --resolution 300
>>> >>>
>>> >>> Then I tried all available resolutions: 100, 150, 200, 240, 300, 400,
>>> >>> 600. The results are strange:
>>> >>>
>>> >>> Scanning with 100,150,200 gives me:
>>> >>> Blue -> Red
>>> >>> Red -> Green
>>> >>> Green -> Blue
>>> >>>
>>> >>> Scanning with 300 and 400 gives me:
>>> >>> Blue -> Green
>>> >>> Green -> Red
>>> >>> Red -> Blue
>>> >>>
>>> >>> And scanning with 240 and 600 shows the RIGHT colors.
>>> >>>
>>> >>> How is that possible? And how can this problem be solved?
>>> >>>
>>> >>>
>>> >>> I installed Rolf Bensch’s PPA
>>> >>> (https://launchpad.net/~rolfbensch/+archive/ubuntu/sane-git), because it
>>> >>> solved the back page cutting problem when scanning Duplex. (see
>>> >>> http://permalink.gmane.org/gmane.comp.graphics.scanning.sane.devel/24903)
>>> >>>
>>> >>> Other than that, I only installed the Canon "DR-C125 Driver for Linux
>>> >>> V1.0 (v1.0)".
>>> >>>
>>> >>> Any hint is appreciated!
>>> >>> el-ti
>>> >>>
>>> >>> Am 04.03.2016 um 10:59 schrieb el-ti:
>>> >>>> Dear Sane-developers and users,
>>> >>>>
>>> >>>> through this very helpful discussion
>>> >>>> (http://permalink.gmane.org/gmane.comp.graphics.scanning.sane.devel/24903),
>>> >>>> I managed to get my Canon Scanner working in Duplex without cutting 1 cm
>>> >>>> of the back page.
>>> >>>>
>>> >>>> Everything seems to work fine. However, I discovered a very strange
>>> >>>> behaviour regarding the colour management: When scanning in simplex
>>> >>>> mode, everything works fine. There is no page cutting and colours are as
>>> >>>> they should be. But in duplex mode, the colours are somehow shifted on
>>> >>>> the colour range: Blue is scanned as green, green is scanned as red, red
>>> >>>> is scanned as blue (for both back and front page).
>>> >>>>
>>> >>>> Is there an easy solution for this? Or did I forget to install something?
>>> >>>>
>>> >>>> Thank you very much!
>>> >>>> el-ti
>>> >>>>
>>> >>>
>>> >>>
>>> >>> --
>>> >>> sane-devel mailing list: sane-devel at lists.alioth.debian.org
>>> >>> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
>>> >>> Unsubscribe: Send mail with subject "unsubscribe your_password"
>>> >>>              to sane-devel-request at lists.alioth.debian.org
>>> >>
>>> >>
>>> >>
>>> >
>>>
>>>
>>>
>>
>
>
>
> --
> "well, I stand up next to a mountain- and I chop it down with the edge
> of my hand"



-- 
"well, I stand up next to a mountain- and I chop it down with the edge
of my hand"
-------------- next part --------------
diff --git a/backend/canon_dr.c b/backend/canon_dr.c
index da0a6a9..61ddbc5 100644
--- a/backend/canon_dr.c
+++ b/backend/canon_dr.c
@@ -329,6 +329,8 @@
          - use bg_color to fill missing image data
       v54 2015-11-21, MAN
          - br_x and br_y locked to page_width/height until changed
+      v55 2016-03-15, MAN
+         - add new color interlace modes for DR-C125
 
    SANE FLOW DIAGRAM
 
@@ -379,7 +381,7 @@
 #include "canon_dr.h"
 
 #define DEBUG 1
-#define BUILD 54
+#define BUILD 55
 
 /* values for SANE_DEBUG_CANON_DR env var:
  - errors           5
@@ -1581,6 +1583,12 @@ init_model (struct scanner *s)
     s->rgb_format = 1;
     /*s->duplex_offset = 400; now set in config file*/
 
+    s->color_inter_by_res[DPI_100] = COLOR_INTERLACE_2510_BRG;
+    s->color_inter_by_res[DPI_150] = COLOR_INTERLACE_2510_BRG;
+    s->color_inter_by_res[DPI_200] = COLOR_INTERLACE_2510_BRG;
+    s->color_inter_by_res[DPI_300] = COLOR_INTERLACE_2510_GBR;
+    s->color_inter_by_res[DPI_400] = COLOR_INTERLACE_2510_GBR;
+
     /*only in Y direction, so we trash them in X*/
     s->std_res_x[DPI_100]=0;
     s->std_res_x[DPI_150]=0;
@@ -5123,6 +5131,60 @@ copy_simplex(struct scanner *s, unsigned char * buf, int len, int side)
             line[line_next++] = 0;
           }
           break;
+
+        case COLOR_INTERLACE_2510_BRG:
+          DBG (17, "copy_simplex: color, 2510 BRG\n");
+        
+          /* first read head (third byte of every three) */
+          for(j=t-1;j>=0;j-=3){
+            line[line_next++] = buf[i+t+j];
+            line[line_next++] = buf[i+2*t+j];
+            line[line_next++] = buf[i+j];
+          }
+          /* second read head (first byte of every three) */
+          for(j=f-3;j>=0;j-=3){
+            line[line_next++] = buf[i+t+j];
+            line[line_next++] = buf[i+2*t+j];
+            line[line_next++] = buf[i+j];
+          }
+          /* third read head (second byte of every three) */
+          for(j=t-2;j>=0;j-=3){
+            line[line_next++] = buf[i+t+j];
+            line[line_next++] = buf[i+2*t+j];
+            line[line_next++] = buf[i+j];
+          }
+          /* padding */
+          for(j=0;j<tw;j++){
+            line[line_next++] = 0;
+          }
+          break;
+
+        case COLOR_INTERLACE_2510_GBR:
+          DBG (17, "copy_simplex: color, 2510 GBR\n");
+        
+          /* first read head (third byte of every three) */
+          for(j=t-1;j>=0;j-=3){
+            line[line_next++] = buf[i+2*t+j];
+            line[line_next++] = buf[i+j];
+            line[line_next++] = buf[i+t+j];
+          }
+          /* second read head (first byte of every three) */
+          for(j=f-3;j>=0;j-=3){
+            line[line_next++] = buf[i+2*t+j];
+            line[line_next++] = buf[i+j];
+            line[line_next++] = buf[i+t+j];
+          }
+          /* third read head (second byte of every three) */
+          for(j=t-2;j>=0;j-=3){
+            line[line_next++] = buf[i+2*t+j];
+            line[line_next++] = buf[i+j];
+            line[line_next++] = buf[i+t+j];
+          }
+          /* padding */
+          for(j=0;j<tw;j++){
+            line[line_next++] = 0;
+          }
+          break;
       }
     }
   
diff --git a/backend/canon_dr.h b/backend/canon_dr.h
index 69618dc..24ee6cc 100644
--- a/backend/canon_dr.h
+++ b/backend/canon_dr.h
@@ -447,6 +447,8 @@ enum {
 #define COLOR_INTERLACE_RRGGBB 5
 #define COLOR_INTERLACE_rRgGbB 6
 #define COLOR_INTERLACE_2510 7
+#define COLOR_INTERLACE_2510_BRG 8
+#define COLOR_INTERLACE_2510_GBR 9
 
 #define DUPLEX_INTERLACE_NONE 0
 #define DUPLEX_INTERLACE_FFBB 1


More information about the sane-devel mailing list