viewing a pic in 'C'
viewing a pic in 'C'
how is it possible to read(view) a picture file in a C program in graphics? :-\
Re:viewing a pic in 'C'
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'
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.
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.
- Pype.Clicker
- 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'
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);
- 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);