* @memberof ktxTexture1 * @~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. * * @param[in] This pointer to the target ktxTexture object. * @param[in,out] ppDstBytes pointer to location to write the address of * the destination memory. The
| 467 | * An error occurred while writing the file. |
| 468 | */ |
| 469 | KTX_error_code |
| 470 | ktxTexture1_WriteToMemory(ktxTexture1* This, |
| 471 | ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) |
| 472 | { |
| 473 | struct ktxStream dststr; |
| 474 | KTX_error_code result; |
| 475 | ktx_size_t strSize; |
| 476 | |
| 477 | if (!This || !ppDstBytes || !pSize) |
| 478 | return KTX_INVALID_VALUE; |
| 479 | |
| 480 | *ppDstBytes = NULL; |
| 481 | |
| 482 | result = ktxMemStream_construct(&dststr, KTX_FALSE); |
| 483 | if (result != KTX_SUCCESS) |
| 484 | return result; |
| 485 | |
| 486 | result = ktxTexture1_WriteToStream(This, &dststr); |
| 487 | if(result != KTX_SUCCESS) |
| 488 | { |
| 489 | ktxMemStream_destruct(&dststr); |
| 490 | return result; |
| 491 | } |
| 492 | |
| 493 | ktxMemStream_getdata(&dststr, ppDstBytes); |
| 494 | dststr.getsize(&dststr, &strSize); |
| 495 | *pSize = (GLsizei)strSize; |
| 496 | /* This function does not free the memory pointed at by the |
| 497 | * value obtained from ktxMemStream_getdata() thanks to the |
| 498 | * KTX_FALSE passed to the constructor above. |
| 499 | */ |
| 500 | ktxMemStream_destruct(&dststr); |
| 501 | return KTX_SUCCESS; |
| 502 | |
| 503 | } |
| 504 | |
| 505 | ktx_uint32_t lcm4(uint32_t a); |
| 506 | KTX_error_code appendLibId(ktxHashList* head, |