Skip to content

Commit

Permalink
use reinterpret(UInt8, buf)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Nov 29, 2023
1 parent 5ff5d8a commit 353e578
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function _load(png_ptr, info_ptr; gamma::Union{Nothing,Float64}=nothing, expand_
end

function _load!(buffer::Matrix{T}, png_ptr, info_ptr) where T # separate to support precompilation of permutedims
png_read_image(png_ptr, map(pointer, eachcol(rawview(channelview(buffer)))))
png_read_image(png_ptr, map(pointer, eachcol(reinterpret(UInt8, buffer))))
png_read_end(png_ptr, info_ptr)
png_destroy_read_struct(Ref{Ptr{Cvoid}}(png_ptr), Ref{Ptr{Cvoid}}(info_ptr), C_NULL)
return permutedims(buffer, (2, 1))
Expand Down Expand Up @@ -522,7 +522,7 @@ function _write_image(buf::AbstractArray{T,2}, png_ptr::Ptr{Cvoid}, info_ptr::Pt
Cvoid,
(Ptr{Cvoid}, Ptr{Ptr{T}}),
png_ptr,
map(pointer, eachcol(rawview(channelview(buf)))),
map(pointer, eachcol(reinterpret(UInt8, buf))),
)
end
png_write_end(png_ptr, info_ptr)
Expand Down

0 comments on commit 353e578

Please sign in to comment.