Like Tree4Likes

Can I insert an image to my C file?

This is a discussion on Can I insert an image to my C file? within the C Programming forums, part of the General Programming Boards category; I am talking about console C file . Can I insert images or colors in my C file? How?...

  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
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    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
    2,779
    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.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  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
    2,706
    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
    2,779
    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.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  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,220
    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.

  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
    289
    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,220
    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
    333
    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.
    http://www.malcolmmclean.site11.com/www

  15. #15
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Name:  ccGraphA.PNG
Views: 1332
Size:  27.8 KB
    Name:  triangles1.PNG
Views: 1331
Size:  6.0 KB
    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.

Page 1 of 2 12 LastLast
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, 09: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, 08:40 PM
  4. Insert image into email
    By caroundw5h in forum Tech Board
    Replies: 9
    Last Post: 09-07-2004, 08:33 AM
  5. Image class - loading image file
    By GaPe in forum Windows Programming
    Replies: 2
    Last Post: 07-11-2004, 02:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21