示例#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;
            }
示例#2
0
        private unsafe void Render(asd.Texture2D destination, asd.Texture2D source)
        {
            var dstWidth  = destination.Size.X;
            var dstHeight = destination.Size.Y;
            var srcWidth  = source.Size.X;
            var srcHeight = source.Size.Y;

            var dstLock = new asd.TextureLockInfomation();
            var srcLock = new asd.TextureLockInfomation();

            destination.Lock(dstLock);
            source.Lock(srcLock);

            asd.Color *p = (asd.Color *)srcLock.Pixels.ToPointer();

            for (int y = 0; y < dstHeight && y < srcHeight; y++)
            {
                for (int x = 0; x < dstWidth && x < srcWidth; x++)
                {
                    var src = *(p + x + y * srcWidth);
                    var dst = (asd.Color *)dstLock.Pixels + x + y * dstWidth;

                    *dst = src;
                }
            }

            source.Unlock();
            destination.Unlock();
        }
示例#3
0
    public unsafe void Run()
    {
        // Altseedを初期化する。
        asd.Engine.Initialize("Texture_Basic", 640, 480, new asd.EngineOption());

        // 画像を読み込む。
        asd.Texture2D texture = asd.Engine.Graphics.CreateEmptyTexture2D(256, 256, asd.TextureFormat.R8G8B8A8_UNORM_SRGB);

        // ロックして編集可能な状態にする。
        asd.TextureLockInfomation lockInfo = new asd.TextureLockInfomation();
        if (texture.Lock(lockInfo))
        {
#if LANG_CS
            // C#のみの高速処理
            for (int y = 0; y < lockInfo.Size.Y; y++)
            {
                for (int x = 0; x < lockInfo.Size.X; x++)
                {
                    var pixel = &((byte *)lockInfo.Pixels)[(x + y * lockInfo.Size.X) * lockInfo.Pitch];
                    pixel[0] = (byte)x;
                    pixel[1] = (byte)y;
                    pixel[2] = 0;
                    pixel[3] = 255;
                }
            }
#else
            System.Console.WriteLine("実装されていません。");
#endif
            // Unlockして編集結果を適用する。
            texture.Unlock();
        }

        // 画像描画オブジェクトのインスタンスを生成する。
        asd.TextureObject2D obj = new asd.TextureObject2D();

        // 描画される画像を設定する。
        obj.Texture = texture;

        // 描画位置を指定する。
        obj.Position = new asd.Vector2DF(50, 50);

        // 画像描画オブジェクトのインスタンスをエンジンに追加する。
        asd.Engine.AddObject2D(obj);

        // Altseedのウインドウが閉じられていないか確認する。
        while (asd.Engine.DoEvents())
        {
            // Altseedを更新する。
            asd.Engine.Update();
            Recorder.TakeScreenShot("Texture_Basic", 5);
        }

        // Altseedの終了処理をする。
        asd.Engine.Terminate();
    }
示例#4
0
    public unsafe void Run()
    {
        // Altseedを初期化する。
        asd.Engine.Initialize("Texture_Edit", 640, 480, new asd.EngineOption());

        // 画像を編集可能な状態で読み込む。
        asd.Texture2D texture = asd.Engine.Graphics.CreateEditableTexture2D("Data/Texture/Picture1.png");

        // ロックして編集可能な状態にする。
        asd.TextureLockInfomation lockInfo = new asd.TextureLockInfomation();
        if (texture.Lock(lockInfo))
        {
            for (int y = 0; y < lockInfo.Size.Y; y++)
            {
                for (int x = 0; x < lockInfo.Size.X; x++)
                {
                    var pixel = &((byte *)lockInfo.Pixels)[(x + y * lockInfo.Size.X) * lockInfo.Pitch];
                    pixel[1] = (byte)(y / 2);
                }
            }

            // Unlockして編集結果を適用する。
            texture.Unlock();
        }

        // 画像描画オブジェクトのインスタンスを生成する。
        asd.TextureObject2D obj = new asd.TextureObject2D();

        // 描画される画像を設定する。
        obj.Texture = texture;

        // 描画位置を指定する。
        obj.Position = new asd.Vector2DF(50, 50);

        // 画像描画オブジェクトのインスタンスをエンジンに追加する。
        asd.Engine.AddObject2D(obj);

        // Altseedのウインドウが閉じられていないか確認する。
        while (asd.Engine.DoEvents())
        {
            // Altseedを更新する。
            asd.Engine.Update();
            Recorder.TakeScreenShot("Texture_Edit", 5);
        }

        // Altseedの終了処理をする。
        asd.Engine.Terminate();
    }