Page 1 of 1

viewing a pic in 'C'

Posted: Fri Jan 07, 2005 11:48 am
by rich_m
how is it possible to read(view) a picture file in a C program in graphics? :-\

Re:viewing a pic in 'C'

Posted: Fri Jan 07, 2005 1:16 pm
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.

Re:viewing a pic in 'C'

Posted: Fri Jan 07, 2005 1:18 pm
by rich_m
how bout the file being a bmp an the os windows?

Re:viewing a pic in 'C'

Posted: Mon Jan 10, 2005 2:17 am
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.

Re:viewing a pic in 'C'

Posted: Fri Jan 14, 2005 3:03 am
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);