4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since dc0162b was
8e99466,
checked in by Perry Lorier <perry@…>, 17 years ago
|
Get rid of an ugly warning
|
-
Property mode set to
100644
|
File size:
1.9 KB
|
Line | |
---|
1 | #define HAVE_LIBFREETYPE |
---|
2 | #define _GNU_SOURCE |
---|
3 | #include "output.h" |
---|
4 | #include <stdio.h> |
---|
5 | #include <stdlib.h> |
---|
6 | #include "gdc.h" |
---|
7 | #include "gdchart.h" |
---|
8 | #include "gdcpie.h" |
---|
9 | |
---|
10 | struct private_png_t { |
---|
11 | int rows; |
---|
12 | float *data; |
---|
13 | }; |
---|
14 | |
---|
15 | static void output_png_init(struct output_data_t *out) |
---|
16 | { |
---|
17 | out->private_format_data=malloc(sizeof(struct private_png_t)); |
---|
18 | ((struct private_png_t *)out->private_format_data)->rows=0; |
---|
19 | ((struct private_png_t *)out->private_format_data)->data=0; |
---|
20 | } |
---|
21 | |
---|
22 | static void output_png_flush(struct output_data_t *out) |
---|
23 | { |
---|
24 | int i; |
---|
25 | struct private_png_t *prv=out->private_format_data; |
---|
26 | prv->rows++; |
---|
27 | prv->data= realloc(prv->data,prv->rows*out->columns*sizeof(float)); |
---|
28 | for(i=0;i<out->columns;++i) { |
---|
29 | switch (out->data[i].type) { |
---|
30 | case TYPE_int: |
---|
31 | prv->data[out->columns*(prv->rows-1)+i]=out->data[i].d_int; |
---|
32 | break; |
---|
33 | case TYPE_str: |
---|
34 | free(out->data[i].d_str); |
---|
35 | break; |
---|
36 | case TYPE_float: |
---|
37 | prv->data[out->columns*(prv->rows-1)+i]=out->data[i].d_float; |
---|
38 | break; |
---|
39 | case TYPE_time: |
---|
40 | prv->data[out->columns*(prv->rows-1)+i]=out->data[i].d_time; |
---|
41 | break; |
---|
42 | } |
---|
43 | } |
---|
44 | } |
---|
45 | |
---|
46 | static void output_png_destroy(struct output_data_t *out) |
---|
47 | { |
---|
48 | struct private_png_t *prv=out->private_format_data; |
---|
49 | int i,j; |
---|
50 | char *labels[prv->rows]; |
---|
51 | float data1[(out->columns-1)/2][prv->rows]; |
---|
52 | float data2[(out->columns-1)/2][prv->rows]; |
---|
53 | for(i=0;i<prv->rows;++i) { |
---|
54 | asprintf(&labels[i],"%i",(int)prv->data[i*out->columns]); |
---|
55 | for(j=0;j<(out->columns-1)/2;++j) { |
---|
56 | data1[j][i]=prv->data[i*out->columns+j*2+1]; |
---|
57 | data2[j][i]=prv->data[i*out->columns+j*2+2]; |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | GDC_image_type = GDC_PNG; |
---|
62 | GDC_title = out->title; |
---|
63 | GDC_out_graph( 640, 480, |
---|
64 | stdout, |
---|
65 | GDC_COMBO_LINE_LINE, |
---|
66 | prv->rows, |
---|
67 | labels, |
---|
68 | (out->columns-1)/2, |
---|
69 | (float*)data1, |
---|
70 | (float*)data2); |
---|
71 | free(prv->data); |
---|
72 | free(prv); |
---|
73 | } |
---|
74 | |
---|
75 | struct output_type_t output_png = { |
---|
76 | name: "png", |
---|
77 | init: output_png_init, |
---|
78 | flush: output_png_flush, |
---|
79 | destroy: output_png_destroy, |
---|
80 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.