1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
|
@c -*- mode: Noweb; noweb-doc-mode: texinfo-mode; noweb-code-mode: c-mode -*-
@node File o_image.c,,,Top
@chapter File @file{o_image.c}
@section File header
@format
@anchor{o_image.c - -root-}
@i{<<o_image.c : *>>=}@t{
@i{<<o_image.c : copyright and license -- @ref{o_image.c - copyright and license}>>}
/* DO NOT read or edit this file ! Use ../noweb/o_image.nw instead */
@i{<<o_image.c : include directives -- @ref{o_image.c - include directives}>>}
@i{<<o_image.c : global variables -- @ref{o_image.c - global variables}>>}
@i{<<o_image.c : o_image_init() -- @ref{o_image.c - o_image_init()}>>}
@i{<<o_image.c : o_image_create() -- @ref{o_image.c - o_image_create()}>>}
@i{<<o_image.c : o_image_close() -- @ref{o_image.c - o_image_close()}>>}
@i{<<o_image.c : o_image_write() -- @ref{o_image.c - o_image_write()}>>}
@i{<<o_image.c : o_image_geda2gd_color() -- @ref{o_image.c - o_image_geda2gd_color()}>>}
}
@end format
@format
@anchor{o_image.c - copyright and license}
@i{<<o_image.c : copyright and license>>=}@t{
/* gEDA - GPL Electronic Design Automation
* libgeda - gEDA's library
* Copyright (C) 1998-2000 Ales V. Hvezda
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
*/
}
@end format
@format
@anchor{o_image.c - include directives}
@i{<<o_image.c : include directives>>=}@t{
#include <config.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <libguile.h>
#ifdef HAS_LIBGDGEDA
#include <gdgeda/gd.h>
#endif
#include "defines.h"
#include "struct.h"
#include "globals.h"
#include "o_types.h"
#include "funcs.h"
#include "colors.h"
#include "../include/prototype.h"
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
#endif
@display
@r{Uses :
@t{colors}, -- @ref{o_image.c - global variables}.
}
@end display
}
@end format
@format
@anchor{o_image.c - global variables}
@i{<<o_image.c : global variables>>=}@t{
int image_black;
int image_white;
#if 0
int image_red;
int image_green;
int image_blue;
int image_yellow;
int image_cyan;
int image_grey;
#endif
#ifdef HAS_LIBGDGEDA
extern COLOR colors[MAX_COLORS];
gdImagePtr current_im_ptr;
@display
@r{Defines :
@t{colors},
-- @ref{o_image.c - include directives},
-- @ref{o_image.c - o_image_create()}.
@t{current_im_ptr},
-- @ref{o_image.c - o_image_close()},
-- @ref{o_image.c - o_image_create()},
-- @ref{o_image.c - o_image_write()}.
.
@t{image},
-- @ref{o_image.c - o_image_write()}.
@t{image_black},
-- @ref{o_image.c - o_image_create()}.
@t{image_blue},
-- @ref{o_image.c - o_image_create()}.
@t{image_green},
-- @ref{o_image.c - o_image_create()}.
.
@t{image_red},
-- @ref{o_image.c - o_image_create()}.
@t{image_white},
-- @ref{o_image.c - o_image_create()}.
.
}
@end display
}
@end format
@section Function @code{o_image_init()}
@defun o_image_init
@end defun
@format
@anchor{o_image.c - o_image_init()}
@i{<<o_image.c : o_image_init()>>=}@t{
void
o_image_init(void)
@{
@}
@display
@r{Defines :
.
}
@end display
}
@end format
@section Function @code{o_image_create()}
@defun o_image_create x y color_mode
@end defun
@format
@anchor{o_image.c - o_image_create()}
@i{<<o_image.c : o_image_create()>>=}@t{
/* background color ? */
void
o_image_create(int x, int y, int color_mode)
@{
gdImagePtr im_ptr;
im_ptr = gdImageCreate(x, y);
if (color_mode == TRUE) @{
/* You can change the background color which is outputed */
if (colors[BACKGROUND_COLOR].image_red != -1 &&
colors[BACKGROUND_COLOR].image_green != -1 &&
colors[BACKGROUND_COLOR].image_blue != -1) @{
image_black = gdImageColorAllocate(im_ptr,
colors[BACKGROUND_COLOR].image_red,
colors[BACKGROUND_COLOR].image_green,
colors[BACKGROUND_COLOR].image_blue);
@} else @{
image_black = gdImageColorAllocate(im_ptr, 0, 0, 0);
@}
image_white = gdImageColorAllocate(im_ptr, 255, 255, 255);
@} else @{
/* set the background to white */
image_white = gdImageColorAllocate(im_ptr, 255, 255, 255);
image_black = gdImageColorAllocate(im_ptr, 0, 0, 0);
@}
current_im_ptr = im_ptr;
s_color_gdcolor_init();
@}
@display
@r{Defines :
.
}
@end display
@display
@r{Uses :
@t{colors}, -- @ref{o_image.c - global variables}.
@t{current_im_ptr}, -- @ref{o_image.c - global variables}.
@t{image_black}, -- @ref{o_image.c - global variables}.
@t{image_blue}, -- @ref{o_image.c - global variables}.
@t{image_green}, -- @ref{o_image.c - global variables}.
@t{image_red}, -- @ref{o_image.c - global variables}.
@t{image_white}, -- @ref{o_image.c - global variables}.
}
@end display
}
@end format
@section Function @code{o_image_close()}
@defun o_image_close
@end defun
@format
@anchor{o_image.c - o_image_close()}
@i{<<o_image.c : o_image_close()>>=}@t{
void
o_image_close(void)
@{
gdImageDestroy(current_im_ptr);
@}
@display
@r{Defines :
.
}
@end display
@display
@r{Uses :
@t{current_im_ptr}, -- @ref{o_image.c - global variables}.
}
@end display
}
@end format
@section Function @code{o_image_write()}
@defun o_image_write filename
@end defun
@format
@anchor{o_image.c - o_image_write()}
@i{<<o_image.c : o_image_write()>>=}@t{
int
o_image_write(const char *filename)
@{
FILE *out;
if (filename == NULL) @{
return(-1);
@}
gdImageInterlace(current_im_ptr, 1);
out = fopen(filename, "wb");
if (out == NULL) @{
s_log_message("Could not open [%s] for image writting\n", filename);
return(-1);
@}
gdImagePng(current_im_ptr, out);
fclose(out);
return(0);
@}
#endif
@display
@r{Defines :
.
}
@end display
@display
@r{Uses :
@t{current_im_ptr}, -- @ref{o_image.c - global variables}.
@t{image}, -- @ref{o_image.c - global variables}.
}
@end display
}
@end format
@section Function @code{o_image_geda2gd_color()}
@defun o_image_geda2gd_color color
@end defun
@format
@anchor{o_image.c - o_image_geda2gd_color()}
@i{<<o_image.c : o_image_geda2gd_color()>>=}@t{
/* this can stay in even if libgdgeda doesn't exist */
int
o_image_geda2gd_color(int color)
@{
int value;
value = s_color_image_int(color);
return(value);
@}
@display
@r{Defines :
.
}
@end display
}
@end format
|