4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 2d8a045 was
f20d66c,
checked in by Perry Lorier <perry@…>, 14 years ago
|
Fix some warnings found on mroe recent gcc's
Bump version and release 3.0.6
|
-
Property mode set to
100644
|
File size:
2.0 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 | #include <inttypes.h> |
---|
10 | #include <lt_inttypes.h> |
---|
11 | #include <err.h> |
---|
12 | |
---|
13 | struct private_png_t { |
---|
14 | int rows; |
---|
15 | float *data; |
---|
16 | }; |
---|
17 | |
---|
18 | static void output_png_init(struct output_data_t *out) |
---|
19 | { |
---|
20 | out->private_format_data=malloc(sizeof(struct private_png_t)); |
---|
21 | ((struct private_png_t *)out->private_format_data)->rows=0; |
---|
22 | ((struct private_png_t *)out->private_format_data)->data=0; |
---|
23 | } |
---|
24 | |
---|
25 | static void output_png_flush(struct output_data_t *out) |
---|
26 | { |
---|
27 | int i; |
---|
28 | struct private_png_t *prv=out->private_format_data; |
---|
29 | prv->rows++; |
---|
30 | prv->data= realloc(prv->data,prv->rows*out->columns*sizeof(float)); |
---|
31 | for(i=0;i<out->columns;++i) { |
---|
32 | switch (out->data[i].type) { |
---|
33 | case TYPE_int: |
---|
34 | prv->data[out->columns*(prv->rows-1)+i]=out->data[i].d.d_int; |
---|
35 | break; |
---|
36 | case TYPE_str: |
---|
37 | free(out->data[i].d.d_str); |
---|
38 | break; |
---|
39 | case TYPE_float: |
---|
40 | prv->data[out->columns*(prv->rows-1)+i]=out->data[i].d.d_float; |
---|
41 | break; |
---|
42 | case TYPE_time: |
---|
43 | prv->data[out->columns*(prv->rows-1)+i]=out->data[i].d.d_time; |
---|
44 | break; |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | static void output_png_destroy(struct output_data_t *out) |
---|
50 | { |
---|
51 | struct private_png_t *prv=out->private_format_data; |
---|
52 | int i,j; |
---|
53 | char *labels[prv->rows]; |
---|
54 | float data1[(out->columns-1)/2][prv->rows]; |
---|
55 | float data2[(out->columns-1)/2][prv->rows]; |
---|
56 | for(i=0;i<prv->rows;++i) { |
---|
57 | if (asprintf(&labels[i],"%i",(int)prv->data[i*out->columns])==-1) { |
---|
58 | err(1,"Out of memory"); |
---|
59 | } |
---|
60 | for(j=0;j<(out->columns-1)/2;++j) { |
---|
61 | data1[j][i]=prv->data[i*out->columns+j*2+1]; |
---|
62 | data2[j][i]=prv->data[i*out->columns+j*2+2]; |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | GDC_image_type = GDC_PNG; |
---|
67 | GDC_title = out->title; |
---|
68 | GDC_out_graph( 640, 480, |
---|
69 | stdout, |
---|
70 | GDC_COMBO_LINE_LINE, |
---|
71 | prv->rows, |
---|
72 | labels, |
---|
73 | (out->columns-1)/2, |
---|
74 | (float*)data1, |
---|
75 | (float*)data2); |
---|
76 | free(prv->data); |
---|
77 | free(prv); |
---|
78 | } |
---|
79 | |
---|
80 | struct output_type_t output_png = { |
---|
81 | .name= "png", |
---|
82 | .init= output_png_init, |
---|
83 | .flush= output_png_flush, |
---|
84 | .destroy= output_png_destroy, |
---|
85 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.