code: function (colorSample, bitsPerSample) {
                  var multiplier = Math.pow(2, 8 - bitsPerSample);
                  return Math.floor((colorSample * multiplier) + (multiplier - 1));
              }
docs: Clamp color sample from color sample value and number of bits per sample. Internal use only.