Thread: Help with images and text display

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

    Help with images and text display

    Hey guys I'm pretty new to C, just looking to see how to display a image and some text to go along with it so far I can display in the image but cannot display the text at the same time.
    Any ideas?
    This is my source code below

    Code:
    #include <stdio.h>
    #include <gd.h>
    
    int main()
    
    {
      gdImagePtr gdImage = gdImageCreate( 100, 100 );
      FILE *jpgFile = NULL;
      int yellow;
    
      gdImageColorAllocate( gdImage, 0, 0, 0 );
     
      yellow = gdImageColorAllocate( gdImage, 255, 255, 0 );
    
      gdImageFilledEllipse( gdImage, 20, 80, 20, 20, yellow );
    
      jpgFile = fopen( "test.jpg", "wb" );
      gdImageJpeg( gdImage, jpgFile, -1);
    
      fclose( jpgFile );
      gdImageDestroy( gdImage );
      
      printf("test text\n");
    }

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    505
    The image library is non-standard and I don't know exactly how it works.

    But typically it will display images ina separate window. Printf() prints characters to the console. If you want to overlay text on the image, you don't want to pass the ascii values to the console, you want to look up the glyph, then write it as a graphic.
    Possibly the image library will provide some way of doing this.

    If it doesn't, go to my website, and look at the fonts section of the binary image library. That will give you some simple fonts so you can get started with mixing graphics and text.
    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


  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Function and type reference for gd 2.0.33

    If you want to add text to your graphic, you need to look at the text-handling functions.

    Bye, Andreas

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can i display images in C?
    By cursedninja in forum C Programming
    Replies: 7
    Last Post: 02-20-2009, 09:22 AM
  2. Type text = Press button = Display text in Google?
    By Raze88 in forum C++ Programming
    Replies: 4
    Last Post: 03-20-2008, 08:39 AM
  3. Display Images?
    By mburt in forum C++ Programming
    Replies: 14
    Last Post: 08-24-2006, 10:23 AM
  4. Replies: 2
    Last Post: 12-26-2001, 12:08 PM
  5. display pcx / bmp images
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 11-27-2001, 09:56 AM