-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: use low level sixel_encode #2
Conversation
Codecov Report
@@ Coverage Diff @@
## jc/encoder #2 +/- ##
=============================================
- Coverage 2.91% 0.00% -2.92%
=============================================
Files 3 3
Lines 206 228 +22
=============================================
- Hits 6 0 -6
- Misses 200 228 +28
Continue to review full report at Codecov.
|
src/encoder.jl
Outdated
function SixelEncoder(io::IO, img::AbstractArray) | ||
allocator = SixelAllocator() | ||
|
||
colorbits = default_colorbits(img) | ||
pixelformat = default_pixelformat(img) | ||
io = maybe_convert(SixelIOBuffer, io) | ||
SixelEncoder(io, colorbits, pixelformat, allocator) | ||
end | ||
|
||
function sixel_write_callback_function(buffer_ptr::Ptr{Cchar}, sz::Cint, priv::Ref{T})::Cint where {T<:IO} | ||
io = unsafe_load(Base.unsafe_convert(Ptr{T}, priv)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! This io
is created by unsafe_load
which is a copy of the referenced value in the priv(a Ref
).
In fact, there is no need to do this unsafe_load
. priv
is already a Ref{IO}
type as we use the parametric type. So the body of this callback function should be:
unsafe_write(priv[], buffer_ptr, sz)
That's it. I'm sorry for the confusion.
Co-authored-by: Yupei Qi <[email protected]>
MWE is in
demo.jl
:cc: @Gnimuc