| 317 | } |
| 318 | |
| 319 | void imageEncode(bx::AllocatorI* _allocator, void* _dst, const void* _src, TextureFormat::Enum _srcFormat, uint32_t _width, uint32_t _height, uint32_t _depth, TextureFormat::Enum _dstFormat, Quality::Enum _quality, bx::Error* _err) |
| 320 | { |
| 321 | switch (_dstFormat) |
| 322 | { |
| 323 | case TextureFormat::BC1: |
| 324 | case TextureFormat::BC2: |
| 325 | case TextureFormat::BC3: |
| 326 | case TextureFormat::BC4: |
| 327 | case TextureFormat::BC5: |
| 328 | case TextureFormat::ETC1: |
| 329 | case TextureFormat::ETC2: |
| 330 | case TextureFormat::PTC14: |
| 331 | case TextureFormat::PTC14A: |
| 332 | case TextureFormat::ASTC4x4: |
| 333 | case TextureFormat::ASTC5x4: |
| 334 | case TextureFormat::ASTC5x5: |
| 335 | case TextureFormat::ASTC6x5: |
| 336 | case TextureFormat::ASTC6x6: |
| 337 | case TextureFormat::ASTC8x5: |
| 338 | case TextureFormat::ASTC8x6: |
| 339 | case TextureFormat::ASTC8x8: |
| 340 | case TextureFormat::ASTC10x5: |
| 341 | case TextureFormat::ASTC10x6: |
| 342 | case TextureFormat::ASTC10x8: |
| 343 | case TextureFormat::ASTC10x10: |
| 344 | case TextureFormat::ASTC12x10: |
| 345 | case TextureFormat::ASTC12x12: |
| 346 | { |
| 347 | uint8_t* temp = (uint8_t*)bx::alloc(_allocator, _width*_height*_depth*4); |
| 348 | imageDecodeToRgba8(_allocator, temp, _src, _width, _height, _width*4, _srcFormat); |
| 349 | imageEncodeFromRgba8(_allocator, _dst, temp, _width, _height, _depth, _dstFormat, _quality, _err); |
| 350 | bx::free(_allocator, temp); |
| 351 | } |
| 352 | break; |
| 353 | |
| 354 | case bimg::TextureFormat::BC6H: |
| 355 | case bimg::TextureFormat::BC7: |
| 356 | { |
| 357 | uint8_t* temp = (uint8_t*)bx::alloc(_allocator, _width*_height*_depth*16); |
| 358 | imageDecodeToRgba32f(_allocator, temp, _src, _width, _height, _depth, _width*16, _srcFormat); |
| 359 | imageEncodeFromRgba32f(_allocator, _dst, temp, _width, _height, _depth, _dstFormat, _quality, _err); |
| 360 | bx::free(_allocator, temp); |
| 361 | } |
| 362 | break; |
| 363 | |
| 364 | default: |
| 365 | if (!imageConvert(_allocator, _dst, _dstFormat, _src, _srcFormat, _width, _height, 1) ) |
| 366 | { |
| 367 | BX_ERROR_SET(_err, BIMG_ERROR, "Unable to convert between input/output formats!"); |
| 368 | } |
| 369 | break; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | ImageContainer* imageEncode(bx::AllocatorI* _allocator, TextureFormat::Enum _dstFormat, Quality::Enum _quality, const ImageContainer& _input) |
| 374 | { |
no test coverage detected