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
37 #include "../include/prototype.h"
39 #ifdef HAVE_LIBDMALLOC
56 extern COLOR colors
[MAX_COLORS
];
61 gdImagePtr current_im_ptr
;
64 * \par Function Description
67 void o_image_init(void)
73 * \par Function Description
77 * \param [in] color_mode
79 /* background color ? */
80 void o_image_create(int x
, int y
, int color_mode
)
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
);
96 image_black
= gdImageColorAllocate(im_ptr
, 0, 0, 0);
98 image_white
= gdImageColorAllocate(im_ptr
, 255, 255, 255);
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();
111 * \par Function Description
114 void o_image_close(void)
116 gdImageDestroy(current_im_ptr
);
120 * \par Function Description
123 int o_image_write(const char *filename
)
127 if (filename
== NULL
) {
131 gdImageInterlace(current_im_ptr
, 1);
133 out
= fopen(filename
, "wb");
136 s_log_message("Could not open [%s] for image writting\n", filename
);
140 gdImagePng(current_im_ptr
, out
);
148 * \par Function Description
151 /* this can stay in even if libgd doesn't exist */
152 int o_image_geda2gd_color(int color
)
155 value
= s_color_image_int(color
);