Esempio n. 1
0
 public BufferedImageMonochromeBitmapSource(System.Drawing.Bitmap image, bool rotated)
 {
     this.image       = image;
     blackPoint       = 0x7F;
     lastMethod       = null;
     lastArgument     = 0;
     iRotateSupported = rotated;
 }
		public BufferedImageMonochromeBitmapSource(System.Drawing.Bitmap image, bool rotated)
		{
			this.image = image;
			blackPoint = 0x7F;
			lastMethod = null;
			lastArgument = 0;
			iRotateSupported = rotated;
		}
Esempio n. 3
0
 public void  estimateBlackPoint(BlackPointEstimationMethod method, int argument)
 {
     if (!method.Equals(lastMethod) || argument != lastArgument)
     {
         int   width            = getWidth();
         int   height           = getHeight();
         int[] histogram        = new int[LUMINANCE_BUCKETS];
         float biasTowardsWhite = 1.0f;
         if (method.Equals(BlackPointEstimationMethod.TWO_D_SAMPLING))
         {
             int minDimension = width < height?width:height;
             int startI       = height == minDimension?0:(height - width) >> 1;
             int startJ       = width == minDimension?0:(width - height) >> 1;
             for (int n = 0; n < minDimension; n++)
             {
                 int pixel = (iRotateSupported ? image.GetPixel(startI + n, startJ + n).ToArgb() : image.GetPixel(startJ + n, startI + n).ToArgb());
                 histogram[computeRGBLuminance(pixel) >> LUMINANCE_SHIFT]++;
             }
         }
         else if (method.Equals(BlackPointEstimationMethod.ROW_SAMPLING))
         {
             if (argument < 0 || argument >= height)
             {
                 throw new System.ArgumentException("Row is not within the image: " + argument);
             }
             biasTowardsWhite = 2.0f;
             int[] rgbArray = getRGB(0, argument, width);
             for (int x = 0; x < width; x++)
             {
                 int l = computeRGBLuminance(rgbArray[x]);
                 histogram[l >> LUMINANCE_SHIFT]++;
             }
         }
         else
         {
             //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
             throw new System.ArgumentException("Unknown method: " + method);
         }
         blackPoint   = BlackPointEstimator.estimate(histogram) << LUMINANCE_SHIFT;
         lastMethod   = method;
         lastArgument = argument;
     }
 }
		public void  estimateBlackPoint(BlackPointEstimationMethod method, int argument)
		{
			if (!method.Equals(lastMethod) || argument != lastArgument)
			{
                int width = getWidth();
                int height = getHeight();
				int[] histogram = new int[LUMINANCE_BUCKETS];
				float biasTowardsWhite = 1.0f;
				if (method.Equals(BlackPointEstimationMethod.TWO_D_SAMPLING))
				{
					int minDimension = width < height?width:height;
					int startI = height == minDimension?0:(height - width) >> 1;
					int startJ = width == minDimension?0:(width - height) >> 1;
					for (int n = 0; n < minDimension; n++)
					{
						int pixel = (iRotateSupported ? image.GetPixel(startI + n, startJ + n).ToArgb() : image.GetPixel(startJ + n, startI + n).ToArgb());
						histogram[computeRGBLuminance(pixel) >> LUMINANCE_SHIFT]++;
					}
				}
				else if (method.Equals(BlackPointEstimationMethod.ROW_SAMPLING))
				{
					if (argument < 0 || argument >= height)
					{
						throw new System.ArgumentException("Row is not within the image: " + argument);
					}
					biasTowardsWhite = 2.0f;
					int[] rgbArray = getRGB(0, argument, width);
					for (int x = 0; x < width; x++)
					{
						int l = computeRGBLuminance(rgbArray[x]);
						histogram[l >> LUMINANCE_SHIFT]++;
					}
				}
				else
				{
					//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
					throw new System.ArgumentException("Unknown method: " + method);
				}
				blackPoint = BlackPointEstimator.estimate(histogram) << LUMINANCE_SHIFT;
				lastMethod = method;
				lastArgument = argument;
			}
		}