Any good C++ library for displaying large bitmaps - c++

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;
CImg
Graphics Magick
Lead Tools imaging SDK
Anyone got experience of these or can recommend an good alternative?

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.

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.

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

Related

How to save graphic to bmp

Need help with an interesting task. I need to write a C++ program that builds the graph and save a graphic file format bmp. I know how to initialize the bmp, but how to build a graph in it , I can`t think up. Necessary practical and theoretical help if there is a link to an article on the subject.
P.S. I apologize for my bad English :I
There are a lot of ways to do graphics in Windows. The lowest level and most fundamental is to use the Win32 APIs that employ the GDI (Graphics Device Interface), which is built in to Windows. With GDI calls you can paint anything to the screen, and the same GDI calls can be used to paint on an in-memory bitmap that is off screen. To get started in this direction search the net for Win32 tutorials.
I recommend FreeImage library (http://freeimage.sourceforge.net/) it's simple and fast lib without additional problems, you can manipulate graphic files dealing with them like 2D array.
And also, they have nice PDF document about API, you don't need tutorials to use it, just read API and you will get it. Also pr0tip: DON'T PUT SPACES BEFORE SPECIAL CHARACTERS LIKE ",!?.".
You might want to take a look at the graphviz package.

Vector-based fonts on OpenGL

I started working at this company that uses an 2D OpenGL implementation to show our system's data (which runs on Windows.) The whole system was built with C++ (using C++Builder 2007). Thing is, all the text they print there are pixelized when you zoom in, which I think happens because the text is a bitmap:
From what I know they use the same font files as Windows does. I asked around here on why this happens and the answer I got is that the guy who implemented it (which doesn't work at the company anymore) said fonts on OpenGL are hard and this was the best he could do or something like it.
My question is: is there any simple and effective way to make the text also a vector (the same way those lines in the picture are?) So when I zoom the camera, which happens a lot, they don't pixelize. I have little knowledge of OpenGL and if you have some guide and/or tutorial related to this to point me towards the right direction I'd be very thankful. Basically any material would be great.
Most of OpenGL text rendering libraries come to this: creating bitmaps for the fonts. This means you are going to have problems with scaling and aliasing unless you do some hacks.
One of the popular hacks is Valve's approach: Chris Green. 2007. "Improved Alpha-Tested Magnification for Vector Textures and Special Effects.". You use signed distance field algo to generate your fonts bitmap which then helps you to smooth the text outlines on scale during rendering. Wikidot has the C++ implementation for Distance field generation.
If you stick to NVidia specific hardware, you can try the NVidia Path extension which allows you to render graphics directly on GPU. Remember, it is a NVidia only thing.
But in general, signed distance field based approach is the smoothest and easiest to implement.
BTW, freetype-gl uses Valve's approach and also the modern pipeline.
You can try freetype-gl its a library for font rendering in OpenGL.
The issue with using fonts in OpenGL is that they are handled inconsistently across platforms, and that they have minimal support. If you're willing to go with a helper library for OpenGL (SDL comes to mind), then this behaviour will likely be wrapped, meaning that you merely need to provide a suitable font file for them to use.
You may try out FTOGL4 , the fonts for OpenGL4

C/C++ PNG library for creating polygons

Is there a good C/C++ library for creating PNG files and that supports colored polygons and shapes? This library should be OS independent, since I need it for both Linux and Windows.
The Cairo library meets your requirements.
OpenCV is a cross-platform Computer Vision framework that supports several image formats, including PNG.
Qt is a cross-platform library for building graphical interfaces, and it may provide what you are looking for through QImage.
DevIL is a smaller cross-platform Image Library that also supports PNG.
It depends on your OS...for Windows you may consider GDI+, it comes with a friendly C++ interface and it's more intuitive than GDI (even if performance are really poor). Moreover you can save in many different formats.
Links
You can find some good example here:
Converting a BMP Image to a PNG Image
Graphics.DrawPolygon
To save as PNG, you can use LibPNG, it's pretty good. To do the rendering, GDI / GDI+ can be used. (GDI+ is easier to use but is very slow, though, so you won't be able to use that in high-throughput applications.)

Cross-platform drawing library

I've been looking for a good cross-platform 2D drawing library that can be called from C++ and can be used to draw some fairly simple geometry; lines, rectangles, circles, and text (horizontal and vertical) for some charts, and save the output to PNG.
I think a commercial package would be preferable over open source because we would prefer not to have to worry about licensing issues (unless there's something with a BSD style license with no credit clause). I've looked at Cairo Graphics which seemed promising, but the text rendering looks like crap out of the box, and upgrading the text back-end brings us into murky license land.
I need it for Windows, Mac and Linux. Preferably something fairly lightweight and simple to integrate. I've thought about Qt but that's way too heavy for our application.
Any ideas on this would be awesome.
Try Anti-Grain Geometry. From the description:
Anti-Grain Geometry (AGG) is an Open Source, free of charge graphic library, written in industrially standard C++. The terms and conditions of use AGG are described on The License page. AGG doesn't depend on any graphic API or technology. Basically, you can think of AGG as of a rendering engine that produces pixel images in memory from some vectorial data. But of course, AGG can do much more than that. The ideas and the philosophy of AGG are:
Anti-Aliasing.
Subpixel Accuracy.
The highest possible quality.
High performance.
Platform independence and compatibility.
Flexibility and extensibility.
Lightweight design.
Reliability and stability (including numerical stability).
Another one: Skia. Used in Android and Chrome, under active development, HW acceleration.
Have a look at SFML. It's open source but the license is very permissive.
Drawing simple shapes
Displaying text
Antigrain does high quality primitive rendering and seems to be able to render true type fonts and has a commercial license available upon request.
http://www.antigrain.com/
Have you tried FLTK? It is lightweight, cross-platform, has support for 2D/3D graphics and comes with a good widget set (including a charting component). The API is simple and straight forward.
Use SDL
There is also libgd - simple one, but well-written.
Regarding Cairo Graphics, I can't believe it renders text that looks bad. If you are particularly concerned about text rendering, State of the Text Rendering from Jan 2010 gives quite good overview.
I use CImg: cross platform (self contained single header file), simple, concise.
PNG is not natively supported but can be handled if ImageMagick is installed (see supported formats).
See also this related question.
You might use Allegro 5 (since SDL and SFML are mentioned). This provides all of the platforms you require (and more) and can render shapes and save to PNG. Version 5 has a much improved API and hardware acceleration. With any of these low level cross platform libraries you'd have to find your own charting solution.
I put some notes on my blog about Allegro and using it on the Mac.
OpenGL?
I would go for AGG or Cairo.

CoreImage for Win32

For those not familiar with Core Image, here's a good description of it:
http://developer.apple.com/macosx/coreimage.html
Is there something equivalent to Apple's CoreImage/CoreVideo for Windows? I looked around and found the DirectX/Direct3D stuff, which has all the underlying pieces, but there doesn't appear to be any high level API to work with, unless you're willing to use .NET AND use WPF, neither of which really interest me.
The basic idea would be create/load an image, attach any number of filters that can be chained together, forming a graph, and then render the image to an HDC, using the GPU to do most of the hard work. DirectX/Direct3D has these pieces, but you have to jump through a lot of hoops (or so it appears) to use it.
There are a variety of tools for working with shaders (such as RenderMonkey and FX-Composer), but no direct equivalent to CoreImage.
But stacking up fragment shaders on top of each other is not very hard, so if you don't mind learning OpenGL it would be quite doable to build a framework that applies shaders to an input image and draws the result to an HDC.
Adobe's new Pixel Blender is the closest technology out there. It is cross-platform -- it's part of the Flash 10 runtime, as well as the key pixel-oriented CS4 apps, namely After Effects and (soon) Photoshop. It's unclear, however, how much is currently exposed for embedding in other applications at this point. In the most extreme case it should be possible to embed by embedding a Flash view, but that is more overhead than would obviously be idea.
There is also at least one smaller-scale 3rd party offering: Conduit Pixel Engine. It is commercial, with no licensing price clearly listed, however.
I've now got a solution to this. I've implemented an ImageContext class, a special Image class, and a Filter class that allows similar functionality to Apple's CoreImage. All three use OpenGL (I gave up trying to get this to work on DirectX due to image quality issues, if someone knows DirectX well contact me, because I'd love to have a Dx version) to render an image(s) to a context and use the filters to apply their effects (as HLGL frag shaders). There's a brief write up here:
ImageKit
with a screen shot of an example filter and some sample source code.