In one operation, convert an image's alpha channel, or, for single-channel formats, its only channel, to a VTEX-style distance map, and downscale other channels, if present in the output, according to the given resize parameters.
- Returns
- Empty if:
inFormat or outFormat do not satisfy their documented predicates,
reduceX or reduceY are not powers of two,
distanceSpread would result in a search radius of zero with either reduceX or reduceY,
alphaThreshold is out of range, or
edge is ResizeEdge::ZERO.
Otherwise, an image at width / reduceX by height / reduceY in outFormat:
- if
outFormat is single-channel, R contains the distance map.
- if
outFormat has alpha, A contains the distance map, while R/G/B contain:
- if
inFormat had R/G/B, the scaled R/G/B of the input image, otherwise
- 0 in all other channels.
- Parameters
-
| inFormat | Any format that is either single-channel, or has an alpha channel. |
| outFormat | The same requirements as inFormat; channel count does not need to correspond to inFormat. |
| reduceX | Power-of-two horizontal reduction factor. |
| reduceY | Power-of-two vertical reduction factor. |
| srgb | Used in the case of RGBA->RGBA. premultipliedAlpha is omitted. |
| distanceSpread | Scale factor beyond reduceX and reduceY, of search radius for distance hits. |
| alphaThreshold | Threshold below which alpha values are considered zero. |
| flags | Additional behaviors that deviate from VTEX but may be useful; see DistanceFlags. |
| dither | Internally, distance maps are always computed in floating point. When set to a value other than NONE, and the output format is of integral type, dithering is applied prior to quantization. Depending on the application and contents, this can improve or worsen the quality of the distance map. |
| filter | Default value mimics VTEX. Does not affect the alpha channel; distance mapping is a distinct sampling operation from source to destination space. Entirely unused if input is single-channel. |
| edge | Dictates the sampling policy of the distance function regardless of whether there are non-alpha channels to be resized. |
| valveQuirks | When non-null, mimic VTEX's policy of blanking out any edge pixels in the distance map to 0 (i.e. infinite distance), and report back whether this resulted in any change (such that a command-line tool emulating VTEX would want to report a warning). |
Definition at line 474 of file DistanceMapping.cpp.