diff
6   int es = samplesperpixel - nc;
+  es = max(0, es);
