Search code examples
cfile-iobmp

How to open a bmp image file from C program


What I want it not the normal fopen() function. I want to open the image, as in, when I double click on the image, then the way it opens in the imageViewer. I want to open it like that.

Is there any way of doing that through a C code? So basically I want it to pop open and view itself.

I am on Ubuntu.


Solution

  • It depends of the imageViewer program.

    If the imageViewer program could be called in this way in your linux command line interface

    $imageViewer myfile.bmp
    

    then in your C code you can use system to open your file with imageViewer program

    system("imageViewer myfile.bmp");