Dustin Sun
Dustin Sun

Reputation: 5532

resize an image in VC++

Need be able to zoom in/zoom out/resize images of type bmp, jpeg, png, gif, raw or tiff using VC++ 2012. Do I have to use some third party library? Can you give me some ideas? New to VC++. Many thanks!

Upvotes: 1

Views: 1627

Answers (3)

Jerry Coffin
Jerry Coffin

Reputation: 490128

GDI+ supports at least most of the image formats you've listed, and makes it pretty easy to display a scaled image. Depending on what you mean by "raw", it may not be adequate -- as far as I know, it doesn't support camera raw formats.

If you need support for camera raw formats, there are a fair number of alternatives -- CXImage, for one example, supports lots of camera raw formats, there I'm not sure if it has the newest and greatest version of DCRAW, so it may not support all the newest cameras.

Another that may be worth considering is DevIL, the Developer's Image Library. Again, supports lots of formats, including (I believe) all you've mentioned (again, depending somewhat on what you mean by "raw").

Upvotes: 0

Mark Ransom
Mark Ransom

Reputation: 308166

There's really two parts to your question. The first is how to read the many types of images that you've listed; the second is how to display the image at something other than its native size. I'll answer the second.

Once you have the image in a bitmap, you can use StretchBlt or StretchDIBits to draw it to a device context (DC). You use the rectangle parameters to determine which part of the image you want to display, and what part of the screen you want it to occupy. If the sizes of those rectangles are not the same the image will be resized automatically.

Upvotes: 1

Steve
Steve

Reputation: 7271

If you're using Visual C++, I'm assuming you're targetting a Windows environment. If so, then Windows Imaging Components may provide what you're after. It has built-in support for

  • BMP
  • JPEG
  • PNG
  • TIFF
  • HDPhoto

It is possible that codecs have been written for other formats too.

Upvotes: 3

Related Questions