* @memberof ktxTexture2 * @~English * @brief Write a ktxTexture object to block of memory in KTX format. * * Memory is allocated by the function and the caller is responsible for * freeing it. * * Callers are strongly urged to include a KTXwriter item in the texture's * metadata. It can be added by code, similar to the following, prior to * calling this function. * @code * char writ
| 745 | * An error occurred while writing the file. |
| 746 | */ |
| 747 | KTX_error_code |
| 748 | ktxTexture2_WriteToMemory(ktxTexture2* This, |
| 749 | ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) |
| 750 | { |
| 751 | struct ktxStream dststr; |
| 752 | KTX_error_code result; |
| 753 | ktx_size_t strSize; |
| 754 | |
| 755 | if (!This || !ppDstBytes || !pSize) |
| 756 | return KTX_INVALID_VALUE; |
| 757 | |
| 758 | *ppDstBytes = NULL; |
| 759 | |
| 760 | result = ktxMemStream_construct(&dststr, KTX_FALSE); |
| 761 | if (result != KTX_SUCCESS) |
| 762 | return result; |
| 763 | |
| 764 | result = ktxTexture2_WriteToStream(This, &dststr); |
| 765 | if(result != KTX_SUCCESS) |
| 766 | { |
| 767 | ktxMemStream_destruct(&dststr); |
| 768 | return result; |
| 769 | } |
| 770 | |
| 771 | ktxMemStream_getdata(&dststr, ppDstBytes); |
| 772 | dststr.getsize(&dststr, &strSize); |
| 773 | *pSize = (GLsizei)strSize; |
| 774 | /* This function does not free the memory pointed at by the |
| 775 | * value obtained from ktxMemStream_getdata() thanks to the |
| 776 | * KTX_FALSE passed to the constructor above. |
| 777 | */ |
| 778 | ktxMemStream_destruct(&dststr); |
| 779 | return KTX_SUCCESS; |
| 780 | |
| 781 | } |
| 782 | |
| 783 | /** |
| 784 | * @memberof ktxTexture2 |
nothing calls this directly
no test coverage detected