Thread: Can I insert an image to my C file?

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    16

    Question Can I insert an image to my C file?

    I am talking about console C file .
    Can I insert images or colors in my C file? How?

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    It depends. What computer platform and compiler?

  3. #3
    Registered User
    Join Date
    Dec 2012
    Posts
    16
    its falcon C++ IDE
    and os Win7

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Hritik View Post
    its falcon C++ IDE
    and os Win7
    I am guessing the Compiler is MinGW GCC; please confirm that for the experts.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User
    Join Date
    Dec 2012
    Posts
    16
    Quote Originally Posted by stahta01 View Post
    I am guessing the Compiler is MinGW GCC; please confirm that for the experts.

    Tim S.
    Falcon is not a bad compiler.
    Do you know the code to do that?

  6. #6
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    For what it's worth, there are some FAQ entries that might help you along.
    FAQ > Display a picture file in DOS - Cprogramming.com
    FAQ > Color my text - Cprogramming.com

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Hritik View Post
    Falcon is not a bad compiler.
    Do you know the code to do that?
    I would guess that YOU can not do that.

    In order for you to have a chance on doing it; you need to learn the name and version of your compiler!

    Edit: Falcon is an IDE; not a compiler!

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by stahta01 View Post
    I would guess that YOU can not do that.

    In order for you to have a chance on doing it; you need to learn the name and version of your compiler!

    Edit: Falcon is an IDE; not a compiler!

    Tim S.
    Tim, Tim, Tim - why do you INSIST on bringing up these trivial DETAILS!
    < ROFL! >

  9. #9
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    For simple color text, I notice there is a simple "colorprintf" project on Github that you can use as a quick way to output color text.

    https://github.com/VittGam/colorprintf

    That should get you started with color on the console at least. The issue of color text on a text console can be complicated by cross-platform issues.

    For images, can you describe more precisely what you want to do? For example, if you literally mean to display a graphical image on a (text-based) console, there are some libraries to help you do this (libcaca and aalib are two that come to mind). The image data would be converted to "ASCII Art" characters which resemble the original image on the text console.

    On the other hand, if you want to display a graphical image in the normal fashion, then you simply can't use a console. You probably want to write a GUI application. Probably the most straightforward way to do this is to use a library/GUI framework designed for this. Examples are Qt, GTK, Fltk. All of these three offer tutorials for learning the basics, including displaying images.
    Last edited by c99tutorial; 12-26-2012 at 04:46 PM.

  10. #10
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Quote Originally Posted by c99tutorial View Post
    On the other hand, if you want to display a graphical image in the normal fashion, then you simply can't use a console. You probably want to write a GUI application. Probably the most straightforward way to do this is to use a library/GUI framework designed for this. Examples are Qt, GTK, Fltk. All of these three offer tutorials for learning the basics, including displaying images.
    I know there are windows versions for GTK+, is there one for QT and Fltk? I noticed the OP said he was on windows 7.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  11. #11
    Registered User
    Join Date
    Dec 2012
    Posts
    16
    Can you suggest a good small (about 6MB) C compiler(not IDE)??

  12. #12
    Registered User
    Join Date
    Dec 2012
    Posts
    307
    i tend to use pelles for c , and VC++ for my c++, but have also used GCC for C on some older systems, as it is semi small footprint.....

    GCC GCC, the GNU Compiler Collection - GNU Project - Free Software Foundation (FSF)

  13. #13
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by caroundw5h View Post
    I know there are windows versions for GTK+, is there one for QT and Fltk? I noticed the OP said he was on windows 7.
    All three are cross-platform and work on Windows as well as Linux, Mac OS X.

  14. #14
    Registered User
    Join Date
    May 2012
    Posts
    505
    An image is a set of pixel values internally, usually red, green and blue from 0-255. There's no way of representing this in C except by an array of unsigned chars. So one solution is to write .little utility to read in an image, and print it out as an array. However this is a a bit clumsy, so a lot of compilers offer an option to embed images. You then need a platform-specific library function to access the image data.
    A portable, ANSI C only, console program cannot display images. All it can do is write characters to standard output, or create files. However these files can be image files. The BMP, GIF and JPEG file formats are all explained in my book, Basic Algorithms.
    I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
    Visit my website for lots of associated C programming resources.
    https://github.com/MalcolmMcLean


  15. #15
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Can I insert an image to my C file?-ccgrapha-png
    Can I insert an image to my C file?-triangles1-png
    These are sreenshots of color screens I've made using the console only, either using conio.h or windows.h functions:

    Colors are limited, for both foreground and background. Windows.h offers some limited texturing of the color, which gives it a more "wood grain" type of look.

    Conio.h works with Windows. There are newer header files that have these same functions (and more), which work with Linux and/or Windows, as well. PDcurses and Ncurses comes to mind. I haven't used them, however.
    Last edited by Adak; 12-27-2012 at 04:37 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merge multiple image file into one image
    By mr_empty in forum C++ Programming
    Replies: 7
    Last Post: 12-09-2009, 02:12 PM
  2. insert/add a GIF image in VC++ 6.0
    By tdk02 in forum Windows Programming
    Replies: 4
    Last Post: 08-14-2006, 08:20 AM
  3. how to convert a bitmap image to a jpg image file using C++?
    By nomer in forum Windows Programming
    Replies: 4
    Last Post: 06-04-2006, 07:40 PM
  4. Insert image into email
    By caroundw5h in forum Tech Board
    Replies: 9
    Last Post: 09-07-2004, 07:33 AM
  5. Image class - loading image file
    By GaPe in forum Windows Programming
    Replies: 2
    Last Post: 07-11-2004, 01:35 PM