| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
#include "MagickWand/studio.h" |
| 44 |
#include "MagickWand/MagickWand.h" |
| 45 |
#include "MagickCore/colorspace-private.h" |
| 46 |
#include "MagickCore/gem.h" |
| 47 |
#include "MagickCore/resource_.h" |
| 48 |
#include "MagickCore/string-private.h" |
| 49 |
#include "validate.h" |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
#if defined(__APPLE__) |
| 55 |
#include "TargetConditionals.h" |
| 56 |
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV |
| 57 |
#define system(s) ((s)==NULL ? 0 : -1) |
| 58 |
#endif |
| 59 |
#elif defined(__ANDROID__) |
| 60 |
#define system(s) ((s)==NULL ? 0 : -1) |
| 61 |
#endif |
| 62 |
#define CIEEpsilon (216.0/24389.0) |
| 63 |
#define CIEK (24389.0/27.0) |
| 64 |
#define D65X 0.95047 |
| 65 |
#define D65Y 1.0 |
| 66 |
#define D65Z 1.08883 |
| 67 |
#define ReferenceEpsilon ((double) QuantumRange*1.0e-2) |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
static MagickBooleanType ValidateHSIToRGB() |
| 96 |
{ |
| 97 |
double |
| 98 |
r, |
| 99 |
g, |
| 100 |
b; |
| 101 |
|
| 102 |
(void) FormatLocaleFile(stdout," HSIToRGB"); |
| 103 |
ConvertHSIToRGB(111.244375/360.0,0.295985,0.658734,&r,&g,&b); |
| 104 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 105 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 106 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 107 |
return(MagickFalse); |
| 108 |
return(MagickTrue); |
| 109 |
} |
| 110 |
|
| 111 |
static MagickBooleanType ValidateRGBToHSI() |
| 112 |
{ |
| 113 |
double |
| 114 |
h, |
| 115 |
i, |
| 116 |
s; |
| 117 |
|
| 118 |
(void) FormatLocaleFile(stdout," RGBToHSI"); |
| 119 |
ConvertRGBToHSI(0.545877*(double) QuantumRange,0.966567*(double) |
| 120 |
QuantumRange,0.463759*(double) QuantumRange,&h,&s,&i); |
| 121 |
if ((fabs(h-111.244374/360.0) >= ReferenceEpsilon) || |
| 122 |
(fabs(s-0.295985) >= ReferenceEpsilon) || |
| 123 |
(fabs(i-0.658734) >= ReferenceEpsilon)) |
| 124 |
return(MagickFalse); |
| 125 |
return(MagickTrue); |
| 126 |
} |
| 127 |
|
| 128 |
static MagickBooleanType ValidateHSLToRGB() |
| 129 |
{ |
| 130 |
double |
| 131 |
r, |
| 132 |
g, |
| 133 |
b; |
| 134 |
|
| 135 |
(void) FormatLocaleFile(stdout," HSLToRGB"); |
| 136 |
ConvertHSLToRGB(110.200859/360.0,0.882623,0.715163,&r,&g,&b); |
| 137 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 138 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 139 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 140 |
return(MagickFalse); |
| 141 |
return(MagickTrue); |
| 142 |
} |
| 143 |
|
| 144 |
static MagickBooleanType ValidateRGBToHSL() |
| 145 |
{ |
| 146 |
double |
| 147 |
h, |
| 148 |
l, |
| 149 |
s; |
| 150 |
|
| 151 |
(void) FormatLocaleFile(stdout," RGBToHSL"); |
| 152 |
ConvertRGBToHSL(0.545877*(double) QuantumRange,0.966567*(double) |
| 153 |
QuantumRange,0.463759*(double) QuantumRange,&h,&s,&l); |
| 154 |
if ((fabs(h-110.200859/360.0) >= ReferenceEpsilon) || |
| 155 |
(fabs(s-0.882623) >= ReferenceEpsilon) || |
| 156 |
(fabs(l-0.715163) >= ReferenceEpsilon)) |
| 157 |
return(MagickFalse); |
| 158 |
return(MagickTrue); |
| 159 |
} |
| 160 |
|
| 161 |
static MagickBooleanType ValidateHSVToRGB() |
| 162 |
{ |
| 163 |
double |
| 164 |
r, |
| 165 |
g, |
| 166 |
b; |
| 167 |
|
| 168 |
(void) FormatLocaleFile(stdout," HSVToRGB"); |
| 169 |
ConvertHSVToRGB(110.200859/360.0,0.520200,0.966567,&r,&g,&b); |
| 170 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 171 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 172 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 173 |
return(MagickFalse); |
| 174 |
return(MagickTrue); |
| 175 |
} |
| 176 |
|
| 177 |
static MagickBooleanType ValidateRGBToHSV() |
| 178 |
{ |
| 179 |
double |
| 180 |
h, |
| 181 |
s, |
| 182 |
v; |
| 183 |
|
| 184 |
(void) FormatLocaleFile(stdout," RGBToHSV"); |
| 185 |
ConvertRGBToHSV(0.545877*(double) QuantumRange,0.966567*(double) |
| 186 |
QuantumRange,0.463759*(double) QuantumRange,&h,&s,&v); |
| 187 |
if ((fabs(h-110.200859/360.0) >= ReferenceEpsilon) || |
| 188 |
(fabs(s-0.520200) >= ReferenceEpsilon) || |
| 189 |
(fabs(v-0.966567) >= ReferenceEpsilon)) |
| 190 |
return(MagickFalse); |
| 191 |
return(MagickTrue); |
| 192 |
} |
| 193 |
|
| 194 |
static MagickBooleanType ValidateRGBToJPEGYCbCr() |
| 195 |
{ |
| 196 |
double |
| 197 |
Cb, |
| 198 |
Cr, |
| 199 |
Y; |
| 200 |
|
| 201 |
(void) FormatLocaleFile(stdout," RGBToJPEGYCbCr"); |
| 202 |
ConvertRGBToYCbCr(0.545877*(double) QuantumRange,0.966567*(double) |
| 203 |
QuantumRange,0.463759*(double) QuantumRange,&Y,&Cb,&Cr); |
| 204 |
if ((fabs(Y-0.783460) >= ReferenceEpsilon) || |
| 205 |
(fabs(Cb-0.319581) >= ReferenceEpsilon) || |
| 206 |
(fabs(Cr-0.330539) >= ReferenceEpsilon)) |
| 207 |
return(MagickFalse); |
| 208 |
return(MagickTrue); |
| 209 |
} |
| 210 |
|
| 211 |
static MagickBooleanType ValidateJPEGYCbCrToRGB() |
| 212 |
{ |
| 213 |
double |
| 214 |
r, |
| 215 |
g, |
| 216 |
b; |
| 217 |
|
| 218 |
(void) FormatLocaleFile(stdout," JPEGYCbCrToRGB"); |
| 219 |
ConvertYCbCrToRGB(0.783460,0.319581,0.330539,&r,&g,&b); |
| 220 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 221 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 222 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 223 |
return(MagickFalse); |
| 224 |
return(MagickTrue); |
| 225 |
} |
| 226 |
|
| 227 |
static MagickBooleanType ValidateLabToRGB() |
| 228 |
{ |
| 229 |
double |
| 230 |
r, |
| 231 |
g, |
| 232 |
b; |
| 233 |
|
| 234 |
(void) FormatLocaleFile(stdout," LabToRGB"); |
| 235 |
ConvertLabToRGB(88.456154/100.0,-54.671483/255+0.5,51.662818/255.0+0.5, |
| 236 |
D65Illuminant,&r,&g,&b); |
| 237 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 238 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 239 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 240 |
return(MagickFalse); |
| 241 |
return(MagickTrue); |
| 242 |
} |
| 243 |
|
| 244 |
static MagickBooleanType ValidateRGBToLab() |
| 245 |
{ |
| 246 |
double |
| 247 |
a, |
| 248 |
b, |
| 249 |
L; |
| 250 |
|
| 251 |
(void) FormatLocaleFile(stdout," RGBToLab"); |
| 252 |
ConvertRGBToLab(0.545877*(double) QuantumRange,0.966567*(double) |
| 253 |
QuantumRange,0.463759*(double) QuantumRange,D65Illuminant,&L,&a,&b); |
| 254 |
if ((fabs(L-(88.456154/100.0)) >= ReferenceEpsilon) || |
| 255 |
(fabs(a-(-54.671483/255.0+0.5)) >= ReferenceEpsilon) || |
| 256 |
(fabs((double) b-(51.662818/255.0+0.5)) >= ReferenceEpsilon)) |
| 257 |
return(MagickFalse); |
| 258 |
return(MagickTrue); |
| 259 |
} |
| 260 |
|
| 261 |
static MagickBooleanType ValidateLchToRGB() |
| 262 |
{ |
| 263 |
double |
| 264 |
b, |
| 265 |
g, |
| 266 |
r; |
| 267 |
|
| 268 |
(void) FormatLocaleFile(stdout," LchToRGB"); |
| 269 |
ConvertLCHabToRGB(88.456154/100.0,75.219797/255.0+0.5,136.620717/360.0, |
| 270 |
D65Illuminant,&r,&g,&b); |
| 271 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 272 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 273 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 274 |
return(MagickFalse); |
| 275 |
return(MagickTrue); |
| 276 |
} |
| 277 |
|
| 278 |
static MagickBooleanType ValidateRGBToLch() |
| 279 |
{ |
| 280 |
double |
| 281 |
c, |
| 282 |
h, |
| 283 |
L; |
| 284 |
|
| 285 |
(void) FormatLocaleFile(stdout," RGBToLch"); |
| 286 |
ConvertRGBToLCHab(0.545877*(double) QuantumRange,0.966567*(double) |
| 287 |
QuantumRange,0.463759*(double) QuantumRange,D65Illuminant,&L,&c,&h); |
| 288 |
if ((fabs(L-88.456154/100.0) >= ReferenceEpsilon) || |
| 289 |
(fabs(c-(75.219797/255.0+0.5)) >= ReferenceEpsilon) || |
| 290 |
(fabs(h-(136.620717/255.0+0.5)) >= ReferenceEpsilon)) |
| 291 |
return(MagickFalse); |
| 292 |
return(MagickTrue); |
| 293 |
} |
| 294 |
|
| 295 |
static MagickBooleanType ValidateRGBToLMS() |
| 296 |
{ |
| 297 |
double |
| 298 |
L, |
| 299 |
M, |
| 300 |
S; |
| 301 |
|
| 302 |
(void) FormatLocaleFile(stdout," RGBToLMS"); |
| 303 |
ConvertRGBToLMS(0.545877*(double) QuantumRange,0.966567*(double) |
| 304 |
QuantumRange,0.463759*(double) QuantumRange,&L,&M,&S); |
| 305 |
if ((fabs(L-0.611749) >= ReferenceEpsilon) || |
| 306 |
(fabs(M-0.910088) >= ReferenceEpsilon) || |
| 307 |
(fabs(S-0.294880) >= ReferenceEpsilon)) |
| 308 |
return(MagickFalse); |
| 309 |
return(MagickTrue); |
| 310 |
} |
| 311 |
|
| 312 |
static MagickBooleanType ValidateLMSToRGB() |
| 313 |
{ |
| 314 |
double |
| 315 |
r, |
| 316 |
g, |
| 317 |
b; |
| 318 |
|
| 319 |
(void) FormatLocaleFile(stdout," LMSToRGB"); |
| 320 |
ConvertLMSToRGB(0.611749,0.910088,0.294880,&r,&g,&b); |
| 321 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 322 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 323 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 324 |
return(MagickFalse); |
| 325 |
return(MagickTrue); |
| 326 |
} |
| 327 |
|
| 328 |
static MagickBooleanType ValidateRGBToLuv() |
| 329 |
{ |
| 330 |
double |
| 331 |
l, |
| 332 |
u, |
| 333 |
v; |
| 334 |
|
| 335 |
(void) FormatLocaleFile(stdout," RGBToLuv"); |
| 336 |
ConvertRGBToLuv(0.545877*(double) QuantumRange,0.966567*(double) |
| 337 |
QuantumRange,0.463759*(double) QuantumRange,D65Illuminant,&l,&u,&v); |
| 338 |
if ((fabs(l-88.456154/262.0) >= ReferenceEpsilon) || |
| 339 |
(fabs(u-(-51.330414+134.0)/354.0) >= ReferenceEpsilon) || |
| 340 |
(fabs(v-(76.405526+140.0)/262.0) >= ReferenceEpsilon)) |
| 341 |
return(MagickFalse); |
| 342 |
return(MagickTrue); |
| 343 |
} |
| 344 |
|
| 345 |
static MagickBooleanType ValidateLuvToRGB() |
| 346 |
{ |
| 347 |
double |
| 348 |
r, |
| 349 |
g, |
| 350 |
b; |
| 351 |
|
| 352 |
(void) FormatLocaleFile(stdout," LuvToRGB"); |
| 353 |
ConvertLuvToRGB(88.456154/100.0,(-51.330414+134.0)/354.0, |
| 354 |
(76.405526+140.0)/262.0,D65Illuminant,&r,&g,&b); |
| 355 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 356 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 357 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 358 |
return(MagickFalse); |
| 359 |
return(MagickTrue); |
| 360 |
} |
| 361 |
|
| 362 |
static MagickBooleanType ValidateRGBToXYZ() |
| 363 |
{ |
| 364 |
double |
| 365 |
x, |
| 366 |
y, |
| 367 |
z; |
| 368 |
|
| 369 |
(void) FormatLocaleFile(stdout," RGBToXYZ"); |
| 370 |
ConvertRGBToXYZ(0.545877*(double) QuantumRange,0.966567*(double) |
| 371 |
QuantumRange,0.463759*(double) QuantumRange,&x,&y,&z); |
| 372 |
if ((fabs(x-0.470646) >= ReferenceEpsilon) || |
| 373 |
(fabs(y-0.730178) >= ReferenceEpsilon) || |
| 374 |
(fabs(z-0.288324) >= ReferenceEpsilon)) |
| 375 |
return(MagickFalse); |
| 376 |
return(MagickTrue); |
| 377 |
} |
| 378 |
|
| 379 |
static MagickBooleanType ValidateXYZToRGB() |
| 380 |
{ |
| 381 |
double |
| 382 |
r, |
| 383 |
g, |
| 384 |
b; |
| 385 |
|
| 386 |
(void) FormatLocaleFile(stdout," XYZToRGB"); |
| 387 |
ConvertXYZToRGB(0.470646,0.730178,0.288324,&r,&g,&b); |
| 388 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 389 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 390 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 391 |
return(MagickFalse); |
| 392 |
return(MagickTrue); |
| 393 |
} |
| 394 |
|
| 395 |
static MagickBooleanType ValidateYDbDrToRGB() |
| 396 |
{ |
| 397 |
double |
| 398 |
r, |
| 399 |
g, |
| 400 |
b; |
| 401 |
|
| 402 |
(void) FormatLocaleFile(stdout," YDbDrToRGB"); |
| 403 |
ConvertYDbDrToRGB(0.783460,-0.480932+0.5,0.451670+0.5,&r,&g,&b); |
| 404 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 405 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 406 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 407 |
return(MagickFalse); |
| 408 |
return(MagickTrue); |
| 409 |
} |
| 410 |
|
| 411 |
static MagickBooleanType ValidateRGBToYDbDr() |
| 412 |
{ |
| 413 |
double |
| 414 |
Db, |
| 415 |
Dr, |
| 416 |
Y; |
| 417 |
|
| 418 |
(void) FormatLocaleFile(stdout," RGBToYDbDr"); |
| 419 |
ConvertRGBToYDbDr(0.545877*(double) QuantumRange,0.966567*(double) |
| 420 |
QuantumRange,0.463759*(double) QuantumRange,&Y,&Db,&Dr); |
| 421 |
if ((fabs(Y-0.783460) >= ReferenceEpsilon) || |
| 422 |
(fabs(Db-(-0.480932)) >= ReferenceEpsilon) || |
| 423 |
(fabs(Dr-0.451670) >= ReferenceEpsilon)) |
| 424 |
return(MagickFalse); |
| 425 |
return(MagickTrue); |
| 426 |
} |
| 427 |
|
| 428 |
static MagickBooleanType ValidateRGBToYIQ() |
| 429 |
{ |
| 430 |
double |
| 431 |
i, |
| 432 |
q, |
| 433 |
y; |
| 434 |
|
| 435 |
(void) FormatLocaleFile(stdout," RGBToYIQ"); |
| 436 |
ConvertRGBToYIQ(0.545877*(double) QuantumRange,0.966567*(double) |
| 437 |
QuantumRange,0.463759*(double) QuantumRange,&y,&i,&q); |
| 438 |
if ((fabs(y-0.783460) >= ReferenceEpsilon) || |
| 439 |
(fabs(i-(-0.089078)) >= ReferenceEpsilon) || |
| 440 |
(fabs(q-(-0.245399)) >= ReferenceEpsilon)) |
| 441 |
return(MagickFalse); |
| 442 |
return(MagickTrue); |
| 443 |
} |
| 444 |
|
| 445 |
static MagickBooleanType ValidateYIQToRGB() |
| 446 |
{ |
| 447 |
double |
| 448 |
r, |
| 449 |
g, |
| 450 |
b; |
| 451 |
|
| 452 |
(void) FormatLocaleFile(stdout," YIQToRGB"); |
| 453 |
ConvertYIQToRGB(0.783460,-0.089078+0.5,-0.245399+0.5,&r,&g,&b); |
| 454 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 455 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 456 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 457 |
return(MagickFalse); |
| 458 |
return(MagickTrue); |
| 459 |
} |
| 460 |
|
| 461 |
static MagickBooleanType ValidateRGBToYPbPr() |
| 462 |
{ |
| 463 |
double |
| 464 |
Pb, |
| 465 |
Pr, |
| 466 |
y; |
| 467 |
|
| 468 |
(void) FormatLocaleFile(stdout," RGBToYPbPr"); |
| 469 |
ConvertRGBToYPbPr(0.545877*(double) QuantumRange,0.966567*(double) |
| 470 |
QuantumRange,0.463759*(double) QuantumRange,&y,&Pb,&Pr); |
| 471 |
if ((fabs(y-0.783460) >= ReferenceEpsilon) || |
| 472 |
(fabs(Pb-(-0.180419)) >= ReferenceEpsilon) || |
| 473 |
(fabs(Pr-(-0.169461)) >= ReferenceEpsilon)) |
| 474 |
return(MagickFalse); |
| 475 |
return(MagickTrue); |
| 476 |
} |
| 477 |
|
| 478 |
static MagickBooleanType ValidateYPbPrToRGB() |
| 479 |
{ |
| 480 |
double |
| 481 |
r, |
| 482 |
g, |
| 483 |
b; |
| 484 |
|
| 485 |
(void) FormatLocaleFile(stdout," YPbPrToRGB"); |
| 486 |
ConvertYPbPrToRGB(0.783460,-0.180419+0.5,-0.169461+0.5,&r,&g,&b); |
| 487 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 488 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 489 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 490 |
return(MagickFalse); |
| 491 |
return(MagickTrue); |
| 492 |
} |
| 493 |
|
| 494 |
static MagickBooleanType ValidateRGBToYUV() |
| 495 |
{ |
| 496 |
double |
| 497 |
U, |
| 498 |
V, |
| 499 |
Y; |
| 500 |
|
| 501 |
(void) FormatLocaleFile(stdout," RGBToYUV"); |
| 502 |
ConvertRGBToYUV(0.545877*(double) QuantumRange,0.966567*(double) |
| 503 |
QuantumRange,0.463759*(double) QuantumRange,&Y,&U,&V); |
| 504 |
if ((fabs(Y-0.783460) >= ReferenceEpsilon) || |
| 505 |
(fabs(U-(-0.157383)) >= ReferenceEpsilon) || |
| 506 |
(fabs(V-(-0.208443)) >= ReferenceEpsilon)) |
| 507 |
return(MagickFalse); |
| 508 |
return(MagickTrue); |
| 509 |
} |
| 510 |
|
| 511 |
static MagickBooleanType ValidateYUVToRGB() |
| 512 |
{ |
| 513 |
double |
| 514 |
r, |
| 515 |
g, |
| 516 |
b; |
| 517 |
|
| 518 |
(void) FormatLocaleFile(stdout," YUVToRGB"); |
| 519 |
ConvertYUVToRGB(0.783460,-0.157383+0.5,-0.208443+0.5,&r,&g,&b); |
| 520 |
if ((fabs((double) r-0.545877*(double) QuantumRange) >= ReferenceEpsilon) || |
| 521 |
(fabs((double) g-0.966567*(double) QuantumRange) >= ReferenceEpsilon) || |
| 522 |
(fabs((double) b-0.463759*(double) QuantumRange) >= ReferenceEpsilon)) |
| 523 |
return(MagickFalse); |
| 524 |
return(MagickTrue); |
| 525 |
} |
| 526 |
|
| 527 |
static size_t ValidateColorspaces(size_t *fails,ExceptionInfo *exception) |
| 528 |
{ |
| 529 |
MagickBooleanType |
| 530 |
status; |
| 531 |
|
| 532 |
size_t |
| 533 |
fail, |
| 534 |
test; |
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
) |
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
(void) FormatLocaleFile(stdout,"validate colorspaces:\n"); |
| 559 |
fail=0; |
| 560 |
for (test=0; test < 26; test++) |
| 561 |
{ |
| 562 |
CatchException(exception); |
| 563 |
(void) FormatLocaleFile(stdout," test %.20g: ",(double) test); |
| 564 |
switch (test) |
| 565 |
{ |
| 566 |
case 0: status=ValidateHSIToRGB(); break; |
| 567 |
case 1: status=ValidateRGBToHSI(); break; |
| 568 |
case 2: status=ValidateHSLToRGB(); break; |
| 569 |
case 3: status=ValidateRGBToHSL(); break; |
| 570 |
case 4: status=ValidateHSVToRGB(); break; |
| 571 |
case 5: status=ValidateRGBToHSV(); break; |
| 572 |
case 6: status=ValidateJPEGYCbCrToRGB(); break; |
| 573 |
case 7: status=ValidateRGBToJPEGYCbCr(); break; |
| 574 |
case 8: status=ValidateLabToRGB(); break; |
| 575 |
case 9: status=ValidateRGBToLab(); break; |
| 576 |
case 10: status=ValidateLchToRGB(); break; |
| 577 |
case 11: status=ValidateRGBToLch(); break; |
| 578 |
case 12: status=ValidateLMSToRGB(); break; |
| 579 |
case 13: status=ValidateRGBToLMS(); break; |
| 580 |
case 14: status=ValidateLuvToRGB(); break; |
| 581 |
case 15: status=ValidateRGBToLuv(); break; |
| 582 |
case 16: status=ValidateXYZToRGB(); break; |
| 583 |
case 17: status=ValidateRGBToXYZ(); break; |
| 584 |
case 18: status=ValidateYDbDrToRGB(); break; |
| 585 |
case 19: status=ValidateRGBToYDbDr(); break; |
| 586 |
case 20: status=ValidateYIQToRGB(); break; |
| 587 |
case 21: status=ValidateRGBToYIQ(); break; |
| 588 |
case 22: status=ValidateYPbPrToRGB(); break; |
| 589 |
case 23: status=ValidateRGBToYPbPr(); break; |
| 590 |
case 24: status=ValidateYUVToRGB(); break; |
| 591 |
case 25: status=ValidateRGBToYUV(); break; |
| 592 |
default: status=MagickFalse; |
| 593 |
} |
| 594 |
if (status == MagickFalse) |
| 595 |
{ |
| 596 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 597 |
GetMagickModule()); |
| 598 |
fail++; |
| 599 |
continue; |
| 600 |
} |
| 601 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 602 |
} |
| 603 |
(void) FormatLocaleFile(stdout, |
| 604 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 605 |
(double) (test-fail),(double) fail); |
| 606 |
*fails+=fail; |
| 607 |
return(test); |
| 608 |
} |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
static size_t ValidateCompareCommand(ImageInfo *image_info, |
| 644 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 645 |
ExceptionInfo *exception) |
| 646 |
{ |
| 647 |
char |
| 648 |
**arguments, |
| 649 |
command[MagickPathExtent]; |
| 650 |
|
| 651 |
int |
| 652 |
number_arguments; |
| 653 |
|
| 654 |
MagickBooleanType |
| 655 |
status; |
| 656 |
|
| 657 |
ssize_t |
| 658 |
i, |
| 659 |
j; |
| 660 |
|
| 661 |
size_t |
| 662 |
fail, |
| 663 |
test; |
| 664 |
|
| 665 |
fail=0; |
| 666 |
test=0; |
| 667 |
(void) FormatLocaleFile(stdout,"validate compare command line program:\n"); |
| 668 |
for (i=0; compare_options[i] != (char *) NULL; i++) |
| 669 |
{ |
| 670 |
CatchException(exception); |
| 671 |
(void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++), |
| 672 |
compare_options[i]); |
| 673 |
(void) FormatLocaleString(command,MagickPathExtent,"%s %s %s %s", |
| 674 |
compare_options[i],reference_filename,reference_filename,output_filename); |
| 675 |
arguments=StringToArgv(command,&number_arguments); |
| 676 |
if (arguments == (char **) NULL) |
| 677 |
{ |
| 678 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 679 |
GetMagickModule()); |
| 680 |
(void) LogMagickEvent(ExceptionEvent,GetMagickModule(),"%s", |
| 681 |
exception->reason); |
| 682 |
fail++; |
| 683 |
continue; |
| 684 |
} |
| 685 |
status=CompareImagesCommand(image_info,number_arguments,arguments, |
| 686 |
(char **) NULL,exception); |
| 687 |
for (j=0; j < (ssize_t) number_arguments; j++) |
| 688 |
arguments[j]=DestroyString(arguments[j]); |
| 689 |
arguments=(char **) RelinquishMagickMemory(arguments); |
| 690 |
if (status == MagickFalse) |
| 691 |
{ |
| 692 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 693 |
GetMagickModule()); |
| 694 |
(void) LogMagickEvent(ExceptionEvent,GetMagickModule(),"%s", |
| 695 |
exception->reason); |
| 696 |
fail++; |
| 697 |
continue; |
| 698 |
} |
| 699 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 700 |
} |
| 701 |
(void) FormatLocaleFile(stdout, |
| 702 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 703 |
(double) (test-fail),(double) fail); |
| 704 |
*fails+=fail; |
| 705 |
return(test); |
| 706 |
} |
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
static size_t ValidateCompositeCommand(ImageInfo *image_info, |
| 742 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 743 |
ExceptionInfo *exception) |
| 744 |
{ |
| 745 |
char |
| 746 |
**arguments, |
| 747 |
command[MagickPathExtent]; |
| 748 |
|
| 749 |
int |
| 750 |
number_arguments; |
| 751 |
|
| 752 |
MagickBooleanType |
| 753 |
status; |
| 754 |
|
| 755 |
ssize_t |
| 756 |
i, |
| 757 |
j; |
| 758 |
|
| 759 |
size_t |
| 760 |
fail, |
| 761 |
test; |
| 762 |
|
| 763 |
fail=0; |
| 764 |
test=0; |
| 765 |
(void) FormatLocaleFile(stdout,"validate composite command line program:\n"); |
| 766 |
for (i=0; composite_options[i] != (char *) NULL; i++) |
| 767 |
{ |
| 768 |
CatchException(exception); |
| 769 |
(void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++), |
| 770 |
composite_options[i]); |
| 771 |
(void) FormatLocaleString(command,MagickPathExtent,"%s %s %s %s", |
| 772 |
reference_filename,composite_options[i],reference_filename, |
| 773 |
output_filename); |
| 774 |
arguments=StringToArgv(command,&number_arguments); |
| 775 |
if (arguments == (char **) NULL) |
| 776 |
{ |
| 777 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 778 |
GetMagickModule()); |
| 779 |
fail++; |
| 780 |
continue; |
| 781 |
} |
| 782 |
status=CompositeImageCommand(image_info,number_arguments,arguments, |
| 783 |
(char **) NULL,exception); |
| 784 |
for (j=0; j < (ssize_t) number_arguments; j++) |
| 785 |
arguments[j]=DestroyString(arguments[j]); |
| 786 |
arguments=(char **) RelinquishMagickMemory(arguments); |
| 787 |
if (status == MagickFalse) |
| 788 |
{ |
| 789 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 790 |
GetMagickModule()); |
| 791 |
fail++; |
| 792 |
continue; |
| 793 |
} |
| 794 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 795 |
} |
| 796 |
(void) FormatLocaleFile(stdout, |
| 797 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 798 |
(double) (test-fail),(double) fail); |
| 799 |
*fails+=fail; |
| 800 |
return(test); |
| 801 |
} |
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
static size_t ValidateConvertCommand(ImageInfo *image_info, |
| 837 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 838 |
ExceptionInfo *exception) |
| 839 |
{ |
| 840 |
char |
| 841 |
**arguments, |
| 842 |
command[MagickPathExtent]; |
| 843 |
|
| 844 |
int |
| 845 |
number_arguments; |
| 846 |
|
| 847 |
MagickBooleanType |
| 848 |
status; |
| 849 |
|
| 850 |
ssize_t |
| 851 |
i, |
| 852 |
j; |
| 853 |
|
| 854 |
size_t |
| 855 |
fail, |
| 856 |
test; |
| 857 |
|
| 858 |
fail=0; |
| 859 |
test=0; |
| 860 |
(void) FormatLocaleFile(stdout,"validate convert command line program:\n"); |
| 861 |
for (i=0; convert_options[i] != (char *) NULL; i++) |
| 862 |
{ |
| 863 |
CatchException(exception); |
| 864 |
(void) FormatLocaleFile(stdout," test %.20g: %s",(double) test++, |
| 865 |
convert_options[i]); |
| 866 |
(void) FormatLocaleString(command,MagickPathExtent,"%s %s %s %s", |
| 867 |
reference_filename,convert_options[i],reference_filename,output_filename); |
| 868 |
arguments=StringToArgv(command,&number_arguments); |
| 869 |
if (arguments == (char **) NULL) |
| 870 |
{ |
| 871 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 872 |
GetMagickModule()); |
| 873 |
fail++; |
| 874 |
continue; |
| 875 |
} |
| 876 |
status=ConvertImageCommand(image_info,number_arguments,arguments, |
| 877 |
(char **) NULL,exception); |
| 878 |
for (j=0; j < (ssize_t) number_arguments; j++) |
| 879 |
arguments[j]=DestroyString(arguments[j]); |
| 880 |
arguments=(char **) RelinquishMagickMemory(arguments); |
| 881 |
if (status == MagickFalse) |
| 882 |
{ |
| 883 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 884 |
GetMagickModule()); |
| 885 |
fail++; |
| 886 |
continue; |
| 887 |
} |
| 888 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 889 |
} |
| 890 |
(void) FormatLocaleFile(stdout, |
| 891 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 892 |
(double) (test-fail),(double) fail); |
| 893 |
*fails+=fail; |
| 894 |
return(test); |
| 895 |
} |
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
static size_t ValidateIdentifyCommand(ImageInfo *image_info, |
| 931 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 932 |
ExceptionInfo *exception) |
| 933 |
{ |
| 934 |
char |
| 935 |
**arguments, |
| 936 |
command[MagickPathExtent]; |
| 937 |
|
| 938 |
int |
| 939 |
number_arguments; |
| 940 |
|
| 941 |
MagickBooleanType |
| 942 |
status; |
| 943 |
|
| 944 |
ssize_t |
| 945 |
i, |
| 946 |
j; |
| 947 |
|
| 948 |
size_t |
| 949 |
fail, |
| 950 |
test; |
| 951 |
|
| 952 |
(void) output_filename; |
| 953 |
fail=0; |
| 954 |
test=0; |
| 955 |
(void) FormatLocaleFile(stdout,"validate identify command line program:\n"); |
| 956 |
for (i=0; identify_options[i] != (char *) NULL; i++) |
| 957 |
{ |
| 958 |
CatchException(exception); |
| 959 |
(void) FormatLocaleFile(stdout," test %.20g: %s",(double) test++, |
| 960 |
identify_options[i]); |
| 961 |
(void) FormatLocaleString(command,MagickPathExtent,"%s %s", |
| 962 |
identify_options[i],reference_filename); |
| 963 |
arguments=StringToArgv(command,&number_arguments); |
| 964 |
if (arguments == (char **) NULL) |
| 965 |
{ |
| 966 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 967 |
GetMagickModule()); |
| 968 |
fail++; |
| 969 |
continue; |
| 970 |
} |
| 971 |
status=IdentifyImageCommand(image_info,number_arguments,arguments, |
| 972 |
(char **) NULL,exception); |
| 973 |
for (j=0; j < (ssize_t) number_arguments; j++) |
| 974 |
arguments[j]=DestroyString(arguments[j]); |
| 975 |
arguments=(char **) RelinquishMagickMemory(arguments); |
| 976 |
if (status == MagickFalse) |
| 977 |
{ |
| 978 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 979 |
GetMagickModule()); |
| 980 |
fail++; |
| 981 |
continue; |
| 982 |
} |
| 983 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 984 |
} |
| 985 |
(void) FormatLocaleFile(stdout, |
| 986 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 987 |
(double) (test-fail),(double) fail); |
| 988 |
*fails+=fail; |
| 989 |
return(test); |
| 990 |
} |
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
#undef MagickCountTempFiles |
| 1031 |
|
| 1032 |
static size_t ValidateImageFormatsInMemory(ImageInfo *image_info, |
| 1033 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 1034 |
ExceptionInfo *exception) |
| 1035 |
{ |
| 1036 |
char |
| 1037 |
#ifdef MagickCountTempFiles |
| 1038 |
path[MagickPathExtent], |
| 1039 |
SystemCommand[MagickPathExtent], |
| 1040 |
#endif |
| 1041 |
size[MagickPathExtent]; |
| 1042 |
|
| 1043 |
const MagickInfo |
| 1044 |
*magick_info; |
| 1045 |
|
| 1046 |
double |
| 1047 |
distortion, |
| 1048 |
fuzz; |
| 1049 |
|
| 1050 |
Image |
| 1051 |
*difference_image, |
| 1052 |
*ping_image, |
| 1053 |
*reconstruct_image, |
| 1054 |
*reference_image; |
| 1055 |
|
| 1056 |
MagickBooleanType |
| 1057 |
status; |
| 1058 |
|
| 1059 |
ssize_t |
| 1060 |
i, |
| 1061 |
j; |
| 1062 |
|
| 1063 |
size_t |
| 1064 |
fail, |
| 1065 |
length, |
| 1066 |
test; |
| 1067 |
|
| 1068 |
unsigned char |
| 1069 |
*blob; |
| 1070 |
|
| 1071 |
fail=0; |
| 1072 |
test=0; |
| 1073 |
(void) FormatLocaleFile(stdout,"validate image formats in memory:\n"); |
| 1074 |
|
| 1075 |
#ifdef MagickCountTempFiles |
| 1076 |
(void)GetPathTemplate(path); |
| 1077 |
|
| 1078 |
path[strlen(path)-17]='\0'; |
| 1079 |
(void) FormatLocaleFile(stdout," tmp path is '%s*'\n",path); |
| 1080 |
#endif |
| 1081 |
|
| 1082 |
for (i=0; reference_formats[i].magick != (char *) NULL; i++) |
| 1083 |
{ |
| 1084 |
magick_info=GetMagickInfo(reference_formats[i].magick,exception); |
| 1085 |
if ((magick_info == (const MagickInfo *) NULL) || |
| 1086 |
(magick_info->decoder == (DecodeImageHandler *) NULL) || |
| 1087 |
(magick_info->encoder == (EncodeImageHandler *) NULL)) |
| 1088 |
continue; |
| 1089 |
for (j=0; reference_types[j].type != UndefinedType; j++) |
| 1090 |
{ |
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
CatchException(exception); |
| 1095 |
(void) FormatLocaleFile(stdout," test %.20g: %s/%s/%s/%.20g-bits", |
| 1096 |
(double) (test++),reference_formats[i].magick,CommandOptionToMnemonic( |
| 1097 |
MagickCompressOptions,reference_formats[i].compression), |
| 1098 |
CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type), |
| 1099 |
(double) reference_types[j].depth); |
| 1100 |
(void) CopyMagickString(image_info->filename,reference_filename, |
| 1101 |
MagickPathExtent); |
| 1102 |
reference_image=ReadImage(image_info,exception); |
| 1103 |
if ((reference_image == (Image *) NULL) || |
| 1104 |
(exception->severity >= ErrorException)) |
| 1105 |
{ |
| 1106 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1107 |
GetMagickModule()); |
| 1108 |
if (exception->reason != (char *) NULL) |
| 1109 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1110 |
CatchException(exception); |
| 1111 |
fail++; |
| 1112 |
continue; |
| 1113 |
} |
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
(void) FormatLocaleString(size,MagickPathExtent,"%.20gx%.20g", |
| 1118 |
(double) reference_image->columns,(double) reference_image->rows); |
| 1119 |
(void) CloneString(&image_info->size,size); |
| 1120 |
image_info->depth=reference_types[j].depth; |
| 1121 |
(void) FormatLocaleString(reference_image->filename,MagickPathExtent, |
| 1122 |
"%s:%s",reference_formats[i].magick,output_filename); |
| 1123 |
status=SetImageType(reference_image,reference_types[j].type,exception); |
| 1124 |
if (status == MagickFalse || (exception->severity >= ErrorException)) |
| 1125 |
{ |
| 1126 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1127 |
GetMagickModule()); |
| 1128 |
if (exception->reason != (char *) NULL) |
| 1129 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1130 |
CatchException(exception); |
| 1131 |
fail++; |
| 1132 |
reference_image=DestroyImage(reference_image); |
| 1133 |
continue; |
| 1134 |
} |
| 1135 |
status=SetImageDepth(reference_image,reference_types[j].depth,exception); |
| 1136 |
if (status == MagickFalse || (exception->severity >= ErrorException)) |
| 1137 |
{ |
| 1138 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1139 |
GetMagickModule()); |
| 1140 |
CatchException(exception); |
| 1141 |
fail++; |
| 1142 |
reference_image=DestroyImage(reference_image); |
| 1143 |
continue; |
| 1144 |
} |
| 1145 |
reference_image->compression=reference_formats[i].compression; |
| 1146 |
status=WriteImage(image_info,reference_image,exception); |
| 1147 |
reference_image=DestroyImage(reference_image); |
| 1148 |
if (status == MagickFalse || (exception->severity >= ErrorException)) |
| 1149 |
{ |
| 1150 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1151 |
GetMagickModule()); |
| 1152 |
if (exception->reason != (char *) NULL) |
| 1153 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1154 |
CatchException(exception); |
| 1155 |
fail++; |
| 1156 |
continue; |
| 1157 |
} |
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
(void) FormatLocaleString(image_info->filename,MagickPathExtent,"%s:%s", |
| 1162 |
reference_formats[i].magick,output_filename); |
| 1163 |
ping_image=PingImage(image_info,exception); |
| 1164 |
if (ping_image == (Image *) NULL || |
| 1165 |
(exception->severity >= ErrorException)) |
| 1166 |
{ |
| 1167 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1168 |
GetMagickModule()); |
| 1169 |
if (exception->reason != (char *) NULL) |
| 1170 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1171 |
CatchException(exception); |
| 1172 |
fail++; |
| 1173 |
continue; |
| 1174 |
} |
| 1175 |
ping_image=DestroyImage(ping_image); |
| 1176 |
|
| 1177 |
|
| 1178 |
|
| 1179 |
reference_image=ReadImage(image_info,exception); |
| 1180 |
if ((reference_image == (Image *) NULL) || |
| 1181 |
(exception->severity >= ErrorException)) |
| 1182 |
{ |
| 1183 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1184 |
GetMagickModule()); |
| 1185 |
if (exception->reason != (char *) NULL) |
| 1186 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1187 |
CatchException(exception); |
| 1188 |
fail++; |
| 1189 |
continue; |
| 1190 |
} |
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
(void) FormatLocaleString(reference_image->filename,MagickPathExtent, |
| 1195 |
"%s:%s",reference_formats[i].magick,output_filename); |
| 1196 |
(void) CopyMagickString(image_info->magick,reference_formats[i].magick, |
| 1197 |
MagickPathExtent); |
| 1198 |
reference_image->depth=reference_types[j].depth; |
| 1199 |
reference_image->compression=reference_formats[i].compression; |
| 1200 |
length=8192; |
| 1201 |
blob=(unsigned char *) ImageToBlob(image_info,reference_image,&length, |
| 1202 |
exception); |
| 1203 |
if ((blob == (unsigned char *) NULL) || |
| 1204 |
(exception->severity >= ErrorException)) |
| 1205 |
{ |
| 1206 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1207 |
GetMagickModule()); |
| 1208 |
if (exception->reason != (char *) NULL) |
| 1209 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1210 |
CatchException(exception); |
| 1211 |
fail++; |
| 1212 |
reference_image=DestroyImage(reference_image); |
| 1213 |
continue; |
| 1214 |
} |
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
ping_image=PingBlob(image_info,blob,length,exception); |
| 1219 |
if (ping_image == (Image *) NULL || |
| 1220 |
(exception->severity >= ErrorException)) |
| 1221 |
{ |
| 1222 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1223 |
GetMagickModule()); |
| 1224 |
if (exception->reason != (char *) NULL) |
| 1225 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1226 |
CatchException(exception); |
| 1227 |
fail++; |
| 1228 |
blob=(unsigned char *) RelinquishMagickMemory(blob); |
| 1229 |
continue; |
| 1230 |
} |
| 1231 |
ping_image=DestroyImage(ping_image); |
| 1232 |
|
| 1233 |
|
| 1234 |
|
| 1235 |
(void) FormatLocaleString(image_info->filename,MagickPathExtent,"%s:%s", |
| 1236 |
reference_formats[i].magick,output_filename); |
| 1237 |
reconstruct_image=BlobToImage(image_info,blob,length,exception); |
| 1238 |
blob=(unsigned char *) RelinquishMagickMemory(blob); |
| 1239 |
if (reconstruct_image == (Image *) NULL || |
| 1240 |
(exception->severity >= ErrorException)) |
| 1241 |
{ |
| 1242 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1243 |
GetMagickModule()); |
| 1244 |
if (exception->reason != (char *) NULL) |
| 1245 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1246 |
CatchException(exception); |
| 1247 |
fail++; |
| 1248 |
reference_image=DestroyImage(reference_image); |
| 1249 |
continue; |
| 1250 |
} |
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
fuzz=0.003; |
| 1255 |
if (reference_formats[i].fuzz != 0.0) |
| 1256 |
fuzz=reference_formats[i].fuzz; |
| 1257 |
difference_image=CompareImages(reference_image,reconstruct_image, |
| 1258 |
RootMeanSquaredErrorMetric,&distortion,exception); |
| 1259 |
reconstruct_image=DestroyImage(reconstruct_image); |
| 1260 |
reference_image=DestroyImage(reference_image); |
| 1261 |
if ((difference_image == (Image *) NULL) || |
| 1262 |
(exception->severity >= ErrorException)) |
| 1263 |
{ |
| 1264 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1265 |
GetMagickModule()); |
| 1266 |
if (exception->reason != (char *) NULL) |
| 1267 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1268 |
CatchException(exception); |
| 1269 |
fail++; |
| 1270 |
continue; |
| 1271 |
} |
| 1272 |
difference_image=DestroyImage(difference_image); |
| 1273 |
if (MagickSafeSignificantError(QuantumScale*distortion,fuzz) != MagickFalse) |
| 1274 |
{ |
| 1275 |
(void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n", |
| 1276 |
QuantumScale*distortion); |
| 1277 |
fail++; |
| 1278 |
continue; |
| 1279 |
} |
| 1280 |
#ifdef MagickCountTempFiles |
| 1281 |
(void) FormatLocaleFile(stdout,"... pass, "); |
| 1282 |
(void) fflush(stdout); |
| 1283 |
SystemCommand[0]='\0'; |
| 1284 |
(void) strncat(SystemCommand,"echo `ls ",9); |
| 1285 |
(void) strncat(SystemCommand,path,MagickPathExtent-31); |
| 1286 |
(void) strncat(SystemCommand,"* | wc -w` tmp files.",20); |
| 1287 |
(void) system(SystemCommand); |
| 1288 |
(void) fflush(stdout); |
| 1289 |
#else |
| 1290 |
(void) FormatLocaleFile(stdout,"... pass\n"); |
| 1291 |
#endif |
| 1292 |
} |
| 1293 |
} |
| 1294 |
(void) FormatLocaleFile(stdout, |
| 1295 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1296 |
(double) (test-fail),(double) fail); |
| 1297 |
*fails+=fail; |
| 1298 |
return(test); |
| 1299 |
} |
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info, |
| 1335 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 1336 |
ExceptionInfo *exception) |
| 1337 |
{ |
| 1338 |
char |
| 1339 |
size[MagickPathExtent]; |
| 1340 |
|
| 1341 |
const MagickInfo |
| 1342 |
*magick_info; |
| 1343 |
|
| 1344 |
double |
| 1345 |
distortion, |
| 1346 |
fuzz; |
| 1347 |
|
| 1348 |
Image |
| 1349 |
*difference_image, |
| 1350 |
*reference_image, |
| 1351 |
*reconstruct_image; |
| 1352 |
|
| 1353 |
MagickBooleanType |
| 1354 |
status; |
| 1355 |
|
| 1356 |
ssize_t |
| 1357 |
i, |
| 1358 |
j; |
| 1359 |
|
| 1360 |
size_t |
| 1361 |
fail, |
| 1362 |
test; |
| 1363 |
|
| 1364 |
fail=0; |
| 1365 |
test=0; |
| 1366 |
(void) FormatLocaleFile(stdout,"validate image formats on disk:\n"); |
| 1367 |
for (i=0; reference_formats[i].magick != (char *) NULL; i++) |
| 1368 |
{ |
| 1369 |
magick_info=GetMagickInfo(reference_formats[i].magick,exception); |
| 1370 |
if ((magick_info == (const MagickInfo *) NULL) || |
| 1371 |
(magick_info->decoder == (DecodeImageHandler *) NULL) || |
| 1372 |
(magick_info->encoder == (EncodeImageHandler *) NULL)) |
| 1373 |
continue; |
| 1374 |
for (j=0; reference_types[j].type != UndefinedType; j++) |
| 1375 |
{ |
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
CatchException(exception); |
| 1380 |
(void) FormatLocaleFile(stdout," test %.20g: %s/%s/%s/%.20g-bits", |
| 1381 |
(double) (test++),reference_formats[i].magick,CommandOptionToMnemonic( |
| 1382 |
MagickCompressOptions,reference_formats[i].compression), |
| 1383 |
CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type), |
| 1384 |
(double) reference_types[j].depth); |
| 1385 |
(void) CopyMagickString(image_info->filename,reference_filename, |
| 1386 |
MagickPathExtent); |
| 1387 |
reference_image=ReadImage(image_info,exception); |
| 1388 |
if ((reference_image == (Image *) NULL) || |
| 1389 |
(exception->severity >= ErrorException)) |
| 1390 |
{ |
| 1391 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1392 |
GetMagickModule()); |
| 1393 |
if (exception->reason != (char *) NULL) |
| 1394 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1395 |
CatchException(exception); |
| 1396 |
fail++; |
| 1397 |
continue; |
| 1398 |
} |
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
(void) FormatLocaleString(size,MagickPathExtent,"%.20gx%.20g", |
| 1403 |
(double) reference_image->columns,(double) reference_image->rows); |
| 1404 |
(void) CloneString(&image_info->size,size); |
| 1405 |
image_info->depth=reference_types[j].depth; |
| 1406 |
(void) FormatLocaleString(reference_image->filename,MagickPathExtent, |
| 1407 |
"%s:%s",reference_formats[i].magick,output_filename); |
| 1408 |
status=SetImageType(reference_image,reference_types[j].type,exception); |
| 1409 |
if (status == MagickFalse || (exception->severity >= ErrorException)) |
| 1410 |
{ |
| 1411 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1412 |
GetMagickModule()); |
| 1413 |
if (exception->reason != (char *) NULL) |
| 1414 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1415 |
CatchException(exception); |
| 1416 |
fail++; |
| 1417 |
reference_image=DestroyImage(reference_image); |
| 1418 |
continue; |
| 1419 |
} |
| 1420 |
status=SetImageDepth(reference_image,reference_types[j].depth,exception); |
| 1421 |
if (status == MagickFalse || (exception->severity >= ErrorException)) |
| 1422 |
{ |
| 1423 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1424 |
GetMagickModule()); |
| 1425 |
CatchException(exception); |
| 1426 |
fail++; |
| 1427 |
reference_image=DestroyImage(reference_image); |
| 1428 |
continue; |
| 1429 |
} |
| 1430 |
reference_image->compression=reference_formats[i].compression; |
| 1431 |
status=WriteImage(image_info,reference_image,exception); |
| 1432 |
reference_image=DestroyImage(reference_image); |
| 1433 |
if (status == MagickFalse || (exception->severity >= ErrorException)) |
| 1434 |
{ |
| 1435 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1436 |
GetMagickModule()); |
| 1437 |
if (exception->reason != (char *) NULL) |
| 1438 |
(void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
| 1439 |
CatchException(exception); |
| 1440 |
fail++; |
| 1441 |
continue; |
| 1442 |
} |
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
(void) FormatLocaleString(image_info->filename,MagickPathExtent,"%s:%s", |
| 1447 |
reference_formats[i].magick,output_filename); |
| 1448 |
reference_image=ReadImage(image_info,exception); |
| 1449 |
if ((reference_image == (Image *) NULL) || |
| 1450 |
(exception->severity >= ErrorException)) |
| 1451 |
{ |
| 1452 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1453 |
GetMagickModule()); |
| 1454 |
CatchException(exception); |
| 1455 |
fail++; |
| 1456 |
continue; |
| 1457 |
} |
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
(void) FormatLocaleString(reference_image->filename,MagickPathExtent, |
| 1462 |
"%s:%s",reference_formats[i].magick,output_filename); |
| 1463 |
reference_image->depth=reference_types[j].depth; |
| 1464 |
reference_image->compression=reference_formats[i].compression; |
| 1465 |
status=WriteImage(image_info,reference_image,exception); |
| 1466 |
if (status == MagickFalse ||exception->severity >= ErrorException) |
| 1467 |
{ |
| 1468 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1469 |
GetMagickModule()); |
| 1470 |
CatchException(exception); |
| 1471 |
fail++; |
| 1472 |
reference_image=DestroyImage(reference_image); |
| 1473 |
continue; |
| 1474 |
} |
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
(void) FormatLocaleString(image_info->filename,MagickPathExtent,"%s:%s", |
| 1479 |
reference_formats[i].magick,output_filename); |
| 1480 |
reconstruct_image=ReadImage(image_info,exception); |
| 1481 |
if (reconstruct_image == (Image *) NULL || |
| 1482 |
(exception->severity >= ErrorException)) |
| 1483 |
{ |
| 1484 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1485 |
GetMagickModule()); |
| 1486 |
CatchException(exception); |
| 1487 |
fail++; |
| 1488 |
reference_image=DestroyImage(reference_image); |
| 1489 |
continue; |
| 1490 |
} |
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
fuzz=0.003; |
| 1495 |
if (reference_formats[i].fuzz != 0.0) |
| 1496 |
fuzz=reference_formats[i].fuzz; |
| 1497 |
difference_image=CompareImages(reference_image,reconstruct_image, |
| 1498 |
RootMeanSquaredErrorMetric,&distortion,exception); |
| 1499 |
reconstruct_image=DestroyImage(reconstruct_image); |
| 1500 |
reference_image=DestroyImage(reference_image); |
| 1501 |
if (difference_image == (Image *) NULL || |
| 1502 |
(exception->severity >= ErrorException)) |
| 1503 |
{ |
| 1504 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1505 |
GetMagickModule()); |
| 1506 |
CatchException(exception); |
| 1507 |
fail++; |
| 1508 |
continue; |
| 1509 |
} |
| 1510 |
difference_image=DestroyImage(difference_image); |
| 1511 |
if (MagickSafeSignificantError(QuantumScale*distortion,fuzz) != MagickFalse) |
| 1512 |
{ |
| 1513 |
(void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n", |
| 1514 |
QuantumScale*distortion); |
| 1515 |
fail++; |
| 1516 |
continue; |
| 1517 |
} |
| 1518 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 1519 |
} |
| 1520 |
} |
| 1521 |
(void) FormatLocaleFile(stdout, |
| 1522 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1523 |
(double) (test-fail),(double) fail); |
| 1524 |
*fails+=fail; |
| 1525 |
return(test); |
| 1526 |
} |
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
|
| 1558 |
|
| 1559 |
|
| 1560 |
|
| 1561 |
static size_t ValidateImportExportPixels(ImageInfo *image_info, |
| 1562 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 1563 |
ExceptionInfo *exception) |
| 1564 |
{ |
| 1565 |
double |
| 1566 |
distortion; |
| 1567 |
|
| 1568 |
Image |
| 1569 |
*difference_image, |
| 1570 |
*reference_image, |
| 1571 |
*reconstruct_image; |
| 1572 |
|
| 1573 |
MagickBooleanType |
| 1574 |
status; |
| 1575 |
|
| 1576 |
ssize_t |
| 1577 |
i, |
| 1578 |
j; |
| 1579 |
|
| 1580 |
size_t |
| 1581 |
length; |
| 1582 |
|
| 1583 |
unsigned char |
| 1584 |
*pixels; |
| 1585 |
|
| 1586 |
size_t |
| 1587 |
fail, |
| 1588 |
test; |
| 1589 |
|
| 1590 |
(void) output_filename; |
| 1591 |
fail=0; |
| 1592 |
test=0; |
| 1593 |
(void) FormatLocaleFile(stdout, |
| 1594 |
"validate the import and export of image pixels:\n"); |
| 1595 |
for (i=0; reference_map[i] != (char *) NULL; i++) |
| 1596 |
{ |
| 1597 |
for (j=0; reference_storage[j].type != UndefinedPixel; j++) |
| 1598 |
{ |
| 1599 |
|
| 1600 |
|
| 1601 |
|
| 1602 |
CatchException(exception); |
| 1603 |
(void) FormatLocaleFile(stdout," test %.20g: %s/%s",(double) (test++), |
| 1604 |
reference_map[i],CommandOptionToMnemonic(MagickStorageOptions, |
| 1605 |
reference_storage[j].type)); |
| 1606 |
(void) CopyMagickString(image_info->filename,reference_filename, |
| 1607 |
MagickPathExtent); |
| 1608 |
reference_image=ReadImage(image_info,exception); |
| 1609 |
if ((reference_image == (Image *) NULL) || |
| 1610 |
(exception->severity >= ErrorException)) |
| 1611 |
{ |
| 1612 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1613 |
GetMagickModule()); |
| 1614 |
CatchException(exception); |
| 1615 |
fail++; |
| 1616 |
continue; |
| 1617 |
} |
| 1618 |
if (LocaleNCompare(reference_map[i],"cmy",3) == 0) |
| 1619 |
(void) SetImageColorspace(reference_image,CMYKColorspace,exception); |
| 1620 |
length=strlen(reference_map[i])*reference_image->columns* |
| 1621 |
reference_image->rows*reference_storage[j].quantum; |
| 1622 |
pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels)); |
| 1623 |
if ((pixels == (unsigned char *) NULL) || |
| 1624 |
(exception->severity >= ErrorException)) |
| 1625 |
{ |
| 1626 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1627 |
GetMagickModule()); |
| 1628 |
CatchException(exception); |
| 1629 |
fail++; |
| 1630 |
reference_image=DestroyImage(reference_image); |
| 1631 |
continue; |
| 1632 |
} |
| 1633 |
(void) memset(pixels,0,length*sizeof(*pixels)); |
| 1634 |
status=ExportImagePixels(reference_image,0,0,reference_image->columns, |
| 1635 |
reference_image->rows,reference_map[i],reference_storage[j].type,pixels, |
| 1636 |
exception); |
| 1637 |
if (status == MagickFalse || (exception->severity >= ErrorException)) |
| 1638 |
{ |
| 1639 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1640 |
GetMagickModule()); |
| 1641 |
CatchException(exception); |
| 1642 |
fail++; |
| 1643 |
pixels=(unsigned char *) RelinquishMagickMemory(pixels); |
| 1644 |
reference_image=DestroyImage(reference_image); |
| 1645 |
continue; |
| 1646 |
} |
| 1647 |
(void) SetImageBackgroundColor(reference_image,exception); |
| 1648 |
status=ImportImagePixels(reference_image,0,0,reference_image->columns, |
| 1649 |
reference_image->rows,reference_map[i],reference_storage[j].type, |
| 1650 |
pixels,exception); |
| 1651 |
if (status == MagickFalse || (exception->severity >= ErrorException)) |
| 1652 |
{ |
| 1653 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1654 |
GetMagickModule()); |
| 1655 |
CatchException(exception); |
| 1656 |
fail++; |
| 1657 |
pixels=(unsigned char *) RelinquishMagickMemory(pixels); |
| 1658 |
reference_image=DestroyImage(reference_image); |
| 1659 |
continue; |
| 1660 |
} |
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
reconstruct_image=AcquireImage(image_info,exception); |
| 1665 |
(void) SetImageExtent(reconstruct_image,reference_image->columns, |
| 1666 |
reference_image->rows,exception); |
| 1667 |
(void) SetImageColorspace(reconstruct_image,reference_image->colorspace, |
| 1668 |
exception); |
| 1669 |
(void) SetImageBackgroundColor(reconstruct_image,exception); |
| 1670 |
status=ImportImagePixels(reconstruct_image,0,0,reconstruct_image->columns, |
| 1671 |
reconstruct_image->rows,reference_map[i],reference_storage[j].type, |
| 1672 |
pixels,exception); |
| 1673 |
pixels=(unsigned char *) RelinquishMagickMemory(pixels); |
| 1674 |
if (status == MagickFalse || (exception->severity >= ErrorException)) |
| 1675 |
{ |
| 1676 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1677 |
GetMagickModule()); |
| 1678 |
CatchException(exception); |
| 1679 |
fail++; |
| 1680 |
reference_image=DestroyImage(reference_image); |
| 1681 |
continue; |
| 1682 |
} |
| 1683 |
|
| 1684 |
|
| 1685 |
|
| 1686 |
difference_image=CompareImages(reference_image,reconstruct_image, |
| 1687 |
RootMeanSquaredErrorMetric,&distortion,exception); |
| 1688 |
reconstruct_image=DestroyImage(reconstruct_image); |
| 1689 |
reference_image=DestroyImage(reference_image); |
| 1690 |
if (difference_image == (Image *) NULL || |
| 1691 |
(exception->severity >= ErrorException)) |
| 1692 |
{ |
| 1693 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1694 |
GetMagickModule()); |
| 1695 |
CatchException(exception); |
| 1696 |
fail++; |
| 1697 |
continue; |
| 1698 |
} |
| 1699 |
difference_image=DestroyImage(difference_image); |
| 1700 |
if ((QuantumScale*distortion) > 0.0) |
| 1701 |
{ |
| 1702 |
(void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n", |
| 1703 |
QuantumScale*distortion); |
| 1704 |
fail++; |
| 1705 |
continue; |
| 1706 |
} |
| 1707 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 1708 |
} |
| 1709 |
} |
| 1710 |
(void) FormatLocaleFile(stdout, |
| 1711 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1712 |
(double) (test-fail),(double) fail); |
| 1713 |
*fails+=fail; |
| 1714 |
return(test); |
| 1715 |
} |
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
|
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
|
| 1749 |
|
| 1750 |
static size_t ValidateMagickCommand(ImageInfo *image_info, |
| 1751 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 1752 |
ExceptionInfo *exception) |
| 1753 |
{ |
| 1754 |
char |
| 1755 |
**arguments, |
| 1756 |
command[MagickPathExtent]; |
| 1757 |
|
| 1758 |
int |
| 1759 |
number_arguments; |
| 1760 |
|
| 1761 |
MagickBooleanType |
| 1762 |
status; |
| 1763 |
|
| 1764 |
ssize_t |
| 1765 |
i, |
| 1766 |
j; |
| 1767 |
|
| 1768 |
size_t |
| 1769 |
fail, |
| 1770 |
test; |
| 1771 |
|
| 1772 |
fail=0; |
| 1773 |
test=0; |
| 1774 |
(void) FormatLocaleFile(stdout,"validate magick command line program:\n"); |
| 1775 |
for (i=0; convert_options[i] != (char *) NULL; i++) |
| 1776 |
{ |
| 1777 |
CatchException(exception); |
| 1778 |
(void) FormatLocaleFile(stdout," test %.20g: %s",(double) test++, |
| 1779 |
convert_options[i]); |
| 1780 |
(void) FormatLocaleString(command,MagickPathExtent,"%s %s %s %s", |
| 1781 |
reference_filename,convert_options[i],reference_filename,output_filename); |
| 1782 |
arguments=StringToArgv(command,&number_arguments); |
| 1783 |
if (arguments == (char **) NULL) |
| 1784 |
{ |
| 1785 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1786 |
GetMagickModule()); |
| 1787 |
fail++; |
| 1788 |
continue; |
| 1789 |
} |
| 1790 |
status=MagickImageCommand(image_info,number_arguments,arguments, |
| 1791 |
(char **) NULL,exception); |
| 1792 |
for (j=0; j < (ssize_t) number_arguments; j++) |
| 1793 |
arguments[j]=DestroyString(arguments[j]); |
| 1794 |
arguments=(char **) RelinquishMagickMemory(arguments); |
| 1795 |
if (status == MagickFalse) |
| 1796 |
{ |
| 1797 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1798 |
GetMagickModule()); |
| 1799 |
fail++; |
| 1800 |
continue; |
| 1801 |
} |
| 1802 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 1803 |
} |
| 1804 |
(void) FormatLocaleFile(stdout, |
| 1805 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1806 |
(double) (test-fail),(double) fail); |
| 1807 |
*fails+=fail; |
| 1808 |
return(test); |
| 1809 |
} |
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
|
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
|
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
|
| 1831 |
|
| 1832 |
|
| 1833 |
|
| 1834 |
|
| 1835 |
|
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
|
| 1841 |
|
| 1842 |
|
| 1843 |
|
| 1844 |
static size_t ValidateMontageCommand(ImageInfo *image_info, |
| 1845 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 1846 |
ExceptionInfo *exception) |
| 1847 |
{ |
| 1848 |
char |
| 1849 |
**arguments, |
| 1850 |
command[MagickPathExtent]; |
| 1851 |
|
| 1852 |
int |
| 1853 |
number_arguments; |
| 1854 |
|
| 1855 |
MagickBooleanType |
| 1856 |
status; |
| 1857 |
|
| 1858 |
ssize_t |
| 1859 |
i, |
| 1860 |
j; |
| 1861 |
|
| 1862 |
size_t |
| 1863 |
fail, |
| 1864 |
test; |
| 1865 |
|
| 1866 |
fail=0; |
| 1867 |
test=0; |
| 1868 |
(void) FormatLocaleFile(stdout,"validate montage command line program:\n"); |
| 1869 |
for (i=0; montage_options[i] != (char *) NULL; i++) |
| 1870 |
{ |
| 1871 |
CatchException(exception); |
| 1872 |
(void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++), |
| 1873 |
montage_options[i]); |
| 1874 |
(void) FormatLocaleString(command,MagickPathExtent,"%s %s %s %s", |
| 1875 |
reference_filename,montage_options[i],reference_filename, |
| 1876 |
output_filename); |
| 1877 |
arguments=StringToArgv(command,&number_arguments); |
| 1878 |
if (arguments == (char **) NULL) |
| 1879 |
{ |
| 1880 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1881 |
GetMagickModule()); |
| 1882 |
fail++; |
| 1883 |
continue; |
| 1884 |
} |
| 1885 |
status=MontageImageCommand(image_info,number_arguments,arguments, |
| 1886 |
(char **) NULL,exception); |
| 1887 |
for (j=0; j < (ssize_t) number_arguments; j++) |
| 1888 |
arguments[j]=DestroyString(arguments[j]); |
| 1889 |
arguments=(char **) RelinquishMagickMemory(arguments); |
| 1890 |
if (status == MagickFalse) |
| 1891 |
{ |
| 1892 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1893 |
GetMagickModule()); |
| 1894 |
fail++; |
| 1895 |
continue; |
| 1896 |
} |
| 1897 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 1898 |
} |
| 1899 |
(void) FormatLocaleFile(stdout, |
| 1900 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1901 |
(double) (test-fail),(double) fail); |
| 1902 |
*fails+=fail; |
| 1903 |
return(test); |
| 1904 |
} |
| 1905 |
|
| 1906 |
|
| 1907 |
|
| 1908 |
|
| 1909 |
|
| 1910 |
|
| 1911 |
|
| 1912 |
|
| 1913 |
|
| 1914 |
|
| 1915 |
|
| 1916 |
|
| 1917 |
|
| 1918 |
|
| 1919 |
|
| 1920 |
|
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
|
| 1939 |
static size_t ValidateStreamCommand(ImageInfo *image_info, |
| 1940 |
const char *reference_filename,const char *output_filename,size_t *fails, |
| 1941 |
ExceptionInfo *exception) |
| 1942 |
{ |
| 1943 |
char |
| 1944 |
**arguments, |
| 1945 |
command[MagickPathExtent]; |
| 1946 |
|
| 1947 |
int |
| 1948 |
number_arguments; |
| 1949 |
|
| 1950 |
MagickBooleanType |
| 1951 |
status; |
| 1952 |
|
| 1953 |
ssize_t |
| 1954 |
i, |
| 1955 |
j; |
| 1956 |
|
| 1957 |
size_t |
| 1958 |
fail, |
| 1959 |
test; |
| 1960 |
|
| 1961 |
fail=0; |
| 1962 |
test=0; |
| 1963 |
(void) FormatLocaleFile(stdout,"validate stream command line program:\n"); |
| 1964 |
for (i=0; stream_options[i] != (char *) NULL; i++) |
| 1965 |
{ |
| 1966 |
CatchException(exception); |
| 1967 |
(void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++), |
| 1968 |
stream_options[i]); |
| 1969 |
(void) FormatLocaleString(command,MagickPathExtent,"%s %s %s", |
| 1970 |
stream_options[i],reference_filename,output_filename); |
| 1971 |
arguments=StringToArgv(command,&number_arguments); |
| 1972 |
if (arguments == (char **) NULL) |
| 1973 |
{ |
| 1974 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1975 |
GetMagickModule()); |
| 1976 |
fail++; |
| 1977 |
continue; |
| 1978 |
} |
| 1979 |
status=StreamImageCommand(image_info,number_arguments,arguments, |
| 1980 |
(char **) NULL,exception); |
| 1981 |
for (j=0; j < (ssize_t) number_arguments; j++) |
| 1982 |
arguments[j]=DestroyString(arguments[j]); |
| 1983 |
arguments=(char **) RelinquishMagickMemory(arguments); |
| 1984 |
if (status == MagickFalse) |
| 1985 |
{ |
| 1986 |
(void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1987 |
GetMagickModule()); |
| 1988 |
fail++; |
| 1989 |
continue; |
| 1990 |
} |
| 1991 |
(void) FormatLocaleFile(stdout,"... pass.\n"); |
| 1992 |
} |
| 1993 |
(void) FormatLocaleFile(stdout, |
| 1994 |
" summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1995 |
(double) (test-fail),(double) fail); |
| 1996 |
*fails+=fail; |
| 1997 |
return(test); |
| 1998 |
} |
| 1999 |
|
| 2000 |
|
| 2001 |
|
| 2002 |
|
| 2003 |
|
| 2004 |
|
| 2005 |
|
| 2006 |
|
| 2007 |
|
| 2008 |
|
| 2009 |
|
| 2010 |
|
| 2011 |
|
| 2012 |
|
| 2013 |
|
| 2014 |
static MagickBooleanType ValidateUsage(void) |
| 2015 |
{ |
| 2016 |
const char |
| 2017 |
**p; |
| 2018 |
|
| 2019 |
static const char |
| 2020 |
*miscellaneous[]= |
| 2021 |
{ |
| 2022 |
"-debug events display copious debugging information", |
| 2023 |
"-help print program options", |
| 2024 |
"-log format format of debugging information", |
| 2025 |
"-validate type validation type", |
| 2026 |
"-version print version information", |
| 2027 |
(char *) NULL |
| 2028 |
}, |
| 2029 |
*settings[]= |
| 2030 |
{ |
| 2031 |
"-regard-warnings pay attention to warning messages", |
| 2032 |
"-verbose print detailed information about the image", |
| 2033 |
(char *) NULL |
| 2034 |
}; |
| 2035 |
|
| 2036 |
(void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
| 2037 |
(void) printf("Copyright: %s\n\n",GetMagickCopyright()); |
| 2038 |
(void) printf("Features: %s\n",GetMagickFeatures()); |
| 2039 |
(void) printf("Usage: %s [options ...] reference-file\n",GetClientName()); |
| 2040 |
(void) printf("\nValidate Settings:\n"); |
| 2041 |
for (p=settings; *p != (char *) NULL; p++) |
| 2042 |
(void) printf(" %s\n",*p); |
| 2043 |
(void) printf("\nMiscellaneous Options:\n"); |
| 2044 |
for (p=miscellaneous; *p != (char *) NULL; p++) |
| 2045 |
(void) printf(" %s\n",*p); |
| 2046 |
return(MagickTrue); |
| 2047 |
} |
| 2048 |
|
| 2049 |
int main(int argc,char **argv) |
| 2050 |
{ |
| 2051 |
#define DestroyValidate() \ |
| 2052 |
{ \ |
| 2053 |
image_info=DestroyImageInfo(image_info); \ |
| 2054 |
exception=DestroyExceptionInfo(exception); \ |
| 2055 |
} |
| 2056 |
#define ThrowValidateException(asperity,tag,option) \ |
| 2057 |
{ \ |
| 2058 |
(void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 2059 |
option); \ |
| 2060 |
CatchException(exception); \ |
| 2061 |
DestroyValidate(); \ |
| 2062 |
return(MagickFalse); \ |
| 2063 |
} |
| 2064 |
|
| 2065 |
char |
| 2066 |
output_filename[MagickPathExtent], |
| 2067 |
reference_filename[MagickPathExtent], |
| 2068 |
*option; |
| 2069 |
|
| 2070 |
double |
| 2071 |
elapsed_time, |
| 2072 |
user_time; |
| 2073 |
|
| 2074 |
ExceptionInfo |
| 2075 |
*exception; |
| 2076 |
|
| 2077 |
Image |
| 2078 |
*reference_image; |
| 2079 |
|
| 2080 |
ImageInfo |
| 2081 |
*image_info; |
| 2082 |
|
| 2083 |
MagickBooleanType |
| 2084 |
regard_warnings, |
| 2085 |
status; |
| 2086 |
|
| 2087 |
MagickSizeType |
| 2088 |
memory_resource, |
| 2089 |
map_resource; |
| 2090 |
|
| 2091 |
ssize_t |
| 2092 |
i; |
| 2093 |
|
| 2094 |
TimerInfo |
| 2095 |
*timer; |
| 2096 |
|
| 2097 |
size_t |
| 2098 |
fail, |
| 2099 |
iterations, |
| 2100 |
tests; |
| 2101 |
|
| 2102 |
ValidateType |
| 2103 |
type; |
| 2104 |
|
| 2105 |
|
| 2106 |
|
| 2107 |
|
| 2108 |
MagickCoreGenesis(*argv,MagickTrue); |
| 2109 |
(void) setlocale(LC_ALL,""); |
| 2110 |
(void) setlocale(LC_NUMERIC,"C"); |
| 2111 |
iterations=1; |
| 2112 |
status=MagickFalse; |
| 2113 |
type=AllValidate; |
| 2114 |
regard_warnings=MagickFalse; |
| 2115 |
(void) regard_warnings; |
| 2116 |
exception=AcquireExceptionInfo(); |
| 2117 |
image_info=AcquireImageInfo(); |
| 2118 |
(void) CopyMagickString(image_info->filename,ReferenceFilename, |
| 2119 |
MagickPathExtent); |
| 2120 |
for (i=1; i < (ssize_t) argc; i++) |
| 2121 |
{ |
| 2122 |
option=argv[i]; |
| 2123 |
if (IsCommandOption(option) == MagickFalse) |
| 2124 |
{ |
| 2125 |
(void) CopyMagickString(image_info->filename,option,MagickPathExtent); |
| 2126 |
continue; |
| 2127 |
} |
| 2128 |
switch (*(option+1)) |
| 2129 |
{ |
| 2130 |
case 'b': |
| 2131 |
{ |
| 2132 |
if (LocaleCompare("bench",option+1) == 0) |
| 2133 |
{ |
| 2134 |
iterations=StringToUnsignedLong(argv[++i]); |
| 2135 |
break; |
| 2136 |
} |
| 2137 |
ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2138 |
} |
| 2139 |
case 'd': |
| 2140 |
{ |
| 2141 |
if (LocaleCompare("debug",option+1) == 0) |
| 2142 |
{ |
| 2143 |
(void) SetLogEventMask(argv[++i]); |
| 2144 |
break; |
| 2145 |
} |
| 2146 |
ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2147 |
} |
| 2148 |
case 'h': |
| 2149 |
{ |
| 2150 |
if (LocaleCompare("help",option+1) == 0) |
| 2151 |
{ |
| 2152 |
(void) ValidateUsage(); |
| 2153 |
return(0); |
| 2154 |
} |
| 2155 |
ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2156 |
} |
| 2157 |
case 'l': |
| 2158 |
{ |
| 2159 |
if (LocaleCompare("log",option+1) == 0) |
| 2160 |
{ |
| 2161 |
if (*option != '+') |
| 2162 |
(void) SetLogFormat(argv[i+1]); |
| 2163 |
break; |
| 2164 |
} |
| 2165 |
ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2166 |
} |
| 2167 |
case 'r': |
| 2168 |
{ |
| 2169 |
if (LocaleCompare("regard-warnings",option+1) == 0) |
| 2170 |
{ |
| 2171 |
regard_warnings=MagickTrue; |
| 2172 |
break; |
| 2173 |
} |
| 2174 |
ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2175 |
} |
| 2176 |
case 'v': |
| 2177 |
{ |
| 2178 |
if (LocaleCompare("validate",option+1) == 0) |
| 2179 |
{ |
| 2180 |
ssize_t |
| 2181 |
validate; |
| 2182 |
|
| 2183 |
if (*option == '+') |
| 2184 |
break; |
| 2185 |
i++; |
| 2186 |
if (i >= (ssize_t) argc) |
| 2187 |
ThrowValidateException(OptionError,"MissingArgument",option); |
| 2188 |
validate=ParseCommandOption(MagickValidateOptions,MagickFalse, |
| 2189 |
argv[i]); |
| 2190 |
if (validate < 0) |
| 2191 |
ThrowValidateException(OptionError,"UnrecognizedValidateType", |
| 2192 |
argv[i]); |
| 2193 |
type=(ValidateType) validate; |
| 2194 |
break; |
| 2195 |
} |
| 2196 |
if ((LocaleCompare("version",option+1) == 0) || |
| 2197 |
(LocaleCompare("-version",option+1) == 0)) |
| 2198 |
{ |
| 2199 |
(void) FormatLocaleFile(stdout,"Version: %s\n", |
| 2200 |
GetMagickVersion((size_t *) NULL)); |
| 2201 |
(void) FormatLocaleFile(stdout,"Copyright: %s\n\n", |
| 2202 |
GetMagickCopyright()); |
| 2203 |
(void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 2204 |
GetMagickFeatures()); |
| 2205 |
return(0); |
| 2206 |
} |
| 2207 |
ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2208 |
} |
| 2209 |
default: |
| 2210 |
ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2211 |
} |
| 2212 |
} |
| 2213 |
timer=(TimerInfo *) NULL; |
| 2214 |
if (iterations > 1) |
| 2215 |
timer=AcquireTimerInfo(); |
| 2216 |
reference_image=ReadImage(image_info,exception); |
| 2217 |
tests=0; |
| 2218 |
fail=0; |
| 2219 |
if (reference_image == (Image *) NULL) |
| 2220 |
fail++; |
| 2221 |
else |
| 2222 |
{ |
| 2223 |
if (LocaleCompare(image_info->filename,ReferenceFilename) == 0) |
| 2224 |
(void) CopyMagickString(reference_image->magick,ReferenceImageFormat, |
| 2225 |
MagickPathExtent); |
| 2226 |
(void) AcquireUniqueFilename(reference_filename); |
| 2227 |
(void) AcquireUniqueFilename(output_filename); |
| 2228 |
(void) CopyMagickString(reference_image->filename,reference_filename, |
| 2229 |
MagickPathExtent); |
| 2230 |
status=WriteImage(image_info,reference_image,exception); |
| 2231 |
reference_image=DestroyImage(reference_image); |
| 2232 |
if (status == MagickFalse) |
| 2233 |
fail++; |
| 2234 |
else |
| 2235 |
{ |
| 2236 |
(void) FormatLocaleFile(stdout,"Version: %s\n", |
| 2237 |
GetMagickVersion((size_t *) NULL)); |
| 2238 |
(void) FormatLocaleFile(stdout,"Copyright: %s\n\n", |
| 2239 |
GetMagickCopyright()); |
| 2240 |
(void) FormatLocaleFile(stdout, |
| 2241 |
"ImageMagick Validation Suite (%s)\n\n",CommandOptionToMnemonic( |
| 2242 |
MagickValidateOptions,(ssize_t) type)); |
| 2243 |
if ((type & ColorspaceValidate) != 0) |
| 2244 |
tests+=ValidateColorspaces(&fail,exception); |
| 2245 |
if ((type & CompareValidate) != 0) |
| 2246 |
tests+=ValidateCompareCommand(image_info,reference_filename, |
| 2247 |
output_filename,&fail,exception); |
| 2248 |
if ((type & CompositeValidate) != 0) |
| 2249 |
tests+=ValidateCompositeCommand(image_info,reference_filename, |
| 2250 |
output_filename,&fail,exception); |
| 2251 |
if ((type & ConvertValidate) != 0) |
| 2252 |
tests+=ValidateConvertCommand(image_info,reference_filename, |
| 2253 |
output_filename,&fail,exception); |
| 2254 |
if ((type & FormatsDiskValidate) != 0) |
| 2255 |
{ |
| 2256 |
memory_resource=SetMagickResourceLimit(MemoryResource,0); |
| 2257 |
map_resource=SetMagickResourceLimit(MapResource,0); |
| 2258 |
(void) FormatLocaleFile(stdout,"[pixel-cache: disk] "); |
| 2259 |
tests+=ValidateImageFormatsInMemory(image_info,reference_filename, |
| 2260 |
output_filename,&fail,exception); |
| 2261 |
(void) FormatLocaleFile(stdout,"[pixel-cache: disk] "); |
| 2262 |
tests+=ValidateImageFormatsOnDisk(image_info,reference_filename, |
| 2263 |
output_filename,&fail,exception); |
| 2264 |
(void) SetMagickResourceLimit(MemoryResource,memory_resource); |
| 2265 |
(void) SetMagickResourceLimit(MapResource,map_resource); |
| 2266 |
} |
| 2267 |
if ((type & FormatsMapValidate) != 0) |
| 2268 |
{ |
| 2269 |
memory_resource=SetMagickResourceLimit(MemoryResource,0); |
| 2270 |
(void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] "); |
| 2271 |
tests+=ValidateImageFormatsInMemory(image_info,reference_filename, |
| 2272 |
output_filename,&fail,exception); |
| 2273 |
(void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] "); |
| 2274 |
tests+=ValidateImageFormatsOnDisk(image_info,reference_filename, |
| 2275 |
output_filename,&fail,exception); |
| 2276 |
(void) SetMagickResourceLimit(MemoryResource,memory_resource); |
| 2277 |
} |
| 2278 |
if ((type & FormatsMemoryValidate) != 0) |
| 2279 |
{ |
| 2280 |
(void) FormatLocaleFile(stdout,"[pixel-cache: memory] "); |
| 2281 |
tests+=ValidateImageFormatsInMemory(image_info,reference_filename, |
| 2282 |
output_filename,&fail,exception); |
| 2283 |
(void) FormatLocaleFile(stdout,"[pixel-cache: memory] "); |
| 2284 |
tests+=ValidateImageFormatsOnDisk(image_info,reference_filename, |
| 2285 |
output_filename,&fail,exception); |
| 2286 |
} |
| 2287 |
if ((type & IdentifyValidate) != 0) |
| 2288 |
tests+=ValidateIdentifyCommand(image_info,reference_filename, |
| 2289 |
output_filename,&fail,exception); |
| 2290 |
if ((type & ImportExportValidate) != 0) |
| 2291 |
tests+=ValidateImportExportPixels(image_info,reference_filename, |
| 2292 |
output_filename,&fail,exception); |
| 2293 |
if ((type & MagickValidate) != 0) |
| 2294 |
tests+=ValidateMagickCommand(image_info,reference_filename, |
| 2295 |
output_filename,&fail,exception); |
| 2296 |
if ((type & MontageValidate) != 0) |
| 2297 |
tests+=ValidateMontageCommand(image_info,reference_filename, |
| 2298 |
output_filename,&fail,exception); |
| 2299 |
if ((type & StreamValidate) != 0) |
| 2300 |
tests+=ValidateStreamCommand(image_info,reference_filename, |
| 2301 |
output_filename,&fail,exception); |
| 2302 |
(void) FormatLocaleFile(stdout, |
| 2303 |
"validation suite: %.20g tests; %.20g passed; %.20g failed.\n", |
| 2304 |
(double) tests,(double) (tests-fail),(double) fail); |
| 2305 |
} |
| 2306 |
(void) RelinquishUniqueFileResource(output_filename); |
| 2307 |
(void) ConcatenateMagickString(output_filename,"-0",MagickPathExtent); |
| 2308 |
(void) RelinquishUniqueFileResource(output_filename); |
| 2309 |
(void) RelinquishUniqueFileResource(reference_filename); |
| 2310 |
} |
| 2311 |
if (exception->severity != UndefinedException) |
| 2312 |
CatchException(exception); |
| 2313 |
if (iterations > 1) |
| 2314 |
{ |
| 2315 |
elapsed_time=GetElapsedTime(timer); |
| 2316 |
user_time=GetUserTime(timer); |
| 2317 |
(void) FormatLocaleFile(stderr, |
| 2318 |
"Performance: %.20gi %.3fips %0.6fu %ld:%02ld.%03ld\n",(double) |
| 2319 |
iterations,1.0*iterations/elapsed_time,user_time,(long) |
| 2320 |
(elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)), |
| 2321 |
(long) (1000.0*(elapsed_time-floor(elapsed_time)))); |
| 2322 |
timer=DestroyTimerInfo(timer); |
| 2323 |
} |
| 2324 |
DestroyValidate(); |
| 2325 |
MagickCoreTerminus(); |
| 2326 |
return(fail == 0 ? 0 : 1); |
| 2327 |
} |