Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tip-545-svg-options Excluding Merge-Ins
This is equivalent to a diff from e704fbb6 to 595d1ebd
2019-08-19
| ||
07:42 | Merge branch 'tip-545-svg-options' after positive vote check-in: 56b9b155 user: oehhar tags: trunk | |
2019-06-16
| ||
16:57 | Do small scale to 1x1 test also for file source, renumber tests. Closed-Leaf check-in: 595d1ebd user: oehhar tags: tip-545-svg-options | |
2019-06-14
| ||
16:46 | Tests for svg file check-in: 8809f721 user: oehhar tags: tip-545-svg-options | |
2019-06-07
| ||
19:12 | Fix [c345ddf1a7]: typo in comment of tkMacOSXDraw.c check-in: ff8d6c88 user: fvogel tags: trunk | |
18:46 | Merge trunk check-in: c4aca028 user: oehhar tags: tip-545-svg-options | |
2019-06-05
| ||
21:25 | merge trunk Closed-Leaf check-in: 83678378 user: jan.nijtmans tags: offsetof | |
19:44 | Fix bug [9ebc6fd168]: Aqua can report incorrect mouse coordinates. check-in: e704fbb6 user: culler tags: trunk | |
19:44 | Remove trailing whitespace that emacs inserts. check-in: 01e3ff40 user: culler tags: core-8-6-branch | |
14:49 | merge-mark check-in: 7b9b1460 user: jan.nijtmans tags: trunk | |
Changes to doc/photo.n.
︙ | |||
548 549 550 551 552 553 554 | 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | - + - - - + + + + - + | . The option has effect when reading image data from a file. Specifies an additional alpha filtering for the overall image, which allows the background on which the image is displayed to show through. This usually also has the effect of desaturating the image. The \fIalphaValue\fR must be between 0.0 and 1.0. .TP |
︙ |
Changes to generic/tkImgSVGnano.c.
︙ | |||
26 27 28 29 30 31 32 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | - - - + + + + + + + | #include "nanosvg.h" #define NANOSVGRAST_IMPLEMENTATION #include "nanosvgrast.h" /* Additional parameters to nsvgRasterize() */ typedef struct { |
︙ | |||
64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | + + | static NSVGimage * ParseSVGWithOptions(Tcl_Interp *interp, const char *input, int length, Tcl_Obj *format, RastOpts *ropts); static int RasterizeSVG(Tcl_Interp *interp, Tk_PhotoHandle imageHandle, NSVGimage *nsvgImage, int destX, int destY, int width, int height, int srcX, int srcY, RastOpts *ropts); static double GetScaleFromParameters(NSVGimage *nsvgImage, RastOpts *ropts, int *widthPtr, int *heightPtr); static NSVGcache * GetCachePtr(Tcl_Interp *interp); static int CacheSVG(Tcl_Interp *interp, ClientData dataOrChan, Tcl_Obj *formatObj, NSVGimage *nsvgImage, RastOpts *ropts); static NSVGimage * GetCachedSVG(Tcl_Interp *interp, ClientData dataOrChan, Tcl_Obj *formatObj, RastOpts *ropts); static void CleanCache(Tcl_Interp *interp); |
︙ | |||
130 131 132 133 134 135 136 | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | - + - - - - + + + - + - - + + | Tcl_DecrRefCount(dataObj); return 0; } data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); Tcl_DecrRefCount(dataObj); if (nsvgImage != NULL) { |
︙ | |||
235 236 237 238 239 240 241 | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | - + - - - - + + + - + - - + + | RastOpts ropts; NSVGimage *nsvgImage; CleanCache(interp); data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); if (nsvgImage != NULL) { |
︙ | |||
320 321 322 323 324 325 326 | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | - + - + - + - - - + + + | int length, Tcl_Obj *formatObj, RastOpts *ropts) { Tcl_Obj **objv = NULL; int objc = 0; double dpi = 96.0; |
︙ | |||
381 382 383 384 385 386 387 388 389 390 391 392 393 394 | 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | + + + + + + + + + + + + + + + + + + + + | Tcl_WrongNumArgs(interp, 1, objv, "value"); goto error; } objc--; objv++; /* * check that only one scale option is given */ switch ((enum fmtOptions) optIndex) { case OPT_SCALE: case OPT_SCALE_TO_HEIGHT: case OPT_SCALE_TO_WIDTH: if ( parameterScaleSeen ) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "only one of -scale, -scaletoheight, -scaletowidth may be given", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE", NULL); goto error; } parameterScaleSeen = 1; } /* * Decode parameters */ switch ((enum fmtOptions) optIndex) { case OPT_DPI: if (Tcl_GetDoubleFromObj(interp, objv[0], &dpi) == TCL_ERROR) { goto error; } if (dpi < 0.0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( |
︙ | |||
407 408 409 410 411 412 413 | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - + | Tcl_SetObjResult(interp, Tcl_NewStringObj( "-scale value must be positive", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE", NULL); goto error; } break; |
︙ | |||
466 467 468 469 470 471 472 473 | 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | + - - + + - - + + | int srcX, int srcY, RastOpts *ropts) { int w, h, c; NSVGrasterizer *rast; unsigned char *imgData; Tk_PhotoImageBlock svgblock; double scale; |
︙ | |||
516 517 518 519 520 521 522 523 524 525 526 527 528 529 | 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 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 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | cleanRAST: nsvgDeleteRasterizer(rast); cleanAST: nsvgDelete(nsvgImage); return TCL_ERROR; } /* *---------------------------------------------------------------------- * * GetScaleFromParameters -- * * Get the scale value from the already parsed parameters -scale, * -scaletoheight and -scaletowidth. * * The image width and height is also returned. * * Results: * The evaluated or configured scale value, or 0.0 on failure * * Side effects: * heightPtr and widthPtr are set to height and width of the image. * *---------------------------------------------------------------------- */ static double GetScaleFromParameters( NSVGimage *nsvgImage, RastOpts *ropts, int *widthPtr, int *heightPtr) { double scale; int width, height; if ((nsvgImage->width == 0.0) || (nsvgImage->height == 0.0)) { width = height = 0; scale = 1.0; } else if (ropts->scaleToHeight > 0) { /* * Fixed height */ height = ropts->scaleToHeight; scale = height / nsvgImage->height; width = (int) ceil(nsvgImage->width * scale); } else if (ropts->scaleToWidth > 0) { /* * Fixed width */ width = ropts->scaleToWidth; scale = width / nsvgImage->width; height = (int) ceil(nsvgImage->height * scale); } else { /* * Scale factor */ scale = ropts->scale; width = (int) ceil(nsvgImage->width * scale); height = (int) ceil(nsvgImage->height * scale); } *heightPtr = height; *widthPtr = width; return scale; } /* *---------------------------------------------------------------------- * * GetCachePtr -- * * This function is called to get the per interpreter used |
︙ |
Changes to tests/imgSVGnano.test.
︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | + + + + + + | <polyline fill="red" stroke="purple" points="80,10 90,20 85,40"/> <polygon fill ="yellow" points="80,80 70,85 90,90"/> </svg>} set data(bad) {<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0:w "> </svg>} tcltest::makeFile $data(plus) plus.svg set data(plusFilePath) [file join [tcltest::configure -tmpdir] plus.svg] tcltest::makeFile $data(bad) bad.svg set data(badFilePath) [file join [tcltest::configure -tmpdir] bad.svg] test imgSVGnano-1.1 {reading simple image} -setup { catch {rename foo ""} } -body { image create photo foo -data $data(plus) list [image width foo] [image height foo] } -cleanup { rename foo "" |
︙ | |||
57 58 59 60 61 62 63 | 63 64 65 66 67 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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } -result {{}} test imgSVGnano-1.4 {image options} -setup { catch {rename foo ""} } -body { image create photo foo -data $data(plus) foo configure -format {svg -scale 2} |