Skip to content

Commit bc696f5

Browse files
authored
Merge pull request #11 from JuliaImages/imshow
bugfix imshow for non-colorant arrays. fixes #10
2 parents f83d17d + 4fb8964 commit bc696f5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/imshow.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ end
4848

4949
imshow(io::IO, img, args...) = imshow(io, img, colormode[1], args...)
5050
imshow(img, args...) = imshow(STDOUT, img, colormode[1], args...)
51+
imshow(io::IO, img, colordepth::TermColorDepth, args...) = throw(ArgumentError("imshow only supports colorant arrays with 1 or 2 dimensions"))
5152

5253
"""
5354
imshow256([stream], img, [maxsize])

test/tst_imshow.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
end
1111

1212
@testset "imshow" begin
13+
@testset "non colorant" begin
14+
@test_throws ArgumentError imshow(rand(5,5))
15+
@test_throws ArgumentError imshow(sprand(5,5,.5))
16+
end
1317
@testset "lena" begin
1418
img = imresize(lena, 10, 10)
1519
io = IOBuffer()
@@ -20,6 +24,10 @@ end
2024
end
2125

2226
@testset "imshow256" begin
27+
@testset "non colorant" begin
28+
@test_throws ArgumentError imshow256(rand(5,5))
29+
@test_throws ArgumentError imshow256(sprand(5,5,.5))
30+
end
2331
@testset "rgb line" begin
2432
io = IOBuffer()
2533
imshow256(io, rgb_line)
@@ -48,6 +56,10 @@ end
4856
end
4957

5058
@testset "imshow24bit" begin
59+
@testset "non colorant" begin
60+
@test_throws ArgumentError imshow24bit(rand(5,5))
61+
@test_throws ArgumentError imshow24bit(sprand(5,5,.5))
62+
end
5163
@testset "rgb line" begin
5264
io = IOBuffer()
5365
imshow24bit(io, rgb_line)

0 commit comments

Comments
 (0)