Thread: Program to create shapes in PPM

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    18

    Program to create shapes in PPM

    PLEASE HELP! I have a project in which I have to create a program that reads an input file and outputs an output file which can be opened as a PPM. The input file contains a letter referring to a shape (either a rectangle, circle, or ellipse), a color (RGB), an x and y-offset, and a radius (for circles), dimensions (rectangle), or major axis size (ellipse).

    I have absolutely NO idea how to even start this project. I know that we have to use arrays and loops, but I just started programming and need help to get started. Please let me know if you have any clarifying questions.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Not experienced with it, but first thing I'd do is d/l a couple small ppm files, and a ppm viewer. Without a viewer, and some files to ensure it works OK, how will you know when you have created a good ppm file?

    Then, look into a library that handles ppm format OR Google,and read up on the ppm format your file output will need to follow.

    The first part of your work involves a lot of ppm learning by you, and very little or no C language. I would NOT wait around posting on C forums, for a lot of help with that.

    When you have the viewer, and know the format, then jump back here for any help you need with the actual C portion of it. Don't wait around, because these kinds of projects can take a lot more time than you would expect.

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    18
    I understand how PPMs work; they output a text file with a color for each and every pixel.
    For example:
    0 0 0 # 0, 0
    would print black (0 0 0 are it's RGB vals) at the point (0, 0). I just don't understand how to make an array and/or loops to print out this huge list of colors and point coordinates.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    How about

    sometype pixels[YSIZE][XSIZE];

    Pick a suitable type for sometype.
    Pick suitable sizes.

    Create a simple function to "plot a pixel" in your grid.
    Create a function to draw a line between two points.
    Create a function to draw rectangle, circle, ellipse....

    Then write out your grid as PPM file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with a Battleship Program
    By HBlakeH in forum C Programming
    Replies: 1
    Last Post: 12-05-2010, 11:13 PM
  2. Replies: 2
    Last Post: 09-16-2009, 06:00 AM
  3. How to create a file association program?
    By eShain in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2006, 12:15 PM
  4. Trying to create a payroll calculation program
    By nadeni0119 in forum C++ Programming
    Replies: 1
    Last Post: 04-01-2003, 04:14 PM
  5. program won't create status bar
    By Unregistered in forum Windows Programming
    Replies: 7
    Last Post: 08-30-2001, 04:00 PM

Tags for this Thread