Note that there are some explanatory texts on larger screens.

plurals
  1. POGDI+ image scaling issue
    text
    copied!<p>I have an application which draws background from some bitmap using gdi+. Some of bitmaps are vertical non-linear gradients (e.g. they are 1 pixel wide and should be stretched horizontally to fill whole control width). The problem is that with small images (like described above), some control area on the right is not painted.</p> <p>I've written a test program that scales a 1x1 image to different sizes, and it shows that issue occurs when scale factor is big enough</p> <pre><code>void Draw(HDC hDestDC, int destleft, int desttop, int destwidth, int destheight) { COLORREF buffer[] = {0xFF0000FF }; // 1 pixel image const int width = 1, height = 1; Gdiplus::Bitmap gdipBitmap(width, height, 4*width, PixelFormat32bppARGB, (BYTE*)buffer); Gdiplus::ImageAttributes attrs; Gdiplus::Rect dest(destleft, desttop, destwidth, destheight); Gdiplus::Graphics graphics(hDestDC); graphics.SetInterpolationMode(Gdiplus::InterpolationModeNearestNeighbor); graphics.SetPixelOffsetMode(Gdiplus::PixelOffsetModeHalf); graphics.DrawImage(&amp;gdipBitmap, dest, 0, 0, width, height, Gdiplus::UnitPixel, &amp;attrs); } // OnPaint: for(int i=0; i&lt;800; ++i) Draw(hdc, 0, i, i, 1); // scale 1x1 image to different width </code></pre> <p>I would exptect this test to draw a smooth 'triangle', but instead lines do not have size <em>exactly</em> as specified by destination rect: <a href="http://i.imgur.com/NNpMvmW.png" rel="nofollow">http://i.imgur.com/NNpMvmW.png</a></p> <p>Is there any way to fix this behavior? I need to output bitmap with size exactly as specified (considering source image alpha-channel and no interpolation with background on the edges).</p> <p>P.S: I have to use GDI+ because actual code uses some ImageAttributes provided by gdiplus.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload