Exemple #1
0
        /// <summary>
        /// Render overlay graphic.
        /// </summary>
        /// <param name="pixels">Pixels subject to rendering.</param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public void Render(int[] pixels, int width, int height)
        {
            if (_scaledData == null) _scaledData = (GrayscalePixelDataU8)_originalData.Rescale(_scale);

            var data = _scaledData.Data;

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

#if NET35
            for (var y = 0; y < _scaledData.Height; ++y)
#else
            Parallel.For(0, _scaledData.Height, y =>
#endif
            {
                if (oy + y >= height) return;
                for (int i = _scaledData.Width * y, e = i + _scaledData.Width, p = (oy + y) * width + ox, x = 0; i < e; i++, p++, x++)
                {
                    if (data[i] > 0)
                    {
                        if (ox + x >= width) break;
                        pixels[p] |= _color;
                    }
                }
            }
#if !NET35
            );
#endif
        }
        public void Render(int[] pixels, int width, int height)
        {
            byte[] data = null;

            if (_scaledData == null)
            {
                _scaledData = _originalData.Rescale(_scale);
            }

            data = (_scaledData as GrayscalePixelDataU8).Data;

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

            Parallel.For(0, _scaledData.Height, y => {
                if ((oy + y) >= height)
                {
                    return;
                }
                for (int i = _scaledData.Width * y, e = i + _scaledData.Width, x = 0; i < e; i++, x++)
                {
                    if (data[i] > 0)
                    {
                        if ((ox + x) >= width)
                        {
                            break;
                        }
                        int p     = (oy * width) + ox + i;
                        pixels[p] = _color;
                    }
                }
            });
        }
Exemple #3
0
        public void Render(int[] pixels, int width, int height)
        {
            byte[] data = null;

            if (_scaledData == null) _scaledData = _originalData.Rescale(_scale);

            data = (_scaledData as GrayscalePixelDataU8).Data;

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

#if NET35
            for (var y = 0; y < _scaledData.Height; ++y)
#else
                Parallel.For(0, _scaledData.Height, y =>
#endif
            {
                if ((oy + y) >= height) return;
                for (int i = _scaledData.Width * y, e = i + _scaledData.Width, x = 0; i < e; i++, x++)
                {
                    if (data[i] > 0)
                    {
                        //this is wrong, when scaling is active
                        //if ((ox + x) >= width) break;
                        int p = (oy * width) + ox + i;
                        pixels[p] = _color;
                    }
                }
            }
#if !NET35
            );
#endif
        }