Explorar el Código

HEIC: Fixed data copy when strides are mismatched.

Бранимир Караџић hace 1 año
padre
commit
59f188a6ad
Se han modificado 1 ficheros con 6 adiciones y 3 borrados
  1. 6 3
      src/image_decode.cpp

+ 6 - 3
src/image_decode.cpp

@@ -844,8 +844,8 @@ namespace bimg
 		heif_image* image;
 		heif_image* image;
 		heif_decode_image(handle, &image, heif_colorspace_RGB, heif_chroma_interleaved_RGBA, NULL);
 		heif_decode_image(handle, &image, heif_colorspace_RGB, heif_chroma_interleaved_RGBA, NULL);
 
 
-		int32_t stride;
-		const uint8_t* data = heif_image_get_plane_readonly(image, heif_channel_interleaved, &stride);
+		int32_t srcStride;
+		const uint8_t* data = heif_image_get_plane_readonly(image, heif_channel_interleaved, &srcStride);
 
 
 		ImageContainer* output = NULL;
 		ImageContainer* output = NULL;
 		if (NULL != data)
 		if (NULL != data)
@@ -853,6 +853,7 @@ namespace bimg
 			const bimg::TextureFormat::Enum format = bimg::TextureFormat::RGBA8;
 			const bimg::TextureFormat::Enum format = bimg::TextureFormat::RGBA8;
 			const int32_t width  = heif_image_handle_get_width(handle);
 			const int32_t width  = heif_image_handle_get_width(handle);
 			const int32_t height = heif_image_handle_get_height(handle);
 			const int32_t height = heif_image_handle_get_height(handle);
+			const int32_t dstStride = width*4;
 
 
 			output = imageAlloc(_allocator
 			output = imageAlloc(_allocator
 				, format
 				, format
@@ -862,8 +863,10 @@ namespace bimg
 				, 1
 				, 1
 				, false
 				, false
 				, false
 				, false
-				, data
+				, NULL
 				);
 				);
+
+			bx::memCopy(output->m_data, dstStride, data, srcStride, dstStride, height);
 		}
 		}
 
 
 		heif_image_release(image);
 		heif_image_release(image);