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