mirror of
https://github.com/bkaradzic/bimg.git
synced 2026-02-17 20:52:38 +01:00
Fixed SDF.
This commit is contained in:
@@ -118,6 +118,11 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
outputFormat = _options.format;
|
||||
}
|
||||
|
||||
if (_options.sdf)
|
||||
{
|
||||
outputFormat = bimg::TextureFormat::R8;
|
||||
}
|
||||
|
||||
const bimg::ImageBlockInfo& inputBlockInfo = bimg::getBlockInfo(inputFormat);
|
||||
const bimg::ImageBlockInfo& outputBlockInfo = bimg::getBlockInfo(outputFormat);
|
||||
const uint32_t blockWidth = outputBlockInfo.blockWidth;
|
||||
@@ -410,6 +415,43 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
|
||||
BX_FREE(_allocator, rgbaDst);
|
||||
}
|
||||
else if (_options.sdf)
|
||||
{
|
||||
uint32_t size = bimg::imageGetSize(
|
||||
NULL
|
||||
, uint16_t(dstMip.m_width)
|
||||
, uint16_t(dstMip.m_height)
|
||||
, uint16_t(dstMip.m_depth)
|
||||
, false
|
||||
, false
|
||||
, 1
|
||||
, bimg::TextureFormat::R8
|
||||
);
|
||||
temp = BX_ALLOC(_allocator, size);
|
||||
uint8_t* rgba = (uint8_t*)temp;
|
||||
|
||||
bimg::imageDecodeToR8(_allocator
|
||||
, rgba
|
||||
, mip.m_data
|
||||
, mip.m_width
|
||||
, mip.m_height
|
||||
, mip.m_depth
|
||||
, mip.m_width
|
||||
, mip.m_format
|
||||
);
|
||||
|
||||
bimg::imageGetRawData(*output, side, 0, output->m_data, output->m_size, dstMip);
|
||||
dstData = const_cast<uint8_t*>(dstMip.m_data);
|
||||
|
||||
bimg::imageMakeDist(_allocator
|
||||
, dstData
|
||||
, mip.m_width
|
||||
, mip.m_height
|
||||
, mip.m_width
|
||||
, _options.edge
|
||||
, rgba
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t size = bimg::imageGetSize(
|
||||
@@ -666,7 +708,10 @@ int main(int _argc, const char* _argv[])
|
||||
if (NULL != edgeOpt)
|
||||
{
|
||||
options.sdf = true;
|
||||
options.edge = (float)atof(edgeOpt);
|
||||
if (!bx::fromString(&options.edge, edgeOpt) )
|
||||
{
|
||||
options.edge = 255.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -674,7 +719,10 @@ int main(int _argc, const char* _argv[])
|
||||
if (NULL != alphaRef)
|
||||
{
|
||||
options.alphaTest = true;
|
||||
options.edge = (float)atof(alphaRef);
|
||||
if (!bx::fromString(&options.edge, alphaRef))
|
||||
{
|
||||
options.edge = 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user