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