Ejemplo n.º 1
0
        /// <summary>
        /// modelのパターン(x,y)をbufferに描画する
        /// </summary>
        /// <param name="model">レイヤーモデル</param>
        /// <param name="buffer">描画対象バッファ</param>
        /// <param name="xPos">水平位置</param>
        /// <param name="yPos">垂直位置</param>
        public static void Draw(CharaChipRenderData model, ImageBuffer buffer, int xPos, int yPos)
        {
            if ((xPos < 0) || (xPos > 2) || (yPos < 0) || (yPos > 3))
            {
                return;
            }

            buffer.Clear();

            if ((model == null) || (model.LayerCount == 0))
            {
                return;
            }

            for (int i = model.LayerCount - 1; i >= 0; i--)
            {
                RenderLayer layer = model.GetLayer(i);
                if (layer.Image == null)
                {
                    continue;
                }

                // レイヤーを描画する。
                DrawLayer(buffer, xPos, yPos, layer);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 1キャラクターのキャラチップをレンダリングする。
        /// </summary>
        /// <param name="model">レンダリング対象のキャラチップ</param>
        /// <param name="chipSize">キャラチップサイズ</param>
        /// <returns>レンダリングしたImageBufferが返る。</returns>
        private static ImageBuffer RenderCharaChip(Character model, Size chipSize)
        {
            CharaChipRenderData renderData = new CharaChipRenderData();

            model.CopyTo(renderData.Character);

            if (renderData.HasError)
            {
                throw new Exception(Properties.Resources.MessageWriteError);
            }

            ImageBuffer imageBuffer = ImageBuffer.Create(chipSize.Width * 3, chipSize.Height * 4);

            for (int y = 0; y < 4; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    ImageBuffer buffer = ImageBuffer.Create(chipSize.Width, chipSize.Height);
                    CharaChipRenderer.Draw(renderData, buffer, x, y);
                    imageBuffer.WriteImage(buffer, x * chipSize.Width, y * chipSize.Height);
                }
            }

            return(imageBuffer);
        }