Skip to content

Commit fe07949

Browse files
JPEGCodec: append encoded bits at the end of the data blob instead of overwriting it
1 parent 68831e6 commit fe07949

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

TextureLoader/src/JPEGCodec.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -272,8 +272,9 @@ ENCODE_JPEG_RESULT Diligent_EncodeJpeg(Uint8* pSrcRGBPixels,
272272
/* Step 6: Finish compression */
273273
jpeg_finish_compress(&cinfo);
274274

275-
IDataBlob_Resize(pDstJpegBits, mem_size);
276-
void* pDstPtr = IDataBlob_GetDataPtr(pDstJpegBits, 0);
275+
size_t dst_offset = IDataBlob_GetSize(pDstJpegBits);
276+
IDataBlob_Resize(pDstJpegBits, dst_offset + mem_size);
277+
void* pDstPtr = IDataBlob_GetDataPtr(pDstJpegBits, dst_offset);
277278
memcpy(pDstPtr, mem, mem_size);
278279

279280
/* After finish_compress, we can free memory buffer. */

0 commit comments

Comments
 (0)