Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
画像の重ね合わせ (背景画像の中心に前景画像を表示)
Bitmap backImg = new Bitmap(@"C:\backImage.png");
Bitmap flontImg = new Bitmap(@"C:\flontImage.jpg");
Bitmap mixImg = new Bitmap(backImg);
////描画イメージの左上の隅の値を計算
int centerX = mixImg.Width - (mixImg.Width / 2) - (flontImg.Width / 2);
int centerY = mixImg.Height - (mixImg.Height / 2) - (flontImg.Height / 2);
Graphics g = Graphics.FromImage(mixImg);
g.DrawImage(flontImg, centerX, centerY, flontImg.Width, flontImg.Height);
g.Dispose();
backImg.Dispose();
flontImg.Dispose();
mixImg.Save("MixImage.jpg");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment