J Luis, you probably want to reinterpret it as RGBA{Ufixed8}, from the Color 
package. Images already handles the "result shape not specified error", if you 
want to try that (just say "using Images" first).

Simon, the RGB24 you defined is redundant with RGBA{Ufixed8} or ABGR{Ufixed8} 
depending on the endianness of the host machine. The RGB24 type was created 
specifically to give "meaning" to UInt32s, which is what the Cairo.jl package 
uses, with consistent endianness interpretation (in agreement with Stefan's 
code example).

Images contains quite a number of color types and operations not defined in 
Color.jl; if you're needing more too, I should finally get around to folding 
these back in to Color.

Best,
--Tim

On Saturday, March 28, 2015 02:25:39 AM Simon Danisch wrote:
> I have a similar problem and I was wondering how to solve it best.
> Look at RGB24, which is probably pretty much the type you want.
> SimonDanisch/ColorTypes.jl/src/types.jl#L218
> I copied that from Color.jl, and was wondering why it isn't defined as:
> immutable RGB24
> r::Uint8
> g::Uint8
> b::Uint8
> a::Uint8
> end
> Which could be reinterpreted as Uint32 if needed for a ccall, but inside of
> Julia it would be a lot easier to handle.
> From your example it looks like you have a matrix of the shape (x, 4),
> which is a little annoying, as this means that you can't just reinterpret
> the array.
> You have to juggle around with the dimensions to get the color dimension in
> the first position.
> Specifying the shape is pretty easy, in your case it'd be
> reinterpret(Uint32, Uint8[1 2 3 255], (1,)) as the resulting array should
> have the size (1,).
> 
> Am Samstag, 28. März 2015 02:04:35 UTC+1 schrieb J Luis:
> > Hi,
> > 
> > How can I encode  4 one byte variable, lets say
> > 
> > julia> UInt8[1 2 5 255]
> > 
> > 1x4 Array{UInt8,2}:
> >  0x01  0x02  0x05  0xff
> > 
> > into a single variable with 4 bytes length?
> > 
> > Thanks.

Reply via email to