Andrei Simionescu
Andrei Simionescu

Reputation: 268

How to create PNG images with Visual Studio C++ 2010?

IN: Visual Studio 2010 Ultimate, Windows 7

OUT: Some small ish PNG images that I will use as custom markers in Google Maps.

Language: C++ (or, if I really have to, C#)

Extra: I need to be able to plot the alpha channel (the transparency). I used PNGwriter library on a Linux machine and that didn't offer this feature.

Extra 2: The .exe will run on a server each time a new custom marker is needed. (Markers have different colors and shapes)

Edit: 1. I want to create a new image. 2. I need a library which I can't seem to find via Google yet.

Upvotes: 0

Views: 6163

Answers (5)

Jordan
Jordan

Reputation: 166

You could always use .NET.

I would suggest the built in System.Drawing namespace, which is available in both flavors - C++ and C#. Assuming you aren't against using Visual C++ Express, you can always take it from there.

Here's a link to the "official" documentation: System.Drawing Namespace
Within which is the System.Drawing.Graphics namespace, which is possibly what you would want to use.

AND here's a link to a nice little tutorial that will teach you how to import an image and draw on it (or possibly even draw it onto a bitmap): The Wonders of System.Drawing.Graphics

Upvotes: 1

John
John

Reputation: 21

I created a kluge to do this. I used a common routine for getting the color (GetColor(red,green,blue,transparency)). I printed in two passes. The first pass would print to a 256 gray scale image. GetColor() would return the transparency as a shade of gray. The second pass would print to a 24-bit color image. GetColor would return the RGB color. After the two passes I merged the two bitmaps with the grayscale becoming the alpha channel for the PNG file.

Upvotes: 2

Abyx
Abyx

Reputation: 12918

Boost.GIL can work with PNG.

Upvotes: 0

Luther
Luther

Reputation: 1838

Do you mean you want to convert from one file format to PNG using C++? Or that you want to render to an image and save the resulting image out as a PNG?

Either way, maybe you should take a look at FreeImage http://freeimage.sourceforge.net/features.html which is an open source image parsing/writing library that supports many formats, including PNG.

Upvotes: 2

Billy ONeal
Billy ONeal

Reputation: 106549

C++ does not have any facilities built in for editing images. You'd need to find a library.

Upvotes: 1

Related Questions