00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef NOMALLOCH
00022 #include <malloc.h>
00023 #endif
00024 #include <stdio.h>
00025 #include <math.h>
00026 #include <string.h>
00027 #include <stdlib.h>
00028 #include "defines.h"
00029 #include "cd.h"
00030
00031
00032 int main()
00033 {
00034 cdImagePtr im;
00035 FILE *outf;
00036
00037
00038
00039 im = cdImageCreate( 400, 500 );
00040
00041
00042 if ( -1 == cdImageColor16( im ) )
00043 return 1;
00044
00045
00046
00047 if ( !( cdSetShapeFillAttrib( im, 1, 0, 1 ) ) )
00048 return 1;
00049
00050
00051
00052 if ( !( cdSetTextAttrib( im, 5, 1, 25 ) ) )
00053 return 1;
00054
00055
00056
00057 cdSetShapeEdgeAttrib( im, 1, 1, 1, 1 );
00058
00059
00060
00061 if ( !( cdRectangle( im, 10, 450, 35, 425 ) ) )
00062 return 1;
00063
00064 if ( !( cdText( im, 40, 425, "Color Index: 0" ) ) )
00065 return 1;
00066
00067
00068 if ( !( cdSetEdgeVis( im, 0 ) ) )
00069 return 1;
00070
00071
00072
00073 if ( !( cdSetFillColor( im, 1 ) ) )
00074 return 1;
00075
00076 if ( !( cdRectangle( im, 10, 400, 35, 375 ) ) )
00077 return 1;
00078
00079 if ( !( cdText( im, 40, 375, "Color Index: 1" ) ) )
00080 return 1;
00081
00082
00083 if ( !( cdSetFillColor( im, 2 ) ) )
00084 return 1;
00085
00086 if ( !( cdRectangle( im, 10, 350, 35, 325 ) ) )
00087 return 1;
00088
00089 if ( !( cdText( im, 40, 325, "Color Index: 2" ) ) )
00090 return 1;
00091
00092
00093 if ( !( cdSetFillColor( im, 3 ) ) )
00094 return 1;
00095
00096 if ( !( cdRectangle( im, 10, 300, 35, 275 ) ) )
00097 return 1;
00098
00099 if ( !( cdText( im, 40, 275, "Color Index: 3" ) ) )
00100 return 1;
00101
00102
00103 if ( !( cdSetFillColor( im, 4 ) ) )
00104 return 1;
00105
00106 if ( !( cdRectangle( im, 10, 250, 35, 225 ) ) )
00107 return 1;
00108
00109 if ( !( cdText( im, 40, 225, "Color Index: 4" ) ) )
00110 return 1;
00111
00112
00113 if ( !( cdSetFillColor( im, 5 ) ) )
00114 return 1;
00115
00116 if ( !( cdRectangle( im, 10, 200, 35, 175 ) ) )
00117 return 1;
00118
00119 if ( !( cdText( im, 40, 175, "Color Index: 5" ) ) )
00120 return 1;
00121
00122
00123 if ( !( cdSetFillColor( im, 6 ) ) )
00124 return 1;
00125
00126 if ( !( cdRectangle( im, 10, 150, 35, 125 ) ) )
00127 return 1;
00128
00129 if ( !( cdText( im, 40, 125, "Color Index: 6" ) ) )
00130 return 1;
00131
00132
00133 if ( !( cdSetFillColor( im, 7 ) ) )
00134 return 1;
00135
00136 if ( !( cdRectangle( im, 10, 100, 35, 75 ) ) )
00137 return 1;
00138
00139 if ( !( cdText( im, 40, 75, "Color Index: 7" ) ) )
00140 return 1;
00141
00142
00143 if ( !( cdSetFillColor( im, 8 ) ) )
00144 return 1;
00145
00146 if ( !( cdRectangle( im, 210, 450, 235, 425 ) ) )
00147 return 1;
00148
00149 if ( !( cdText( im, 240, 425, "Color Index: 8" ) ) )
00150 return 1;
00151
00152
00153 if ( !( cdSetFillColor( im, 9 ) ) )
00154 return 1;
00155
00156 if ( !( cdRectangle( im, 210, 400, 235, 375 ) ) )
00157 return 1;
00158
00159 if ( !( cdText( im, 240, 375, "Color Index: 9" ) ) )
00160 return 1;
00161
00162
00163 if ( !( cdSetFillColor( im, 10 ) ) )
00164 return 1;
00165
00166 if ( !( cdRectangle( im, 210, 350, 235, 325 ) ) )
00167 return 1;
00168
00169 if ( !( cdText( im, 240, 325, "Color Index: 10" ) ) )
00170 return 1;
00171
00172
00173 if ( !( cdSetFillColor( im, 11 ) ) )
00174 return 1;
00175
00176 if ( !( cdRectangle( im, 210, 300, 235, 275 ) ) )
00177 return 1;
00178
00179 if ( !( cdText( im, 240, 275, "Color Index: 11" ) ) )
00180 return 1;
00181
00182
00183 if ( !( cdSetFillColor( im, 12 ) ) )
00184 return 1;
00185
00186 if ( !( cdRectangle( im, 210, 250, 235, 225 ) ) )
00187 return 1;
00188
00189 if ( !( cdText( im, 240, 225, "Color Index: 12" ) ) )
00190 return 1;
00191
00192
00193 if ( !( cdSetFillColor( im, 13 ) ) )
00194 return 1;
00195
00196 if ( !( cdRectangle( im, 210, 200, 235, 175 ) ) )
00197 return 1;
00198
00199 if ( !( cdText( im, 240, 175, "Color Index: 13" ) ) )
00200 return 1;
00201
00202
00203 if ( !( cdSetFillColor( im, 14 ) ) )
00204 return 1;
00205
00206 if ( !( cdRectangle( im, 210, 150, 235, 125 ) ) )
00207 return 1;
00208
00209 if ( !( cdText( im, 240, 125, "Color Index: 14" ) ) )
00210 return 1;
00211
00212
00213 if ( !( cdSetFillColor( im, 15 ) ) )
00214 return 1;
00215
00216 if ( !( cdRectangle( im, 210, 100, 235, 75 ) ) )
00217 return 1;
00218
00219 if ( !( cdText( im, 240, 75, "Color Index: 15" ) ) )
00220 return 1;
00221
00222
00223 if ( !cdText( im, 5, 10, "Colors allocated by cdImageColor16" ) )
00224 return 1;
00225
00226
00227 outf = fopen( "color16.cgm", "wb" );
00228 if ( !outf )
00229 return 1;
00230 cdImageCgm( im, outf );
00231 fclose( outf );
00232 outf = 0;
00233
00234
00235 cdImageDestroy( im );
00236 im = 0;
00237
00238 printf( "CGM with 16 color colortable generated as color16.cgm\n" );
00239
00240 return 0;
00241 }