2 * Name: Graphics functions
4 * Purpose: All the functions that are used to create the Online Signature Image
6 * Author: Pedro de Oliveira <falso@rdk.homeip.net>
8 * Copyright (c) 2004-2008 Pedro de Oliveira ( falso@rdk.homeip-net )
10 * This file is part of aMule.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the
24 * Free Software Foundation, Inc.,
25 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
35 #include "functions.h"
36 #include "configfile.h"
40 * this is the funcion that writes the text to the image.
41 * almost everything is taken from libgd examples
43 int createimage(CONF
*config
, char *lines
[IMG_TEXTLINES
], char *path_for_picture
)
51 if ( (in
= fopen(config
->font
, "r")) == NULL
) {
52 perror("font not found\ncheck casrc\n");
57 if ( (in
= fopen(config
->source
, "rb")) == NULL
) {
58 perror("source_image not found\ncheck casrc\n");
62 im
= gdImageCreateFromPng(in
);
64 perror("Error loading source image (not a valid png image file?).\n");
67 white
= gdImageColorResolve(im
, 255, 255, 255);
69 for (i
= 0; i
< IMG_TEXTLINES
; i
++) {
70 if (config
->enabled
[i
] == 1) {
71 gdImageStringFT(im
, &brect
[0], white
, config
->font
, config
->size
,
72 0.0, config
->x
[i
], config
->y
[i
], lines
[i
]);
76 if (config
->img_type
==0) {
77 path
= get_amule_path("aMule-online-sign.png", 0, path_for_picture
);
79 path
= get_amule_path("aMule-online-sign.jpg", 0, path_for_picture
);
82 if (path
== NULL
&& config
->img_type
==0) {
83 perror("could not get PNG path\n");
85 } else if (path
== NULL
) {
86 perror("could not get JPG path\n");
89 out
= fopen(path
, "w");
92 if (config
->img_type
==0) {
95 gdImageJpeg(im
, out
, -1);
99 printf("Online Signature picture created.\n");