Fusionner deux images avec transparence
Bonjour,
j'ai besoin de fusionner deux png en prenant en compte la transparence.
mais je bloque déjà sur une étape intermédiaire.
Il me faut redimensionner un PNG avec un canal trnasparent et le sauver
et la déjà je perds la transparence avec le code suivant
imgPhoto est l'objet de type Image que je viens de passer en paramètres
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Bitmap bmPhoto = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb);
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);
Graphics grPhoto = Graphics.FromImage(bmPhoto);
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
Rectangle Rect_fond = new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight);
// grPhoto.FillRectangle(new SolidBrush(Color.White), Rect_fond);
grPhoto.DrawImage(imgPhoto,
new Rectangle(destX, destY, destWidth, destHeight),
Rect_fond,
GraphicsUnit.Pixel);
// this.SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
// this.BackColor = Color.FromArgb(0, 128, 128, 128);
bmPhoto.Save(destImag, System.Drawing.Imaging.ImageFormat.Png);
grPhoto.Dispose(); |
j'ai essayé backcolor, solidbrush, et make transparent mais surement pas où il faut
merci de votre aide