Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove wrong forcing of image size to 1x1 when it was read from the data or disk to be 0x0 (which indicates the image could not be parsed in that format). Handling for images 0x0 in size must be kept because Tk bases its error detection for the format on this feature. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | tip-545-svg-options |
Files: | files | file ages | folders |
SHA3-256: |
c111a3ea33248b29e2540e895e6753af |
User & Date: | fvogel 2019-06-12 22:23:54.739 |
Context
2019-06-14
| ||
16:46 | Tests for svg file check-in: 8809f721 user: oehhar tags: tip-545-svg-options | |
2019-06-12
| ||
22:23 | Remove wrong forcing of image size to 1x1 when it was read from the data or disk to be 0x0 (which indicates the image could not be parsed in that format). Handling for images 0x0 in size must be kept because Tk bases its error detection for the format on this feature. check-in: c111a3ea user: fvogel tags: tip-545-svg-options | |
2019-06-10
| ||
12:22 | Fix code style a bit, and comments check-in: ebc9fe82 user: fvogel tags: tip-545-svg-options | |
Changes
Changes to generic/tkImgSVGnano.c.
︙ | ︙ | |||
135 136 137 138 139 140 141 | /* in case of an error reading the file */ Tcl_DecrRefCount(dataObj); return 0; } data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); Tcl_DecrRefCount(dataObj); | | | < < < < < | | | | < < < < < | | | | > > | 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 | /* in case of an error reading the file */ Tcl_DecrRefCount(dataObj); return 0; } data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); Tcl_DecrRefCount(dataObj); if (nsvgImage != NULL) { GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr); if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) { nsvgDelete(nsvgImage); return 0; } if (!CacheSVG(interp, chan, formatObj, nsvgImage, &ropts)) { nsvgDelete(nsvgImage); } return 1; } return 0; } /* *---------------------------------------------------------------------- * * FileReadSVG -- * |
︙ | ︙ | |||
247 248 249 250 251 252 253 | const char *data; RastOpts ropts; NSVGimage *nsvgImage; CleanCache(interp); data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); | | | < < < < < | | | | < | | | | > > | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | const char *data; RastOpts ropts; NSVGimage *nsvgImage; CleanCache(interp); data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); if (nsvgImage != NULL) { GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr); if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) { nsvgDelete(nsvgImage); return 0; } if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) { nsvgDelete(nsvgImage); } return 1; } return 0; } /* *---------------------------------------------------------------------- * * StringReadSVG -- * |
︙ | ︙ | |||
582 583 584 585 586 587 588 | * * GetScaleFromParameters -- * * Get the scale value from the already parsed parameters -scale, * -scaletoheight and -scaletowidth. * * The image width and height is also returned. | < | | | < > | | 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 | * * 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) { |
︙ | ︙ | |||
628 629 630 631 632 633 634 | /* * Scale factor */ scale = ropts->scale; width = (int) ceil(nsvgImage->width * scale); height = (int) ceil(nsvgImage->height * scale); } | < < < < < < < < | < < < < < < | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | /* * Scale factor */ scale = ropts->scale; width = (int) ceil(nsvgImage->width * scale); height = (int) ceil(nsvgImage->height * scale); } *heightPtr = height; *widthPtr = width; return scale; } /* *---------------------------------------------------------------------- |
︙ | ︙ |