0

I wonder how to display an image(actually a 3D-array in c++) by c++ programming language.

I want to display an image by own image structure without any external library like OpenCV, QT, and OpenGL. Therefore, I made an image viewer by win32 api in windows, but I need to make same feature in linux os(such as Ubuntu, and RT OS).

So, what is the best way to display an image in Linux?
Or, is there any internal library like win32 api in Linux?

Thank you for your answer!

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
hun2
  • 11
  • 1
  • 2
    Would you consider GTKmm a library? Why don't you consider Win32 a library? I'm pretty certain Win32 is not a part of the c++ specification! – Captain Giraffe Oct 15 '22 at 09:22
  • You’d probably have to reinvent the wheel and implement one of those yourself. And I think it’s not a fun game to do so. – Victor Oct 15 '22 at 09:28
  • You use the raw X11/Wayland libraries and that will be as far as you get. It's what all all those upper level libs use. – Bib Oct 15 '22 at 09:28
  • Actually, I want to make a class(or a module) without any library dependency by c++ programming language. So, in windows os environment, win32 api is an internal library, it makes me include just in cpp files. I mean, I want to find like win32 api in windows to show an image in linux. I know, using OpenCV is easier way to show an image, but I should make a module without external library, but it is okay to use internal librarary like win32 api in windows. Thank you for your answer! – hun2 Oct 15 '22 at 09:30
  • If you don't want to use any libraries, then you are going to have to reimplement what those libraries do yourself. Why go through all that trouble? – Jesper Juhl Oct 15 '22 at 09:52
  • Then I recommend removing tags "qt" and "opencv" from this question... These tags are supposed to express things which you do want and not the things which you do not want :] – HiFile.app - best file manager Oct 15 '22 at 11:16
  • check https://stackoverflow.com/a/703417/18667225 – Markus Oct 15 '22 at 12:50
  • so you wanna talk to the X server (linux) directly? I hope you don't, that's silly. you ALWAYS need to use a library. the GUI parts of the windows api are considered libraries too. – Christoph Rackwitz Oct 15 '22 at 13:04

1 Answers1

0

The basic GUI framework for Linux applications is X11. Other frameworks are build on top of X11.

Here is a simple working example that demonstrates how to display a BGR image with X11 function XPutImage:

https://stackoverflow.com/a/30863727/18667225

The posted code isn't fully correct but you will quickly find the flaws. You can use it as starting point for understanding the principles. And you will learn the keywords to search for.

To use X11 you will only have to link the standard X11 lib:

https://stackoverflow.com/a/1983495/18667225

Markus
  • 5,976
  • 5
  • 6
  • 21