Esempio n. 1
0
            public unsafe Layer(swig.Layer layer)
            {
                this.layer = layer;

                Name = layer.GetName();

                var rect  = layer.GetRect();
                var Rect_ = new ImagePackageGenerator.Rect();

                Rect_.Top    = rect.Top;
                Rect_.Bottom = rect.Bottom;
                Rect_.Left   = rect.Left;
                Rect_.Right  = rect.Right;
                Rect         = Rect_;

                ObjectType = (LayerObjectType)layer.ObjectType;

                AdditionalObjectType = (LayerAdditionalObjectType)layer.AdditionalObjectType;

                Pixels = new Color[Rect.Width * Rect.Height];

                fixed(Color *p_ = Pixels)
                {
                    byte *dst = (byte *)p_;
                    byte *src = (byte *)layer.GetData();

                    for (int y = 0; y < Rect.Height; y++)
                    {
                        for (int x = 0; x < Rect.Width; x++)
                        {
                            dst[(x + y * Rect.Width) * 4 + 0] = src[x * 4 + y * Rect.Width * 4 + 0];
                            dst[(x + y * Rect.Width) * 4 + 1] = src[x * 4 + y * Rect.Width * 4 + 1];
                            dst[(x + y * Rect.Width) * 4 + 2] = src[x * 4 + y * Rect.Width * 4 + 2];
                            dst[(x + y * Rect.Width) * 4 + 3] = src[x * 4 + y * Rect.Width * 4 + 3];
                        }
                    }
                }
            }
Esempio n. 2
0
            public unsafe Layer(swig.Layer layer)
            {
                this.layer = layer;

                Name = layer.GetName();

                var rect = layer.GetRect();
                var Rect_ = new ImagePackageGenerator.Rect();
                Rect_.Top = rect.Top;
                Rect_.Bottom = rect.Bottom;
                Rect_.Left = rect.Left;
                Rect_.Right = rect.Right;
                Rect = Rect_;

                Pixels = new Color[Rect.Width * Rect.Height];

                fixed(Color* p_ = Pixels)
                {
                    byte* dst = (byte*)p_;
                    byte* src = (byte*)layer.GetData();
                    var srtideLength = layer.GetSrtideLength();

                    for(int y = 0; y < Rect.Height; y++)
                    {
                        for (int x = 0; x < Rect.Width; x++)
                        {
                            dst[(x + y * Rect.Width) * 4 + 0] = src[x * 4 + y * srtideLength + 0];
                            dst[(x + y * Rect.Width) * 4 + 1] = src[x * 4 + y * srtideLength + 1];
                            dst[(x + y * Rect.Width) * 4 + 2] = src[x * 4 + y * srtideLength + 2];
                            dst[(x + y * Rect.Width) * 4 + 3] = src[x * 4 + y * srtideLength + 3];
                        }
                    }
                }
            }