viewing a pic in 'C'

Programming, for all ages and all languages.
Post Reply
rich_m

viewing a pic in 'C'

Post by rich_m »

how is it possible to read(view) a picture file in a C program in graphics? :-\
Schol-R-LEA

Re:viewing a pic in 'C'

Post by Schol-R-LEA »

That depends on the type of image file you are displaying, the OS you are implementing it under, the window manager you are using, and/or the graphics library you are calling. Standard C and C++ do not have any support for graphics at all, or even console manipulation for that matter. There are a handful of add-on graphics libraries whose APIs are portable across different systems, such as Allegro, but most of these are aimed at game development; they would be overkill for this purpose.
rich_m

Re:viewing a pic in 'C'

Post by rich_m »

how bout the file being a bmp an the os windows?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:viewing a pic in 'C'

Post by Solar »

Look up the Windows API documentation, then.

The C language proper and standard library does not have any primitives for displaying graphics. (Hey, this ain't Java or VB!) It just gives you the syntax to access whatever API is provided by OS / graphics subsystem.
Every good solution is obvious once you've found it.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:viewing a pic in 'C'

Post by Pype.Clicker »

Okay, very basically:
- you have a library to make I/O calls (open, read, write, etc) which you can use to open the BMP file
- you need a library that gives you a "window" you can draw in. I'm not a window coder, so i can't help for this, but googling for gdi, "windows.h" or even DirectDraw tutorials should give you advices in 10 mins.
- that's being done, you may check http://www.wotsit.org/ to see how a BMP is structured, what information it contains and derive a way to render it on screen. That's rather simple ...

That's so simple that there are chances that your window-drawing library even has a call that does the whole job in a single call, but i thought you might wonder what's going on beyond DrawBmp(Window*, char* bmp);
Post Reply