Exemplo n.º 1
0
            public unsafe Layer(PSD.Layer layer)
            {
                this.layer = layer;

                Name = layer.Name;
                Rect = layer.Rect;

                var wi = asd.Engine.Graphics.CreateEmptyTexture2D(Rect.Width, Rect.Height, asd.TextureFormat.R8G8B8A8_UNORM_SRGB);

                fixed(Color *p = layer.Pixels)
                {
                    asd.TextureLockInfomation info = new asd.TextureLockInfomation();
                    wi.Lock(info);

                    for (int y = 0; y < Rect.Height; y++)
                    {
                        for (int x = 0; x < Rect.Width; x++)
                        {
                            var src = *(p + x + y * Rect.Width);
                            var dst = (Color *)info.Pixels + x + y * Rect.Width;

                            var r = src.B;
                            var b = src.R;
                            src.B = r;
                            src.R = b;

                            *dst = src;
                        }
                    }

                    wi.Unlock();
                }

                Image = wi;
            }
Exemplo n.º 2
0
            public unsafe Layer(PSD.Layer layer)
            {
                this.layer = layer;

                Name = layer.Name;
                Rect = layer.Rect;

                var wi = new System.Drawing.Bitmap(Rect.Width, Rect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                fixed(Color *p = layer.Pixels)
                {
                    var acc = wi.LockBits(new System.Drawing.Rectangle(0, 0, wi.Width, wi.Height),
                                          System.Drawing.Imaging.ImageLockMode.ReadWrite,
                                          System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    for (int y = 0; y < Rect.Height; y++)
                    {
                        for (int x = 0; x < Rect.Width; x++)
                        {
                            var src = *(p + x + y * Rect.Width);
                            var dst = (Color *)acc.Scan0 + x + y * Rect.Width;

                            var r = src.R;
                            var b = src.B;
                            src.B = r;
                            src.R = b;

                            *dst = src;
                        }
                    }

                    wi.UnlockBits(acc);
                }

                Image = wi;
            }
            public unsafe Layer(PSD.Layer layer)
            {
                this.layer = layer;

                Name = layer.Name;
                Rect = layer.Rect;

                var wi = new System.Drawing.Bitmap(Rect.Width, Rect.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                fixed (Color* p = layer.Pixels)
                {
                    var acc = wi.LockBits(new System.Drawing.Rectangle(0, 0, wi.Width, wi.Height),
                        System.Drawing.Imaging.ImageLockMode.ReadWrite,
                        System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    for (int y = 0; y < Rect.Height; y++)
                    {
                        for (int x = 0; x < Rect.Width; x++)
                        {
                            var src = *(p + x + y * Rect.Width);
                            var dst = (Color*)acc.Scan0 + x + y * Rect.Width;

                            var r = src.R;
                            var b = src.B;
                            src.B = r;
                            src.R = b;

                            *dst = src;
                        }
                    }

                    wi.UnlockBits(acc);
                }

                Image = wi;
            }