Kraken
Kraken

Reputation: 24233

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.

Upvotes: 0

Views: 2469

Answers (2)

ShinTakezou
ShinTakezou

Reputation: 9681

The question could be "how to call an extern program" (see e.g Execute external program with specific parameters from windows c/c++ code ) or how to use a specific library/framework in order to "read" a bmp file, open a gfx window and "map" the image on that window; being on Ubuntu (with GNOME?) you can do it easily (and beyond simple BMP), somethings like e.g. https://developer.gnome.org/gnome-devel-demos/stable/image-viewer.c.html

Upvotes: 1

MOHAMED
MOHAMED

Reputation: 43606

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");

Upvotes: 2

Related Questions