tags:

views:

125

answers:

3

I'm currently using MFC/GDI and Stingray to display bitmaps in my application and am looking for a better solution. Specifically;

  • Faster drawing speed - My current solution is slow, based on StretchDIBits
  • Better rendering quality - StretchDIBits rendering quality is awful when scaling a bitmap
  • Support for rotated bitmaps
  • Support for loading / saving in all popular formats
  • Support for large bitmaps - I'm regularly using aerial photographs that are ~64mb as 12,000x12,000 jpegs. GeoTIFF support would also be useful
  • Compatible with MFC document/view, including printing (e.g. must be able render to a CDC)
  • Access to source code is good but not necessary
  • Easy to use / port existing GDI code

While free is always nice, I don't mind spending a reasonable amount on a decent library, though no run time royalty costs. Googling suggests the following;

Anyone got experience of these or can recommend an good alternative?

+1  A: 

I think it's unlikely you'll find something that performs faster than GDI on windows since it has kernel-level support which is something open source solutions will not have.

You might want to also look into OpenGL or Direct2D/Direct3D since these too have direct access to the frame buffer. With 3D APIs, texture size would probably be an issue since most standards limit to something like 4096x4096.

shoosh
I'm not convinced about the speed thing. This may be true if I wasn't scaling the bitmaps, but StretchDIBits doesn't seem that fast at scaling and drawing a 4000x4000 pixel bitmap in say a 300x300 pixel box. It also produces an awful result. The following discussion on StretchDIBits speed is also interesting http://www.gamedev.net/community/forums/topic.asp?topic_id=344785
Shane MacLaughlin
Moving the whole lot OpenGL is certainly worth considering, though would possible involve a lot of work and pose problems on the printing side of things.
Shane MacLaughlin
StretchDIBits does a simple nearest neighbor scaling. For some applications that is exactly what you want and nothing else. (for instance for an image editor zoom)
shoosh
+1  A: 

I have used CxImage in the past which is one to add to your evaluation list.

Rob
+1 Looks great, thanks for posting!
Shane MacLaughlin
+2  A: 

GDI+ is available on any Windows machine since early XP. It has codecs for all popular image formats, JPEG is included. Very nice filters for high-quality image rescaling. Unrestricted image rotation. Draws to a CDC through the Graphics class. Source code for the C++ wrappers are available in the SDK gdiplusXxx.h header files. Speed is likely to be equivalent however, rendering is software based to ensure compatibility.

You can #include <gdiplus.h> and use the C++ wrappers directly. The SDK docs are here. The CImage class is available in MFC, it doesn't expose all capabilities however.

Hans Passant
+1 This is probably a good first step, as it should be a very easy port. I've been meaning to swap from GDI to GDI+ for awhile, so now is probably time to bite the bullet.
Shane MacLaughlin