Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix code style a bit, and comments |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | tip-545-svg-options |
Files: | files | file ages | folders |
SHA3-256: |
ebc9fe82f9f6cc88b33c91170950d07c |
User & Date: | fvogel 2019-06-10 12:22:23.661 |
Context
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 | |
12:10 | Update documentation to reflect content of TIP #545 check-in: 2057f970 user: fvogel tags: tip-545-svg-options | |
Changes
Changes to generic/tkImgSVGnano.c.
︙ | ︙ | |||
258 259 260 261 262 263 264 | * Width and Height equal zero is an svgnano error case and must be errored * out. Valid png images give width and height 0 as result */ if ((nsvgImage->width <= 0.0) || (nsvgImage->height <= 0.0)) { nsvgDelete(nsvgImage); return 0; } | | < < < < | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | * Width and Height equal zero is an svgnano error case and must be errored * out. Valid png images give width and height 0 as result */ if ((nsvgImage->width <= 0.0) || (nsvgImage->height <= 0.0)) { nsvgDelete(nsvgImage); return 0; } GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr); if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) { nsvgDelete(nsvgImage); } return 1; } /* |
︙ | ︙ | |||
527 528 529 530 531 532 533 | { int w, h, c; NSVGrasterizer *rast; unsigned char *imgData; Tk_PhotoImageBlock svgblock; double scale; | | < < < < | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | { int w, h, c; NSVGrasterizer *rast; unsigned char *imgData; Tk_PhotoImageBlock svgblock; double scale; scale = GetScaleFromParameters(nsvgImage, ropts, &w, &h); rast = nsvgCreateRasterizer(); if (rast == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot initialize rasterizer", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "RASTERIZER_ERROR", NULL); goto cleanAST; |
︙ | ︙ | |||
590 591 592 593 594 595 596 | * * GetScaleFromParameters -- * * Get the scale value from the already parsed parameters -scale, * -scaletoheight and -scaletowidth. * * The image width and height is also returned. | | | | | | | 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 | * * GetScaleFromParameters -- * * Get the scale value from the already parsed parameters -scale, * -scaletoheight and -scaletowidth. * * The image width and height is also returned. * Both are greater than or equal to 1. * * 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; /* * nsvgImage->width and nsvgImage->height are greater than 0. * Equal to 0 is an svgnano error case. */ 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 |
︙ | ︙ |