Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,545 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,563 people online right now. Registration is fast and FREE... Join Now!




Drawing flags with 2D arrays in C!

 
Reply to this topicStart new topic

Drawing flags with 2D arrays in C!

Johnathan
30 Oct, 2007 - 05:06 AM
Post #1

New D.I.C Head
*

Joined: 30 Oct, 2007
Posts: 1


My Contributions
PLEASE HELP MEEEEE

could anyone possibly show me how to draw flags in C using a 2D arrays that refer to a ppm file and convert the end image to a gif file.

christ im having trouble like... anyone got any idea?

I have also attached the blue.ppm file


Here's more info on it!

1: Write a program to generate a ppm file representing a blue square on a red background.
blue.ppm blue.ppm as txt shows an example .

Convert this to a gif file, using (on Unix)
convert pic2.ppm pic2.gif

Write a web page to display the picture in its gif encoding.
<img src="pic2.gif" alt="">

2: Write a program to draw a web page of the flags of the 27 countries of the European union.
The size of the flags should be variable, and set by an input parameter to the program at run time.
Where the flag has a complex symbol on it, you should draw the flag without the symbol. e.g. Spain, Slovenia.
Flags should be drawn with a height to width ratio of 2 : 3

3: Add a double size flag of the EU, centred at the top of the web page. The size of the stars should scale properly.

I have something like this so far.... but i am completely new to C and this is proving a challenge. Please help me!

CODE
#include <stdio.h>
#include <stdlib.h>

#define vertical 200
#define horizontal 300

struct color(int r, int g, int b);

int** newarray( int xmax, int ymax)
{
    int ** pic = (int **) malloc ((ymax+1) * sizeof(int *));
    int j;
    for ( j = 0; j<= ymax; j ++) {
        pic[j] = (int *) malloc (xmax * sizeof(int));
        };
    return pic;
}

int main() {
    int ** BB = newarray(8,5);
    int r,g,b;
    for ( g = 0; g<= 9; g++) {
        for ( r = 0; r<=3, g++);
        
        







Attached File(s)
Attached File  blue.txt ( 1.03k ) Number of downloads: 27
User is offlineProfile CardPM
+Quote Post

Pontus
RE: Drawing Flags With 2D Arrays In C!
30 Oct, 2007 - 12:39 PM
Post #2

Dreaming Coder / Coding Dreamer
Group Icon

Joined: 28 Dec, 2006
Posts: 544



Thanked: 4 times
Dream Kudos: 275
My Contributions
If u want to output a image u can better take a look at SDL or Allegro
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 09:30PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month