Strange conversion problem between GDI + to GDI: bitmap and HBitmap

I want to convert gdi + Bitmap to gdi HBitmap object.

I am using the following method:

   Bitmap* img = new Bitmap(XXX);
            // lots of codes...
    HBITMAP temp;
    Color color;
    img->GetHBITMAP(color, &temp);

      

img object uses dialog. when this part of the method is called, a strange thing happens! img display in window has changed! It gets a little clearer or sharper. My question is, what's going on?

+1


source to share


1 answer


Perhaps the bitmap pixel format may be the cause. Are you specifying it explicitly in the Bitmap constructor?

Gdiplus::Bitmap bmp(WIDTH, HEIGHT, PixelFormat24bppRGB);

      

Try to make sure that all the pixel formats you use are the same.



Another reason could be differences in interpolation modes Gdiplus::Graphics

in your code. This attribute determines how images are changed, how lines are drawn, etc.

m_pViewPortImage = new Gdiplus::Bitmap(
    observedWidth,
    observedHeight,
    PixelFormat24bppRGB
);

Gdiplus::Graphics gr(m_pViewPortImage);
gr.SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);

      

+2


source







All Articles