Assert that pixel data is encoded

This commit is contained in:
Nils Dagsson Moskopp 2022-05-16 03:21:52 +02:00
parent 7b94fc026d
commit 1f9c446a98
No known key found for this signature in database
GPG Key ID: A3BC671C35191080

@ -76,6 +76,7 @@ function image:encode_data(properties)
local color_format = properties.color_format local color_format = properties.color_format
local compression = properties.compression local compression = properties.compression
local data_length_before = #self.data
if "Y8" == color_format and "RAW" == compression then if "Y8" == color_format and "RAW" == compression then
if 8 == self.pixel_depth then if 8 == self.pixel_depth then
self:encode_data_Y8_as_Y8_raw() self:encode_data_Y8_as_Y8_raw()
@ -99,6 +100,11 @@ function image:encode_data(properties)
self:encode_data_R8G8B8A8_as_B8G8R8A8_raw() self:encode_data_R8G8B8A8_as_B8G8R8A8_raw()
end end
end end
local data_length_after = #self.data
assert(
data_length_after ~= data_length_before,
"No data encoded for color format: " .. color_format
)
end end
function image:encode_data_Y8_as_Y8_raw() function image:encode_data_Y8_as_Y8_raw()