How to show Matrix{RGB} on Cairo surface?

Cairo provides read_from_png, but returns value of a special type CairoSurfaceBase, which is hard to operate, so I choose Matrix{RGB}(the thing ImageIO returns).
Cairo does provide something called set_matrix, but the second argument must be of typeCairoMatrix. There aren’t any documents on this, so I can’t figure out a way to convert between CairoMatrix and Matrix{RGB}. Or, more importantly, I want to show the Matrix{RGB}.

sync:stackoverflow

CairoSurfaceImage surface can be created from a Matrix{T} with T from Uint32, RGB24 and ARGB32, you need to convert from Matrix{RGB}.

Thanks, but when I tried

julia> mat=FileIO.load("flag.png");nothing

julia> m2=Matrix{RGB24}(undef,32,32);nothing

julia> for i in 1:32
               for j in 1:32
                   m2[i,j]=RGB24(mat[i,j])
               end
           end

ctx=CairoImageSurface(m2)
Cairo.CairoSurfaceImage{RGB24}(Ptr{Nothing} @0x00...

julia> write_to_png(ctx,"D:/foo.png")

I found that the image has been reflected
original:
flag
foo.png:
foo

A simple solution is to use =mat[j,i]
but is this normal? Is it that developers are thinking differntly?

Most bitmaps in graphics are row-first i.e. consecutive pixels in x-axis.