There is no default standard C++ library for creating an image file with a specific format (PNG, Bitmap ... etc). However, there are tricks to create an image and make it viewable if this is all that you need. The ways are discussed below:
- Use a library as jwezorek! mentioned in his answer. There are tons of libraries that can help: OpenCV, STB ... etc
- Create a function that creates a file and streams the pixels data to that file in a specific format (Can be fun for some and a headache for others).
- Save the image data as raw data (pixels data only) in a file, and use a simpler programming language to read the file data and view the image. For instance, let's assume that you will use "python" as the simpler language to create a simple image viewer on windows 10, the code will look as follows:
import NumPy as np
import scipy.misc as smp
from PIL import Image
w = 1066
h = 600
with open('rgb.raw', 'r') as file:
data = file.read().replace('\n', ' ') # Replacing new lines with spaces
rgbs = data.split(' ') # Get a 1D array of all the numbers (pixels) in file
rgbs = [ int(x) for x in rgbs if x != ''] # Change the data into integers
nprgbs = np.array(rgbs, dtype=np.uint8) # Define a numpy array
arr = np.reshape(nprgbs, (h,w,3)) # Reorder the 1D array to 3D matrix (width, height, channels)
img = Image.fromarray(arr) # Create an Image from the pixels.
img.show() # View the image in a window (It uses the default viewer of the OS)
The above code will read a file containing the RGB channels of an image and view it on the default viewer.
As you can see, you can do it in a variety of ways, choose the simplest and the most suitable for you. In conclusion, the answer to your question is "No" unless you use a custom library, create your own functions, or use simpler programming languages to read the stream of data and use them to create the file.