+ public void estimateBlackPoint(BlackPointEstimationMethod method, int argument) throws ReaderException {
+ if (!method.equals(lastMethod) || argument != lastArgument) {
+ int[] histogram = new int[LUMINANCE_BUCKETS];
+ if (method.equals(BlackPointEstimationMethod.TWO_D_SAMPLING)) {
+ int minDimension = width < height ? width : height;
+ for (int n = 0, offset = 0; n < minDimension; n++, offset += width + 1) {
+ histogram[computeRGBLuminance(rgbPixels[offset]) >> LUMINANCE_SHIFT]++;
+ }
+ } else if (method.equals(BlackPointEstimationMethod.ROW_SAMPLING)) {
+ if (argument < 0 || argument >= height) {
+ throw new IllegalArgumentException("Row is not within the image: " + argument);
+ }
+ int offset = argument * width;
+ for (int x = 0; x < width; x++) {
+ histogram[computeRGBLuminance(rgbPixels[offset + x]) >> LUMINANCE_SHIFT]++;
+ }
+ } else {
+ throw new IllegalArgumentException("Unknown method: " + method);
+ }
+ blackPoint = BlackPointEstimator.estimate(histogram) << LUMINANCE_SHIFT;
+ lastMethod = method;
+ lastArgument = argument;
+ }
+ }
+
+ public BlackPointEstimationMethod getLastEstimationMethod() {
+ return lastMethod;
+ }
+
+ public MonochromeBitmapSource rotateCounterClockwise() {
+ throw new IllegalStateException("Rotate not supported");
+ }
+
+ public boolean isRotateSupported() {
+ return false;
+ }
+