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

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.

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.

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.

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

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

Boost.GIL can work with PNG.

Related

Generate Live Mp4 in UWP

I want to develop a slide-show kind of app that could be casted to smart TV, similar to showing a PowerPoint slide show. Standard Miracast solution via the Connect app does not work nicely since the phone resolution does not match the high resolution of the TV; not to count the fact that there is no way to hide the navigation bar with TryEnterFullscreenAsync. The images could be quickly rendered from vector sources. So my question is whether there is a way to generate MP4 on the fly.
As long as you can gerate the bitmaps on the fly, as you mentioned, then you can use FFmpeg to create the MP4.
Download ffmpeg source code and check the source of doc/examples/muxing.c
This example is pretty much doing this. Just replace the fill_yuv_image() by the actual thing you are rendering.
Don't forget to convert your pictures to YUV format. In this example, the encoder will need a YUV bitmap and you will probably render an RGB image. Google for swscale or even check the other examples from FFmpeg in order to solve this problem.
--
If you really want something Microsoft specific, then you must use the "Microsoft Media Foundation". There's a lot of samples here on how to encode and decode:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa371827(v=vs.85).aspx
And you can use all these codecs:
https://msdn.microsoft.com/en-us/library/windows/desktop/ff819077(v=vs.85).aspx

Get CMYK values from image, change them, and save as new image - C++

I need to load 8bit Tiff CMYK image at pixel level for image manipulation. Idea is to be able to change loaded C M Y K pixel components and save changes to new CMYK Tiff file. My question is how can this be done in c++, and which library is easy to use (installation process and API). I'm new to c++, but programming isnt new to me (hobby, but now I need it for student research). Its just more confusing to work in c++ compared to other languages, like Python for instance. So to repeat my question once more, how to do image manipulation for 8bit Tiff CMYK at pixel level with being able to change CMYK components for each pixel in c++, and please can you tell me what I need to install to accomplish that(free libraries only because it is for student research)? Can this be done with libraries that are in C++ Visual Studio 2010 express edition?
Thanks!
P.S. I've done all that in Python (manipulations saturation, desaturation, UCA, GCR, UCR) but now I need to do in a compiler language for comparison between two programs. I've tride to do it in c# but that cmyk barrier of not be able to do stuff with cmyk image also appeared.
Maybe CXImage will help http://www.codeproject.com/KB/graphics/cximage.aspx

want to load an image, process it and save it back in file?

I am creating a photo editor app in webos using its hybrid app. I am new to c++.
I don't want to display image on the screen using C++, because on the front end I am using javascript as ui.because javascript UI is better thn PDK... But on the backend I have to use c++ just to process it and save image to the file. I can't save it using javascript because webOS doesn't have support for canvas.toDataURL() method.
So I have to pick an image file from a relative path in the local directory, get its rgb values, process on the rgb values and then saving image back to the directory. Saving as new and replacing the previous.
Ok, now I want assistance from u developers. Also if this is all possibe using the SDL library ?? Also can I crop image in c+|+ as well given x,y coordinates of all of its edges to be cropped from?
I don't know the SDL library well (I suppose it can load and save images) but for loading and saving images you can use the OpenIL/DevIL library, it is quite simple and supports many formats. You could also take a look at OpenCV, but that could be a bit heavy-weight for your purpose. To your second question, You can do everything with the image when it's loaded, just program it. With the right libraries and programmer, C++ can do nearly everything. Sorry for this stupid sentence, but you asked if you can do that in C++ and the answer is nearly always Yes.

Loading PNG textures to OpenGL

I'm working on a game, and all of my graphics use magenta as transparent/magic color.
They are all 32-bit and the magenta is just for conveniency.
Anyway, I would appreciate if someone could advice me what library should I use to load my images (I need to load them in GL_RGBA format, both internal and texture specific).
If only PNG support is necessary, use libpng. DevIL is supposed to be easy, but it's somewhat bloated (does a lot more than just load images) and internally actually calls OpenGL functions which can mess with your own OpenGL logic.
I personally prefer SDL_image, since I'm using SDL in my projects anyway. While not immediately obvious, SDL_BlitSurface() function can do the conversion from whatever IMG_Load() returns to the necessary pixel format.
DevIL can load virtually every file format and can directly create OpenGL textures. It is the easiest way to go.
You should also use a file format which supports an alpha channel (PNG, TGA, ...). Using a "magic color" in 32-bit images is really out-dated!
Apart from the other answers mentioning SDL and DevIL, there are two more options to consider:
Use libpng directly. This will probably have the smallest impact on the code size if that matters, since you get no bloat for other formats you're not using, no DLLs, etc.
Use operating-system texture loading. This can be a nice way to reduce dependencies if you prefer using OS features over external libraries. GDI+ in Windows XP and up has built-in texture loading for a few formats like PNG and JPEG, and I don't know for certain, but other OSs might have similar features. It's pretty simple to hook GDI+ up in to OpenGL and then the OS is taking care of your texture loading!
There is a very minimalist one file example of loading a png into openGL here:
http://tfc.duke.free.fr/coding/src/png.c
Another option is OpenCV.
It does a lot more than just texture loading, but odds are good you'll find use of its other features as well.

How to get into image manipulation programming?

How can I do simple thing like manipulate image programmatically ? ( with C++ I guess .. )
jpgs/png/gif .....
check out BOOST , it has a simple Image Processing Library called GIL. It also has extensions to import common formats.
http://www.boost.org/doc/libs/1_39_0/libs/gil/doc/index.html
Using .NET you have two options:
GDI+ from System.Drawing namespace (Bitmap class)
WPF engine wich can do a lot of things
If you want low level processing you can use unsafe code and pointers.
A Bitmap or Image is just a big array of bytes.
You need to learn:
what is a stride (extra padding bytes after each row of pixels)
how to compute the next row or a specific pixel location using width, height, stride
the image formats RGB, ARGB, white&black
basic image processing functions (luminosity, midtone, contrast, color detection, edge detection, matrix convulsion)
3D vectorial representation of a RGB color
Depending on how fancy you want to get, you may want to look at OpenCV. It's a computer vision library that has functions ranging from reading and writing images to image processing to advanced things like object detection.
Magick++ is a C++ API for the excellent ImageMagick library.
An advantage of ImageMagick is that it can be used from the command-line and a bunch of popular scripting and compiled languages too, and some of those might be more accessible to you than C++.