Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-1 indices #85

Merged
merged 3 commits into from
Apr 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
julia 0.5
Compat 0.18.0
Compat 0.24
FixedPointNumbers 0.3.0
ColorTypes 0.2.7
Images 0.6
Expand Down
3 changes: 1 addition & 2 deletions src/ImageMagick.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ mapIM(x::Normed) = x
# Make the data contiguous in memory, this is necessary for
# imagemagick since it doesn't handle stride.
to_contiguous(A::Array) = A
to_contiguous(A::AbstractArray) = convert(Array, A)
to_contiguous(A::SubArray) = copy(A)
to_contiguous(A::AbstractArray) = Compat.collect(A)
to_contiguous(A::BitArray) = convert(Array{N0f8}, A)
to_contiguous(A::ColorView) = to_contiguous(channelview(A))

Expand Down
14 changes: 11 additions & 3 deletions test/constructed_images.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ImageMagick, ColorTypes, FixedPointNumbers, IndirectArrays, FileIO
using ImageMagick, ColorTypes, FixedPointNumbers, IndirectArrays, FileIO, OffsetArrays
using Images # for show(io, ::MIME, img) & ImageMeta
using Compat # for I/O redirection
using Base.Test
Expand Down Expand Up @@ -99,13 +99,13 @@ type TestType end
b = RGB(0,0,1)
w = RGB(1,1,1)
r = RGB(1,0,0)
cmaprgb = Array(RGB{Float64}, 255)
cmaprgb = Array{RGB{Float64}}(255)
f = linspace(0,1,128)
cmaprgb[1:128] = [(1-x)*b + x*w for x in f]
cmaprgb[129:end] = [(1-x)*w + x*r for x in f[2:end]]
img = IndirectArray(dataint, cmaprgb)
ImageMagick.save(joinpath(workdir,"cmap.jpg"), img)
cmaprgb = Array(RGB, 255) # poorly-typed cmap, issue #336
cmaprgb = Array{RGB}(255) # poorly-typed cmap, Images issue #336
cmaprgb[1:128] = [(1-x)*b + x*w for x in f]
cmaprgb[129:end] = [(1-x)*w + x*r for x in f[2:end]]
img = IndirectArray(dataint, cmaprgb)
Expand Down Expand Up @@ -268,6 +268,14 @@ type TestType end
imgr = ImageMagick.load(fn)
@test imgr == img
end

@testset "OffsetArrays" begin
img = OffsetArray([true false; false true], 0:1, 3:4)
fn = joinpath(workdir, "indices.png")
ImageMagick.save(fn, img)
imgr = ImageMagick.load(fn)
@test imgr == parent(img)
end
end

nothing
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ info("ImageMagick version ", ImageMagick.libversion)

include("constructed_images.jl")
include("readremote.jl")

workdir = joinpath(tempdir(), "Images")
try
rm(workdir, recursive=true)
end