User Tools

Site Tools


haas:fall2020:cprog:projects:cos0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
haas:fall2020:cprog:projects:cos0 [2020/10/19 16:13] – [How to view your image] wedgehaas:fall2020:cprog:projects:cos0 [2020/10/19 16:14] (current) – [Raspberry Pi command-line via SSH/MOSH] wedge
Line 52: Line 52:
  
 Now, gd has functions for drawing circles. You are **NOT** to use them for this project. As I said, this is a circle //of squares//. As such, you will be making use of the **gdImageFilledRectangle()** function. Now, gd has functions for drawing circles. You are **NOT** to use them for this project. As I said, this is a circle //of squares//. As such, you will be making use of the **gdImageFilledRectangle()** function.
- 
-====getting started==== 
-You may make use of the following skeleton program to assist you in doing this project. 
- 
-Note that this code is not in conformance with project specifications, but is provided to give you a starting place for modifications and additions: 
- 
-<code c> 
-/* 
- * cos0.c   - skeleton code to use the GD graphics library 
-                        to create an image (circle of squares). 
- * 
- * To compile: type 'make' to compile the program 
-         or: gcc --std=c99 -Wall -o cos0 cos0.c -lgd 
- * To execute: ./cos0 ARGS 
- * 
- * Documentation:  http://www.boutell.com/gd/manual2.0.33.html 
-                 https://libgd.github.io/manuals/2.1.1/index/Functions.html 
- */ 
-#include <stdio.h> 
-#include <stdlib.h> 
-#include <string.h> 
-#include <sys/stat.h> 
-#include <gd.h> 
- 
-// color values 
-// 
-#define BLACK       0 
-#define BLUE        1 
-#define GREEN       2 
-#define RED         3 
-#define WHITE       4 
- 
-int main(int argc, char **argv) 
-{ 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // Declare variables 
-        // 
-        char               *outfile;    // name out of the output file 
-        FILE               *out;        // output file pointer 
-        gdImagePtr          img;        // GD Image Construct 
-        unsigned int        color[5];   // color array 
-        unsigned short int  wide, high; // image attributes 
- 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // Check arguments 
-        // 
-        if (argc     == 2) 
-        { 
-                outfile   = *(argv+1); 
-                fprintf(stdout, "Using '%s' as output filename\n", outfile); 
-        } 
-        else 
-        { 
-                outfile   = (char *) malloc (sizeof(char) * 64); 
-                sprintf(outfile, "/home/%s/public_html/cos0.png", getenv("USER")); 
-        } 
- 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // image dimensions 
-        // 
-        wide          = 600; 
-        high          = 800; 
- 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // Create new image of specified wide-ness and high-ness 
-        // 
-        img           = gdImageCreate(wide, high); 
- 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // Some GD color definitions 
-        // 
-        color[BLACK]  = gdImageColorAllocate(img, 0x00, 0x00, 0x00); 
-        color[BLUE]   = gdImageColorAllocate(img, 0x00, 0x00, 0xFF); 
-        color[GREEN]  = gdImageColorAllocate(img, 0x00, 0xFF, 0x00); 
-        color[RED]    = gdImageColorAllocate(img, 0xFF, 0x00, 0x00); 
-        color[WHITE]  = gdImageColorAllocate(img, 0xFF, 0xFF, 0xFF); 
- 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // Paint the background black 
-        // 
-        gdImageFilledRectangle(img, 0, 0, wide-1, high-1, color[BLACK]); 
- 
-    /**************************************************************** 
-                                                                  * 
-      =============>  YOUR CODE/PROGRAM GOES HERE  <============  * 
-                                                                  * 
-     ****************************************************************/ 
- 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // Open the file 
-        // 
-        out           = fopen(outfile, "wb"); 
-        if(out       == NULL) 
-        { 
-                fprintf(stderr, "Error opening '%s'\n", outfile); 
-                exit(1); 
-        } 
- 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // Set sane file permissions on image file 
-        // 
-        chmod (outfile, 0644); 
- 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // Send image to file 
-        // 
-        gdImagePngEx(img, out, -1); 
- 
-        ////////////////////////////////////////////////////////////////// 
-        // 
-        // Close things up 
-        // 
-        fclose(out); 
-        gdImageDestroy(img); 
- 
-        return(0); 
-} 
-</code> 
  
  
Line 230: Line 103:
  
 <cli> <cli>
-yourpi:~/src/desig/cos0$ scp lob0.png yourusername@lab46.g7n.org:public_html/+yourpi:~/src/desig/cos0$ scp cos0.png yourusername@lab46.g7n.org:public_html/
 </cli> </cli>
  
haas/fall2020/cprog/projects/cos0.1603138401.txt.gz · Last modified: 2020/10/19 16:13 by wedge