From 2cea47d9de3e50aec6b909c1f9723d82f43dc50c Mon Sep 17 00:00:00 2001 From: Tamas Nagy Date: Thu, 25 Feb 2021 14:15:58 -0800 Subject: [PATCH] remove type piracy fixes the issue brought up by @timholy in https://github.com/tlnagy/TiffImages.jl/pull/36#discussion_r583014076 --- src/files.jl | 3 ++- src/ifds.jl | 2 +- test/runtests.jl | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/files.jl b/src/files.jl index b9415406..fb5464ed 100644 --- a/src/files.jl +++ b/src/files.jl @@ -86,7 +86,7 @@ function Base.read!(file::TiffFile, arr::AbstractArray) end end -function Base.read!(io::IOStream, arr::SubArray{T,N,P,I,L}) where {T, N, P <: BitArray, I <: Tuple{UnitRange, Int64}, L} +function Base.read!(file::TiffFile, arr::SubArray{T,N,P,I,L}) where {T, N, P <: BitArray, I , L} error("Strided bilevel TIFFs are not yet supported. Please open an issue against TiffImages.jl.") end @@ -111,3 +111,4 @@ Base.seek(file::TiffFile, n::Integer) = seek(file.io, n) Base.bswap(x::Rational{T}) where {T} = Rational(bswap(x.num), bswap(x.den)) Base.IteratorSize(::TiffFile) = Base.SizeUnknown() +Base.eltype(::TiffFile{O}) where {O} = IFD{O} \ No newline at end of file diff --git a/src/ifds.jl b/src/ifds.jl index db149f5c..6598bc05 100644 --- a/src/ifds.jl +++ b/src/ifds.jl @@ -167,7 +167,7 @@ function Base.read!(target::AbstractArray{T, N}, tf::TiffFile, ifd::IFD) where { layout = output(ifd) rowsperstrip = layout.nrows - (ROWSPERSTRIP in keys(ifd)) && (rowsperstrip = ifd[ROWSPERSTRIP].data) + (ROWSPERSTRIP in ifd) && (rowsperstrip = ifd[ROWSPERSTRIP].data) nstrips = ceil(Int, layout.nrows / rowsperstrip) strip_nbytes = ifd[STRIPBYTECOUNTS].data diff --git a/test/runtests.jl b/test/runtests.jl index 8d8d02e9..35429683 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -65,6 +65,11 @@ end @test eltype(img) == Gray{Bool} end +@testset "Striped bilevel image" begin + filepath = get_example("capitol2.tif") + @test_throws ErrorException("Strided bilevel TIFFs are not yet supported. Please open an issue against TiffImages.jl.") TiffImages.load(filepath) +end + @testset "Signed integer type" begin filepath = get_example("4D-series.ome.tif") img = TiffImages.load(filepath)