I am showing jpg in a C ++ CWnd window using GDI +. JPG has a clean white background, 0xffffff, but when displayed using graphics.DrawImage, the background is not completely white with a combination of pixel colors such as 0xfff7f7, 0xf7fff7, 0xf7f7f7. Below is the code, I tried various settings like CompositingMode, SmoothingMode, etc. Image does not scale.
The strange thing is that the background color differs depending on other non-white content in the image. If I make a plain white JPG, then it works or even basically white with some kind of black text. Image comparison is shown below.
CClientDC dc(this); Gdiplus::Graphics graphics(dc); Gdiplus::Bitmap* bmp = Gdiplus::Bitmap::FromFile( L"c:\\test.jpg" ); graphics.SetInterpolationMode(Gdiplus::InterpolationModeHighQuality); //graphics.SetCompositingQuality(Gdiplus::CompositingQualityHighQuality); graphics.SetCompositingQuality(Gdiplus::CompositingQualityDefault); graphics.SetCompositingMode(Gdiplus::CompositingModeSourceCopy); //graphics.SetSmoothingMode( Gdiplus::SmoothingMode::SmoothingModeDefault ); graphics.DrawImage(bmp, 0, 0, bmp->GetWidth(), bmp->GetHeight() );
Here I have text and some confusion only on the left side of the image (without alpha, this is JPG). Everything to the right is pure white. You can see that the background is gray.

Here I started to delete the internal content (only on the left side). After a certain moment, the whole background begins to appear white. ???

It really doesn't matter how much of the image area I delete before it starts displaying white if I delete most of it. The same thing happens for pngs.
Here is the original image test.jpg ...

source share