Skip to content

Commit

Permalink
remove type piracy
Browse files Browse the repository at this point in the history
fixes the issue brought up by @timholy in #36 (comment)
  • Loading branch information
tlnagy committed Mar 1, 2021
1 parent 2ad86b3 commit 2cea47d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}
2 changes: 1 addition & 1 deletion src/ifds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2cea47d

Please sign in to comment.