Gdiplus的Graphics在DrawImage的时候,如何指定透明度

Gdiplus的Graphics在DrawImage的时候,怎么指定透明度?
注意:我不是在做窗口半透明的效果。

我只是想把几幅不透明的Gdiplus::Bitmap做叠加,其中有些在叠加的时候,想给予一定的透明度。

具体叠加代码如下:




Gdiplus::Bitmap bitmap(500, 500, PixelFormat32bppARGB);
Gdiplus::Graphics graphics(&bitmap);


graphics.DrawImage(&bitmap1, 0, 0);
graphics.DrawImage(&bitmap2, 0, 0);
graphics.DrawImage(&bitmap3, 0, 0);



------解决方案--------------------
引用:
难道要自己修改图片矩阵数据中的Alpha值?

有其他方法吗?

Quote: 引用:

graphics.DrawImage 没有这种功能


不好意思,好像

Status DrawImage(          Image *image,
    const Rect &destRect,
    INT srcx,
    INT srcy,
    INT srcwidth,
    INT srcheight,
    Unit srcUnit,
    ImageAttributes *imageAttributes,
    DrawImageAbort callback,
    VOID *callbackData
);
这个函数可以实现


/// 设置图片的透明度  
       /// </summary>  
       /// <param name="image">原图</param>  
       /// <param name="alpha">透明度0-255</param>  
       /// <returns></returns>  
       private Bitmap SetPictureAlpha(Image image,int alpha)  
       {  
           //颜色矩阵  
           float[][] matrixItems =  
           {  
               new float[]{1,0,0,0,0},  
               new float[]{0,1,0,0,0},  
               new float[]{0,0,1,0,0},  
               new float[]{0,0,0,alpha/255f,0},  
               new float[]{0,0,0,0,1}  
           };  
           ColorMatrix colorMatrix = new ColorMatrix(matrixItems);  
           ImageAttributes imageAtt = new ImageAttributes();  
           imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);  
           Bitmap bmp = new Bitmap(image.Width, image.Height);  
           Graphics g = Graphics.FromImage(bmp);  
           g.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height),  
                   0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAtt);  
           g.Dispose();  
  
           return bmp;  
       }