예제 #1
0
        public ImageFilm(int xResolution, int yResolution, Filter filter, float[] cropWindow)
            : base(xResolution, yResolution)
        {
            _filter = filter;
            _cropWindow = cropWindow;

            _bitmap = new WriteableBitmap(xResolution, yResolution, 96.0, 96.0, PixelFormats.Pbgra32, null);

            // Compute film image extent
            _xPixelStart = MathUtility.Ceiling(xResolution * cropWindow[0]);
            _xPixelCount = Math.Max(1, MathUtility.Ceiling(xResolution * cropWindow[1]) - _xPixelStart);
            _yPixelStart = MathUtility.Ceiling(yResolution * cropWindow[2]);
            _yPixelCount = Math.Max(1, MathUtility.Ceiling(yResolution * cropWindow[3]) - _yPixelStart);

            // Allocate film image storage
            _pixels = new ImagePixel[_xPixelCount, _yPixelCount];
            for (var x = 0; x < _xPixelCount; x++)
                for (var y = 0; y < _yPixelCount; y++)
                    _pixels[x, y] = new ImagePixel();

            // Precompute filter weight table
            _filterTable = new float[FilterTableSize * FilterTableSize];
            var index = 0;
            for (int y = 0; y < FilterTableSize; ++y)
            {
                float fy = (y + .5f) * filter.YWidth / FilterTableSize;
                for (int x = 0; x < FilterTableSize; ++x)
                {
                    float fx = (x + .5f) * filter.XWidth / FilterTableSize;
                    _filterTable[index++] = filter.Evaluate(fx, fy);
                }
            }

            _bgra = new byte[_xPixelCount * _yPixelCount * 4];
        }
예제 #2
0
        public ImageFilm(int xResolution, int yResolution, Filter filter, float[] cropWindow)
            : base(xResolution, yResolution)
        {
            _filter     = filter;
            _cropWindow = cropWindow;

            _bitmap = new WriteableBitmap(xResolution, yResolution, 96.0, 96.0, PixelFormats.Pbgra32, null);

            // Compute film image extent
            _xPixelStart = MathUtility.Ceiling(xResolution * cropWindow[0]);
            _xPixelCount = Math.Max(1, MathUtility.Ceiling(xResolution * cropWindow[1]) - _xPixelStart);
            _yPixelStart = MathUtility.Ceiling(yResolution * cropWindow[2]);
            _yPixelCount = Math.Max(1, MathUtility.Ceiling(yResolution * cropWindow[3]) - _yPixelStart);

            // Allocate film image storage
            _pixels = new ImagePixel[_xPixelCount, _yPixelCount];
            for (var x = 0; x < _xPixelCount; x++)
            {
                for (var y = 0; y < _yPixelCount; y++)
                {
                    _pixels[x, y] = new ImagePixel();
                }
            }

            // Precompute filter weight table
            _filterTable = new float[FilterTableSize * FilterTableSize];
            var index = 0;

            for (int y = 0; y < FilterTableSize; ++y)
            {
                float fy = (y + .5f) * filter.YWidth / FilterTableSize;
                for (int x = 0; x < FilterTableSize; ++x)
                {
                    float fx = (x + .5f) * filter.XWidth / FilterTableSize;
                    _filterTable[index++] = filter.Evaluate(fx, fy);
                }
            }

            _bgra = new byte[_xPixelCount * _yPixelCount * 4];
        }