Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/decoding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,21 @@ function decode(
else
throw(ArgumentError("Unsupported color type: $TColor"))
end

bitstream_features = Ref{Wrapper.WebPBitstreamFeatures}()
# WebPGetFeatures is not available in libwebp dynamic library, but WebPGetFeaturesInternal is equivalent: https://github.com/webmproject/libwebp/blob/v1.4.0/src/webp/decode.h#L441
Wrapper.WebPGetFeaturesInternal(
pointer(data), length(data), bitstream_features, Wrapper.WEBP_DECODER_ABI_VERSION
)
width = Ref{Int32}(-1)
height = Ref{Int32}(-1)
if bitstream_features[].has_animation == 1
@warn("Animated WebP not supported")
WebPGetInfo(pointer(data), length(data), width, height)
image =
transpose ? ones(TColor, width[], height[]) : ones(TColor, height[], width[])
return image
end
decoded_data_ptr = webp_decode_fn(pointer(data), length(data), width, height)
decoded_data_size = (sizeof(TDecodedColor), Int(width[]), Int(height[]))
decoded_data = unsafe_wrap(Array{UInt8, 3}, decoded_data_ptr, decoded_data_size)
Expand Down
4 changes: 4 additions & 0 deletions test/decoding_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ using WebP
"5_webp_ll.webp" => (300, 300),
),
),
animation = (
url = "https://storage.googleapis.com/downloads.webmproject.org/webp/images/",
data = Dict("dancing_banana2.lossless.webp" => (1050, 990)),
),
)
for gallery in webp_galleries
for (filename, image_size) in gallery.data
Expand Down
Loading