Inputting pictures from a file?

Hey, is there a way to input/import an image from a file using the 'fstream' header?

Would something like this work?
1
2
3
4
5
6
#import <fstream>

ofstream image("apple.png");

cout << image;
    


I highly doubt it, so I was wondering if there is in fact a way to import a picture from a file and print it out on the screen.
closed account (zb0S216C)
The standard libraries provide no such functionality; you're forced to implement your function(s) yourself by reading 1 byte at a time. However, you can turn to 3rd party libraries[1]. As for printing it to the screen, that falls down to the OS, unless you plan to write the graphics directly to the VRAM. However, the OS isn't going to let you do that unless you do it through the OS's API.

References:
[1] http://www.libpng.org/pub/png/libpng.html


Wazzak
Last edited on
Ok thanks, Framwork!
Topic archived. No new replies allowed.