//public Image(int width, int height) //{ // _pixels = new Pixel[width, height]; // for (int x = 0; x < width; x++) // for (int y = 0; y < height; y++) // _pixels[x, y] = new Pixel(x, y); //} public Image(double width, double height, System.Drawing.Bitmap bitmap, Interpolators.IInterpolator interpolator) { if (interpolator == null) { throw new ArgumentNullException("interpolator", "interpolator is null."); } if (bitmap == null) { throw new ArgumentNullException("bitmap", "bitmap is null."); } if (Width < 0) { throw new Exception("Width can't be negative"); } if (Height < 0) { throw new Exception("Height can't be negative"); } Width = width; Height = height; _interpolator = interpolator; ScaleHorizontal = (bitmap.Width - 1) / Width; ScaleVertical = (bitmap.Height - 1) / Height; _pixels = new Pixel[bitmap.Width, bitmap.Height]; for (int x = 0; x < bitmap.Width; x++) { for (int y = 0; y < bitmap.Height; y++) { _pixels[x, y] = new Pixel(bitmap.GetPixel(x, bitmap.Height - y - 1).GetBrightness(), x, y); } } }
//public Image(int width, int height) //{ // _pixels = new Pixel[width, height]; // for (int x = 0; x < width; x++) // for (int y = 0; y < height; y++) // _pixels[x, y] = new Pixel(x, y); //} public Image(double width, double height, System.Drawing.Bitmap bitmap, Interpolators.IInterpolator interpolator) { if (interpolator == null) throw new ArgumentNullException("interpolator", "interpolator is null."); if (bitmap == null) throw new ArgumentNullException("bitmap", "bitmap is null."); if (Width < 0) throw new Exception("Width can't be negative"); if (Height < 0) throw new Exception("Height can't be negative"); Width = width; Height = height; _interpolator = interpolator; ScaleHorizontal = (bitmap.Width - 1) / Width; ScaleVertical = (bitmap.Height - 1) / Height; _pixels = new Pixel[bitmap.Width, bitmap.Height]; for (int x = 0; x < bitmap.Width; x++) for (int y = 0; y < bitmap.Height; y++) _pixels[x, y] = new Pixel(bitmap.GetPixel(x, bitmap.Height - y - 1).GetBrightness(), x, y); }
public ImageProcessor(System.Drawing.Bitmap bitmap, double width, double height, double lineRes, double pointRes, double angle, Interpolators.IInterpolator interpolator) { if (width < 0) { throw new Exception("Width can not be negative"); } if (height < 0) { throw new Exception("Height can not be negative"); } if (lineRes < 0) { throw new Exception("lineRes can not be negative"); } if (pointRes < 0) { throw new Exception("pointRes can not be negative"); } _Angle = angle; _PointRes = pointRes; _LineRes = lineRes; _Height = height; _Width = width; _image = new Image(width, height, bitmap, interpolator); }