Basically, the program i have to write has to display a bmp image and then close it. I don't have to write on the file, modify it or anything. Just display the file and close it. Is there any simple way to do this in a few lines of code and without having to download any library?
Asked
Active
Viewed 180 times
0
-
4All libraries needed to do this task are already includes in all major Linux distributions and nothing needs to be downloaded, besides the Linux distribution itself; but, no, this is not easy, and takes more than just a "few lines of code". Generally, this is one of those questions that if you have to ask it, the answer has to be that you don't have enough background knowledge in order to do it. – Sam Varshavchik Oct 29 '17 at 19:54
-
If you will look for a lightweight library for your task (and I'm sure you will), the SDL library can handle everything you need. – lisyarus Oct 29 '17 at 20:04
2 Answers
2
No, that's not possible using plain c++. The standard libraries have no notion about windows, graphics or image formats.

user0042
- 7,917
- 3
- 24
- 39
-
1It should be noted that it is theoretically possible to do without extra libraries, one "just" has to write a BMP format parser and to call some (a priori available) system-specific API's to create the window and display the image. However, this surely doesn't count as "few lines of code". – lisyarus Oct 29 '17 at 20:02
0
It is most certainly possible. However, it is not an easy thing to do. You can connect directly to the X11 server using either TCP or Unix Domain Sockets and send it the commands that you need. See my tutorial on the subject here: http://betteros.org/tut/graphics1.php#x11
As for loading a BMP, you will need to read about the format, its fairly simple, the weirdest part is how BMP are stored upside down in the file.

prushik
- 322
- 2
- 7
-
BMP are stored properly, it is the user coordinates that weirdly start from top to match line numbers with typical top-down reading order. See [Why are bmps stored upside down?](https://stackoverflow.com/questions/8346115/why-are-bmps-stored-upside-down). – user7860670 Oct 29 '17 at 20:53
-
I didn't say there was anything wrong with how they are stored, its just different from what I think most people and most programmers would expect. – prushik Oct 29 '17 at 21:06