private void MakeButton_Click(object sender, EventArgs e) { if (BustshotBitmap == null || FaceBitmap == null) { return; } int wakuWidth = MakeWakuWidth(); int wakuHeight = MakeWakuHeight(); int tileWidth = wakuWidth / 3; int tileHeight = wakuHeight / 5; { string errorMessage = CheckPartsRange(tileWidth, tileHeight); if (errorMessage != "") { R.ShowStopError(errorMessage); return; } } Bitmap CanvasBitmap = DrawBitmap(0, CATEGORY.PLAIN); Bitmap PortraitBitmap = new Bitmap(128, 112); Graphics gg = Graphics.FromImage(PortraitBitmap); GraphicsSetting(gg); //切り取る部分の範囲を決定する Rectangle srcRect = new Rectangle((int)this.ClipX.Value, (int)this.ClipY.Value, wakuWidth, wakuHeight); Rectangle destRect = new Rectangle(0, 0, 96, 80); //ベースを切り抜く gg.DrawImage(CanvasBitmap, destRect, srcRect, GraphicsUnit.Pixel); //MAP顔 destRect = new Rectangle(96, 16, 32, 16 * 2); gg.DrawImage(CanvasBitmap, destRect, srcRect, GraphicsUnit.Pixel); int eyeX = (((int)this.EyeX.Value - (int)this.ClipX.Value) / tileWidth) * tileWidth + (int)this.ClipX.Value; int eyeY = (((int)this.EyeY.Value - (int)this.ClipY.Value) / tileHeight) * tileHeight + (int)this.ClipY.Value; int mouthX = (((int)this.MouthX.Value - (int)this.ClipX.Value) / tileWidth) * tileWidth + (int)this.ClipX.Value; int mouthY = (((int)this.MouthY.Value - (int)this.ClipY.Value) / tileHeight) * tileHeight + (int)this.ClipY.Value; Rectangle eycSrcRect = new Rectangle(eyeX, eyeY, tileWidth, tileHeight); Rectangle mouthSrcRect = new Rectangle(mouthX, mouthY, tileWidth, tileHeight); //目の位置枠 とろん目 CanvasBitmap = DrawBitmap(2, CATEGORY.TYPE_EYE); destRect = new Rectangle(96, 16 * 3, 32, 16); gg.DrawImage(CanvasBitmap, destRect, eycSrcRect, GraphicsUnit.Pixel); //とろん目の口 CanvasBitmap = DrawBitmap(2, CATEGORY.TYPE_MOUTH); destRect = new Rectangle(32 * 2, 16 * 5, 32, 16); gg.DrawImage(CanvasBitmap, destRect, mouthSrcRect, GraphicsUnit.Pixel); //目の位置枠 閉じ目 CanvasBitmap = DrawBitmap(7, CATEGORY.TYPE_EYE); destRect = new Rectangle(96, 16 * 4, 32, 16); gg.DrawImage(CanvasBitmap, destRect, eycSrcRect, GraphicsUnit.Pixel); //閉じ目の口は通常の口を利用しにないとダメ. ステータス画面に使われる. CanvasBitmap = DrawBitmap(0, CATEGORY.TYPE_MOUTH); destRect = new Rectangle(96, 16 * 5, 32, 16); gg.DrawImage(CanvasBitmap, destRect, mouthSrcRect, GraphicsUnit.Pixel); //笑い目の口 CanvasBitmap = DrawBitmap(6, CATEGORY.TYPE_MOUTH); destRect = new Rectangle(32 * 2, 16 * 6, 32, 16); gg.DrawImage(CanvasBitmap, destRect, mouthSrcRect, GraphicsUnit.Pixel); //大開の口 CanvasBitmap = DrawBitmap(1, CATEGORY.TYPE_MOUTH); destRect = new Rectangle(32 * 0, 16 * 5, 32, 16); gg.DrawImage(CanvasBitmap, destRect, mouthSrcRect, GraphicsUnit.Pixel); CanvasBitmap = DrawBitmap(1, CATEGORY.TYPE_MOUTH); destRect = new Rectangle(32 * 0, 16 * 6, 32, 16); gg.DrawImage(CanvasBitmap, destRect, mouthSrcRect, GraphicsUnit.Pixel); //驚き顔の口 CanvasBitmap = DrawBitmap(4, CATEGORY.TYPE_MOUTH); destRect = new Rectangle(32 * 1, 16 * 5, 32, 16); gg.DrawImage(CanvasBitmap, destRect, mouthSrcRect, GraphicsUnit.Pixel); //戸惑い顔の口 CanvasBitmap = DrawBitmap(5, CATEGORY.TYPE_MOUTH); destRect = new Rectangle(32 * 1, 16 * 6, 32, 16); gg.DrawImage(CanvasBitmap, destRect, mouthSrcRect, GraphicsUnit.Pixel); if (DecreaseColorCheckBox.Checked == true) { Bitmap PortraitBitmap16 = DecreaseColor16(PortraitBitmap, tileWidth, tileHeight); ImageFormRef.ExportImage(this, PortraitBitmap16, "Portrait", 1); //エクスプローラで選択は自動的にやってくれる. //U.SelectFileByExplorer(savefilename); } else { //そのまま保存. string savefilename = ImageFormRef.ExportImageLow(this, PortraitBitmap, "Portrait"); //エクスプローラで選択 U.SelectFileByExplorer(savefilename); } gg.Dispose(); }