How to combine two or more bitmap with transparency into one, in C #?
Closed due to the fact that the essence of the question is not clear to the participants of Streletz , Ivan Pshenitsyn , Kromster , user194374, dirkgntly 26 Aug '16 at 8:27 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
- 2What exactly do you mean by "unite" ? - Dmitry D.
- @Dmitry D., We have the first bitmap with a pattern, and the second with a figure, and the background on it was transparent. And all this is necessary to combine one bitmap, on which there was a pattern and on top of it a figure - Minebot
- Well, draw one over the other. Transparency is precisely for this purpose and is necessary in order not to think, but simply to overlay the layers one upon another. - rdorn
|
1 answer
use CompositingMode.SourceOver
Bitmap baseImage; Bitmap overlayImage; baseImage = (Bitmap)Image.FromFile(@"C:\150\base.png"); overlayImage = (Bitmap)Image.FromFile(@"C:\150\tb.png"); var finalImage = new Bitmap(overlayImage.Width, overlayImage.Height, PixelFormat.Format32bppArgb); var graphics = Graphics.FromImage(finalImage); graphics.CompositingMode = CompositingMode.SourceOver; graphics.DrawImage(baseImage, 0, 0); graphics.DrawImage(overlayImage, 0, 0); //Отображаем изображение на форме pictureBox1.Image = finalImage; Result:
|
