Esempio n. 1
0
        public static Bitmap DecodeImage(Layer.Mask mask)
        {
            Layer layer = mask.Layer;

            if (mask.Rect.Width == 0 || mask.Rect.Height == 0)
            {
                return(null);
            }

            Bitmap bitmap = new Bitmap(mask.Rect.Width, mask.Rect.Height, PixelFormat.Format32bppArgb);

            Parallel.For(0, layer.Rect.Height, y =>
            {
                Int32 rowIndex = y * layer.Rect.Width;

                for (Int32 x = 0; x < layer.Rect.Width; x++)
                {
                    Int32 pos = rowIndex + x;

                    Color pixelColor = Color.FromArgb(mask.ImageData[pos], mask.ImageData[pos], mask.ImageData[pos]);

                    lock (bitmap)
                    {
                        bitmap.SetPixel(x, y, pixelColor);
                    }
                }
            });
            return(bitmap);
        }
Esempio n. 2
0
        public static Bitmap DecodeImage(Layer.Mask mask)
        {
            var layer = mask.Layer;

            if (mask.Rect.Width == 0 || mask.Rect.Height == 0)
            {
                return(null);
            }
            var bitmap = new Bitmap(mask.Rect.Width, mask.Rect.Height, PixelFormat.Format32bppArgb);

            Parallel.For(0, layer.Rect.Height, delegate(int y)
            {
                var num = y * layer.Rect.Width;
                for (var i = 0; i < layer.Rect.Width; i++)
                {
                    var num2  = num + i;
                    var color = Color.FromArgb(mask.ImageData[num2], mask.ImageData[num2], mask.ImageData[num2]);
                    lock (bitmap)
                    {
                        bitmap.SetPixel(i, y, color);
                    }
                }
            });
            return(bitmap);
        }
Esempio n. 3
0
        private static int GetColor(Layer.Mask mask, int x, int y)
        {
            var result = 255;

            if (mask.PositionIsRelative)
            {
                x -= mask.Rect.X;
                y -= mask.Rect.Y;
            }
            else
            {
                x = x + mask.Layer.Rect.X - mask.Rect.X;
                y = y + mask.Layer.Rect.Y - mask.Rect.Y;
            }
            if (y >= 0 && y < mask.Rect.Height && x >= 0 && x < mask.Rect.Width)
            {
                var num = y * mask.Rect.Width + x;
                result = (num < mask.ImageData.Length) ? mask.ImageData[num] : byte.MaxValue;
            }
            return(result);
        }
Esempio n. 4
0
        private static Int32 GetColor(Layer.Mask mask, Int32 x, Int32 y)
        {
            Int32 c = 255;

            if (mask.PositionIsRelative)
            {
                x -= mask.Rect.X;
                y -= mask.Rect.Y;
            }
            else
            {
                x = (x + mask.Layer.Rect.X) - mask.Rect.X;
                y = (y + mask.Layer.Rect.Y) - mask.Rect.Y;
            }

            if (y >= 0 && y < mask.Rect.Height &&
                x >= 0 && x < mask.Rect.Width)
            {
                Int32 pos = y * mask.Rect.Width + x;
                c = pos < mask.ImageData.Length ? mask.ImageData[pos] : 255;
            }

            return(c);
        }