Beispiel #1
0
        public void Render(int[] pixels, int width, int height)
        {
            byte[] data = null;

            if (_scaledData == null)
            {
                if (_scale == 1.0)
                {
                    _scaledData = _originalData;
                }
                else
                {
                    int w = (int)(_originalData.Width * _scale);
                    int h = (int)(_originalData.Height * _scale);
                    data        = BilinearInterpolation.RescaleGrayscale(_originalData.Data, _originalData.Width, _originalData.Height, w, h);
                    _scaledData = new GrayscalePixelDataU8(w, h, data);
                }
            }

            data = _scaledData.Data;

            int ox = (int)(_offsetX * _scale);
            int oy = (int)(_offsetY * _scale);

            MultiThread.For(0, _scaledData.Height, y => {
                for (int i = _scaledData.Width * y, e = i + _scaledData.Width; i < e; i++)
                {
                    if (data[i] > 0)
                    {
                        int p     = (oy * width) + ox + i;
                        pixels[p] = _color;
                    }
                }
            });
        }
Beispiel #2
0
        public IPixelData Rescale(double scale)
        {
            int w = (int)(Width * scale);
            int h = (int)(Height * scale);

            byte[] data = BilinearInterpolation.RescaleGrayscale(_data, Width, Height, w, h);
            return(new GrayscalePixelDataU8(w, h, data));
        }
Beispiel #3
0
 /// <inheritdoc />
 public IPixelData Rescale(double scale)
 {
     if (scale == 1.0) return this;
     var w = (int)(Width * scale);
     var h = (int)(Height * scale);
     var data = BilinearInterpolation.RescaleGrayscale(Data, Width, Height, w, h);
     return new GrayscalePixelDataS32(w, h, data);
 }
Beispiel #4
0
        /// <inheritdoc />
        public IPixelData Rescale(double scale)
        {
            var w = (int)(Width * scale);
            var h = (int)(Height * scale);
            if (w == Width && h == Height) return this;

            var data = BilinearInterpolation.RescaleGrayscale(Data, Width, Height, w, h);
            return new GrayscalePixelDataU16(w, h, data);
        }
Beispiel #5
0
        public IPixelData Rescale(double scale)
        {
            if (scale == 1.0)
            {
                return(this);
            }
            int w = (int)(Width * scale);
            int h = (int)(Height * scale);

            uint[] data = BilinearInterpolation.RescaleGrayscale(_data, Width, Height, w, h);
            return(new GrayscalePixelDataU32(w, h, data));
        }
Beispiel #6
0
        /// <inheritdoc />
        public virtual IPixelData Rescale(double scale)
        {
            var w = (int)(Width * scale);
            var h = (int)(Height * scale);

            if (w == Width && h == Height)
            {
                return(this);
            }

            var data = BilinearInterpolation.RescaleGrayscale(Data, Width, Height, w, h);

            return(new GrayscalePixelDataU8(w, h, data));
        }