SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Toggle main menu visibility
Loading...
Searching...
No Matches
DistanceMapping.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <vector>
4
5
#include <
sourcepp/Macros.h
>
6
#include <
vtfpp/ImageConversion.h
>
7
8
namespace
vtfpp::DistanceMapping
{
9
10
enum class
Dither
{
11
NONE
= 0,
12
GRADIENT_TANGENT
,
13
// anything generic that doesn't depend on the geometry of the distance field (floyd-steinberg etc) would belong somewhere more general.
14
};
15
16
enum class
Flags
: uint32_t {
17
NONE
= 0,
18
DISTANCEAA
= 1 << 0,
19
EUCLIDEAN
= 1 << 1,
20
SAMPLECENTERED
= 1 << 2,
21
};
22
SOURCEPP_BITFLAGS_ENUM
(
Flags
)
23
24
37
[[nodiscard]] std::vector<std::byte>
alphaToDistance
(
38
std::span<const std::byte> imageData,
39
ImageFormat
inFormat,
40
ImageFormat
outFormat,
41
uint16_t width,
42
uint16_t height,
43
uint16_t reduceX,
44
uint16_t reduceY,
45
bool
srgb,
46
float
distanceSpread = 1.f,
47
float
alphaThreshold = 0.04f,
48
Flags
flags =
Flags::NONE
,
49
Dither
dither =
Dither::NONE
,
50
ImageConversion::ResizeFilter
filter =
ImageConversion::ResizeFilter::NICE
,
51
ImageConversion::ResizeEdge
edge =
ImageConversion::ResizeEdge::CLAMP
,
52
bool
* valveQuirks =
nullptr
53
);
54
55
}
// namespace vtfpp::DistanceMapping
ImageConversion.h
Macros.h
SOURCEPP_BITFLAGS_ENUM
#define SOURCEPP_BITFLAGS_ENUM(Enum)
Defines bitwise operators for an enum or enum class.
Definition
Macros.h:29
vtfpp::DistanceMapping
Definition
DistanceMapping.h:8
vtfpp::DistanceMapping::Dither
Dither
Definition
DistanceMapping.h:10
vtfpp::DistanceMapping::Dither::GRADIENT_TANGENT
@ GRADIENT_TANGENT
Experimental dithering approach that diffuses quantization error perpendicular to the distance gradie...
Definition
DistanceMapping.h:12
vtfpp::DistanceMapping::Dither::NONE
@ NONE
No dithering.
Definition
DistanceMapping.h:11
vtfpp::DistanceMapping::alphaToDistance
std::vector< std::byte > alphaToDistance(std::span< const std::byte > imageData, ImageFormat inFormat, ImageFormat outFormat, uint16_t width, uint16_t height, uint16_t reduceX, uint16_t reduceY, bool srgb, float distanceSpread=1.f, float alphaThreshold=0.04f, Flags flags=Flags::NONE, Dither dither=Dither::NONE, ImageConversion::ResizeFilter filter=ImageConversion::ResizeFilter::NICE, ImageConversion::ResizeEdge edge=ImageConversion::ResizeEdge::CLAMP, bool *valveQuirks=nullptr)
In one operation, convert an image's alpha channel, or, for single-channel formats,...
Definition
DistanceMapping.cpp:474
vtfpp::DistanceMapping::Flags
Flags
Definition
DistanceMapping.h:16
vtfpp::DistanceMapping::Flags::SAMPLECENTERED
@ SAMPLECENTERED
Search from the center of pixels (in destination coordinate space) rather than in their north-west co...
Definition
DistanceMapping.h:20
vtfpp::DistanceMapping::Flags::EUCLIDEAN
@ EUCLIDEAN
The distance-mapping algorithm is a brute-force scan of a square area. If this is enabled,...
Definition
DistanceMapping.h:19
vtfpp::DistanceMapping::Flags::NONE
@ NONE
Definition
DistanceMapping.h:17
vtfpp::DistanceMapping::Flags::DISTANCEAA
@ DISTANCEAA
Experimental; interpret the alpha channel as antialiased. Can result in a more precise distance map,...
Definition
DistanceMapping.h:18
vtfpp::ImageConversion::ResizeEdge
ResizeEdge
Definition
ImageConversion.h:70
vtfpp::ImageConversion::ResizeEdge::CLAMP
@ CLAMP
Definition
ImageConversion.h:72
vtfpp::ImageConversion::ResizeFilter
ResizeFilter
Definition
ImageConversion.h:78
vtfpp::ImageConversion::ResizeFilter::NICE
@ NICE
Valve NICE filtering, equivalent to Lanczos-3.
Definition
ImageConversion.h:91
vtfpp::ImageFormat
ImageFormat
Definition
ImageFormats.h:13
include
vtfpp
DistanceMapping.h
Generated on
for SourcePP by
1.17.0