0

What can I use to load PNGs into a Picture Control, in a way that uses double-buffering?

I've been using this code, which handles the double-buffering for BMPs, as to avoid the flicker of constant repainting. Now I need to switch to PNGs to reduce the app size.

I found CxImage, but the whole library is too big and it would defeat the purpose of switching to PNGs.

Any thoughts?

GreatDane
  • 683
  • 1
  • 9
  • 31
  • 2
    You already handle the painting so you might as well use [``](http://msdn.microsoft.com/en-us/library/ms533798%28v=vs.85%29.aspx) It can load and paint PNGs and is included with any Windows version. JPEG as well, smaller yet. – Hans Passant Jun 11 '14 at 18:12

1 Answers1

2

Just stay with your BMP code. To bring it to the screen you need the bitmap (or use GDI+ as mentioned in a comment).

Load the PNG file with CImage. Use CIamge::Detach and you have your PNG as a bitmap. Than use your current code.

Loading the PNG into a CImage can be done from disk or from a memory buffer (resource) with a stream. In both cases use CImage::Load.

Afaik there is a simple CPngImage class in the MFC that derives from CBitmap, that provides all functions you need.

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
xMRi
  • 14,982
  • 3
  • 26
  • 59