Skip to content

Commit

Permalink
fixup! feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstphrbrns committed Apr 11, 2024
1 parent 3d89fd2 commit b21818c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/types/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ julia> eltype(color(img; alpha=4)) # use the fourth channel as an alpha channel
RGBA{Float32}
```
"""
function color(img::AbstractTIFF{<: WidePixel{C, X}}; alpha::Union{Nothing, Integer}=nothing) where {C, X}
alpha == nothing ? color.(img) : ColorTypes.coloralpha(C).(ColorTypes.color.(color.(img)), channel.(img, alpha))
end
color(img::AbstractTIFF{<: WidePixel}; alpha::Union{Nothing, Integer}=nothing) = color.(img; alpha)

"""
color(img::AbstractTIFF)
Expand All @@ -122,11 +120,15 @@ This is an identity relation that just returns `img`
color(img::AbstractTIFF) = img

"""
color(x::WidePixel)
color(x::WidePixel; alpha)
Return the value of the `color` field of `x`
The optional `alpha` parameter allows an arbitrary channel to be used as the alpha channel
"""
color(x::WidePixel) = x.color
function color(x::WidePixel{C, X}; alpha::Union{Nothing, Integer}=nothing) where {C, X}
alpha == nothing ? x.color : ColorTypes.coloralpha(C)(ColorTypes.color(x.color), channel(x, alpha))
end

"""
color(x::Colorant)
Expand Down
3 changes: 2 additions & 1 deletion src/types/widepixel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function Base.show(io::IO, x::WidePixel{C,X}) where {C, X}
if get(io, :compact, false)
print(io, "WidePixel($(x.color))")
else
print(io, "WidePixel($(x.color)) + $(length(x.extra)) extra channels")
len = length(x.extra)
print(io, "WidePixel($(x.color)) + $len extra channel$(len > 1 ? "s" : "")")
end
end

0 comments on commit b21818c

Please sign in to comment.