0

I am trying to design an application that loads bitmap images. I have bitmaps of varying sizes but I want them to be displayed on a constant space ( like a rectangle of size 500x500). I've tried StretchBlt() in the following way but the results are disappointing and the images are still of varying sizes. The code is mentioned below. Thanks in advance.

DcForClientClientDc.StretchBlt(0, 0 , 500, 500, &bmDC, 0, 0, 1000, 1000, SRCCOPY);
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
Justin M
  • 29
  • 3
  • You'll find explanations of the arguments in the documentation for [`StretchBlt`](https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-stretchblt). – IInspectable Feb 08 '22 at 15:23
  • Also keep in mind the proportions on the image you want to fit. Will they be the same? Otherwise you also need to consider ratios in your scaling so that it fits nicely in the constrained space. – Andrew Truckle Feb 08 '22 at 20:25
  • 2
    Why in the name of C++ somebody would downgrade this question, instead explaining to the original poster what is wrong with the question? – JohnCz Feb 08 '22 at 20:31

1 Answers1

1

You should pass to StretchBlt the actual size of the image you want to scale, but you are using 1000 x 1000.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
Vlad Feinstein
  • 10,960
  • 1
  • 12
  • 27