From b21818cbe836d772be5d259cd07ed24a0279e403 Mon Sep 17 00:00:00 2001 From: Christopher Burns Date: Thu, 11 Apr 2024 11:49:49 -0500 Subject: [PATCH] fixup! feedback --- src/types/common.jl | 12 +++++++----- src/types/widepixel.jl | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/types/common.jl b/src/types/common.jl index 9643555..a3af4f9 100644 --- a/src/types/common.jl +++ b/src/types/common.jl @@ -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) @@ -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) diff --git a/src/types/widepixel.jl b/src/types/widepixel.jl index d9da226..9288bd8 100644 --- a/src/types/widepixel.jl +++ b/src/types/widepixel.jl @@ -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 \ No newline at end of file