All pastes #605190 Raw Edit

Stuff

public c v1 · immutable
·published 2007-07-06 00:35 UTC
rendered paste body
/*    Filename: ejemplo_gd.c *  *    compilacion bajo cualquier plataforma usando la libreria gd *     gcc -o ejemplogd.exe ejemplo_gd.c -lgd  *  *  *  */#include "gd.h"#include <stdio.h>int main() {  /* Declaramos la imagen */  gdImagePtr im;  /* punteros a FILE */  FILE *pngout, *jpegout;  /* indices de colores*/  int black;  int white;  /* reservamos 64 pixeles de ancho y 64 de alto*/  im = gdImageCreate(64, 64);  /* Allocate the color black (red, green and blue all minimum).    Since this is the first color in a new image, it will    be the background color. */  black = gdImageColorAllocate(im, 0, 0, 0);    /* Allocate the color white (red, green and blue all maximum). */  white = gdImageColorAllocate(im, 255, 255, 255);      /* Draw a line from the upper left to the lower right,    using white color index. */  gdImageLine(im, 0, 0, 63, 63, white);    printf("llamando a gdImageLine\n");      /*abrir el fichero en formato escritura "binaria" para crear el png   */  pngout = fopen("test.png", "wb");  printf("llamando a fopen\n");  /* lo mismo pero para jpg*/  jpegout = fopen("test.jpg", "wb");    printf("Llamando a gdImgPng\n");  /* escribir la imagen  en el disco duro (en el directorio donde se ejecuta el binario) en formato png */  gdImagePng(im, pngout);  /* lo mismo pero para jpg*/  gdImageJpeg(im, jpegout, -1);  /* cerrar ficheros. */  fclose(pngout);  fclose(jpegout);  /* destuir la imagen en momeoria. */  gdImageDestroy(im);}