JuliaLang/Color.jl — pull request #63 by kmsquire (2014-09-17 21:51:02+00:00)
Title: Fixes conversion to/from Ufixed* types

* Previously, conversions were attempting to force conversion to, e.g., Lab{Ufixed8}, which is not a valid type.
* Conversions from `ColorValue{Ufixed}` types to abstract `ColorValue`s (i.e., without a specified type parameter) failed (these conversions are allowed from `ColorValue{FloatingPoint}` types)
* Some conversions from `ColorValue{Ufixed}` to `ColorValue{FloatingPoint}` did not round trip well (e.g., `RGB{Ufixed8}` -> `Lab{Float64}` -> `RGB{Ufixed8}`)
* Added tests.

Previously:

```julia
julia> img[1]
RGB{Ufixed8}(0.035,0.106,0.208)

julia> convert(Lab{Float64}, img[1])
Lab{Float64}(9.789275714438482,3.524345941228191,-19.242882752985235)

julia> convert(RGB{Ufixed8}, Lab{Float64}(9.789275714438482,3.524345941228191,-19.242882752985235))
RGB{Ufixed8}(0.031,0.114,0.208)

julia> # ^^^^^^^^^^^^^^^^^^^^ Inexact conversion on previous line

julia> convert(Lab, img[1])
ERROR: type: Lab: in T, expected T<:FloatingPoint, got Type{UfixedBase{Uint8,8}}
in convert at /home/kevin/.julia/v0.4/Color/src/conversions.jl:27
```

With this PR:
```julia
julia> convert(Lab, img[1])
Lab{Float64}(9.789275714438482,3.524345941228191,-19.242882752985235)

julia> convert(RGB{Ufixed8}, ans)
RGB{Ufixed8}(0.035,0.106,0.208)
```

While the behavior is obviously better, this may not be the right fix, so I would appreciate feedback.

Cc: @timholy