C++ 如何在GDI+;阿尔法混合?

C++ 如何在GDI+;阿尔法混合?,c++,gdi+,C++,Gdi+,我在应用程序中使用该方法绘制图元文件图像(emf/wmf)。此方法允许通过ImageAttributes设置颜色矩阵。我使用颜色矩阵执行图像alpha混合(绘制半透明图像),如下所示: const auto alphaPercent = 0.5f ColorMatrix colorMatrix = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,

我在应用程序中使用该方法绘制图元文件图像(emf/wmf)。此方法允许通过
ImageAttributes
设置颜色矩阵。我使用颜色矩阵执行图像alpha混合(绘制半透明图像),如下所示:

const auto alphaPercent = 0.5f
ColorMatrix colorMatrix = { 
  1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
  0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
  0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
  0.0f, 0.0f, 0.0f, alphaPercent, 0.0f,
  0.0f, 0.0f, 0.0f, 0.0f, 1.0f
};

ImageAttributes imageAttributes;
imageAttributes.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeDefault);

pGraphics->DrawImage(pImageToDraw,imagePosition, 0.f, 0.f, sourceWidth, sourceHeight, UnitPixel, &imageAttributes);
这种方法非常适用于位图,但不适用于emf元文件。 将
ColorAdjustTypeDefault
更改为
ColorAdjustTypePen
ColorAdjustTypeBrush
没有帮助

示例:GDI+结果:

但应为(α=50%):


如何使用alpha混合在GDI+中绘制图元文件图像?

显示其余代码,并扩展到“它不工作…”,它显示什么?@BarmakShemirani,“它显示什么?”它显示图元文件图像,而不应用颜色矩阵。WMF格式非常古老,与GDI紧密相关。它从未支持超过24bpp的像素格式。GDI+修复了这个问题,但没有更改WMF。考虑将其渲染为位图并用该颜色矩阵绘制该位图。汉帕桑,谢谢你。我希望还有其他方法:(若初始图像是EMF+(不是遗留的WMF或EMF),一切都可以正常工作)。所以我希望将WMF\EMF转换为EMF+格式(请参阅)。