Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Commit

Permalink
make it backwards compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Feb 7, 2017
1 parent dd867a0 commit 26b3481
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
11 changes: 9 additions & 2 deletions examples/gui/image_processing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ racoon = loadasset("racoon.png")
img = convert(Matrix{RGBA{Float32}}, racoon)

# create a slider that goes from 1-20 in 0.1 steps
slider, slider_s = widget(Signal(1f0), range=1f0:0.1f0:20f0, window)

slider, slider_s = widget(Signal(1f0), range = 1f0:0.1f0:20f0, window)

if !isdefined(:clamp01)
function clamp01(color)
mapc(color) do c
clamp(c, 0, 1)
end
end
end
"""
Applies a gaussian filter to `img` and converts it to RGBA{N0f8}
"""
Expand Down
14 changes: 13 additions & 1 deletion examples/imagelike/imageio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,25 @@ arrays = map((RGBA{N0f8}, RGBA{Float32}, RGB{N0f8}, RGB{Float32}, BGRA{N0f8}, BG
loaded_imgs = map(x->loadasset("test_images", x), readdir(assetpath("test_images")))

# combine them all into one array and add an animated gif and a few other images

# backward compatible imconvert
imconvert(im) = im
if isdefined(:Image)
function imconvert(im::Image)
if ndims(im) == 2
convert(Array{eltype(im), ndims(im)}, im)
else
permutedims(im.data, (2, 1, 3))
end
end
end
x = Any[
arrays..., loaded_imgs...,
loadasset("kittens-look.gif"),
loadasset("mario", "stand", "right.png"),
loadasset("mario", "jump", "left.gif"),
]
x = map(x-> convert(Array{eltype(x), ndims(x)}, x), x)
x = map(imconvert, x)

# visualize all images and convert the array to be a vector of element type context
# This shouldn't be necessary, but it seems map is not able to infer the type alone
Expand Down
2 changes: 1 addition & 1 deletion examples/interactive/mario_game.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ for verb in ["jump", "walk", "stand"], dir in ["left", "right"]
end
path = assetpath("mario", verb, pic)
sequence = read_sequence(path)
gif = map(img->map(RGBA{N0f8}, img), sequence)
gif = map(img->convert(Matrix{RGBA{N0f8}}, img), sequence)
mario_images[verb*dir] = play(gif)
end
function mario2image(mario, images=mario_images)
Expand Down

0 comments on commit 26b3481

Please sign in to comment.