Removed indent from gattrib's configure script.
[geda-gaf.git] / libgeda / src / o_image.c
blob870bd2b400219f717b79f696fa21b0a5a138cbbe
1 /* gEDA - GPL Electronic Design Automation
2 * libgeda - gEDA's library
3 * Copyright (C) 1998-2000 Ales V. Hvezda
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
19 #include <config.h>
21 #include <stdio.h>
23 #include <gtk/gtk.h>
24 #include <libguile.h>
26 #ifdef HAS_LIBGD
27 #include <gd.h>
28 #endif
30 #include "defines.h"
31 #include "struct.h"
32 #include "globals.h"
33 #include "o_types.h"
34 #include "funcs.h"
35 #include "colors.h"
37 #include "../include/prototype.h"
39 #ifdef HAVE_LIBDMALLOC
40 #include <dmalloc.h>
41 #endif
43 int image_black;
44 int image_white;
45 #if 0
46 int image_red;
47 int image_green;
48 int image_blue;
49 int image_yellow;
50 int image_cyan;
51 int image_grey;
52 #endif
54 #ifdef HAS_LIBGD
56 extern COLOR colors[MAX_COLORS];
58 /*! \brief
61 gdImagePtr current_im_ptr;
63 /*! \brief
64 * \par Function Description
67 void o_image_init(void)
72 /*! \brief
73 * \par Function Description
75 * \param [in] x
76 * \param [in] y
77 * \param [in] color_mode
79 /* background color ? */
80 void o_image_create(int x, int y, int color_mode)
82 gdImagePtr im_ptr;
84 im_ptr = gdImageCreate(x, y);
86 if (color_mode == TRUE) {
87 /* You can change the background color which is outputed */
88 if (colors[BACKGROUND_COLOR].image_red != -1 &&
89 colors[BACKGROUND_COLOR].image_green != -1 &&
90 colors[BACKGROUND_COLOR].image_blue != -1) {
91 image_black = gdImageColorAllocate(im_ptr,
92 colors[BACKGROUND_COLOR].image_red,
93 colors[BACKGROUND_COLOR].image_green,
94 colors[BACKGROUND_COLOR].image_blue);
95 } else {
96 image_black = gdImageColorAllocate(im_ptr, 0, 0, 0);
98 image_white = gdImageColorAllocate(im_ptr, 255, 255, 255);
99 } else {
100 /* set the background to white */
101 image_white = gdImageColorAllocate(im_ptr, 255, 255, 255);
102 image_black = gdImageColorAllocate(im_ptr, 0, 0, 0);
105 current_im_ptr = im_ptr;
107 s_color_gdcolor_init();
110 /*! \brief
111 * \par Function Description
114 void o_image_close(void)
116 gdImageDestroy(current_im_ptr);
119 /*! \brief
120 * \par Function Description
123 int o_image_write(const char *filename)
125 FILE *out;
127 if (filename == NULL) {
128 return(-1);
131 gdImageInterlace(current_im_ptr, 1);
133 out = fopen(filename, "wb");
135 if (out == NULL) {
136 s_log_message("Could not open [%s] for image writting\n", filename);
137 return(-1);
140 gdImagePng(current_im_ptr, out);
142 fclose(out);
143 return(0);
145 #endif
147 /*! \brief
148 * \par Function Description
151 /* this can stay in even if libgd doesn't exist */
152 int o_image_geda2gd_color(int color)
154 int value;
155 value = s_color_image_int(color);
156 return(value);