How to draw ARGB bitmap using GDI+?

前端 未结 4 1215
醉梦人生
醉梦人生 2021-01-20 01:02

I have valid HBITMAP handle of ARGB type. How to draw it using GDI+?

I\'ve tried method: graphics.DrawImage(Bitmap::FromHBITMAP(m_hBitmap, NULL), 0, 0); But it doesn

4条回答
  •  隐瞒了意图╮
    2021-01-20 01:56

    I had similar issues getting my transparent channel to work. In my case, I knew what the background color should be used for the transparent area (it was solid). I used the Bitmap.GetHBITMAP(..) method and passed in the background color to be used for the transparent area. This was a much easier solution that other attempts I was trying using LockBits and re-creating the Bitmap with PixelFormat32bppARGB, as well as cloning. In my case, the Bitmap was ignoring the alpha channel since it was created from Bitmap.FromStream.

    I also had some very strange problems with the background area of my image being changed slightly. For example, instead of pure white, it was off white like 0xfff7f7. This was the case whether I was using JPG (with blended colors) or with PNG and transparent colors.

    See my question and solution at

    GDI+ DrawImage of a JPG with white background is not white

提交回复
热议问题