Well sorry I did a mistake somewhere, it's totally my bad. I was expecting that:
buffer[4*(i+j*width)+0]=R;
buffer[4*(i+j*width)+1]=G;
buffer[4*(i+j*width)+2]=B;
buffer[4*(i+j*width)+3]=A;
(for a pixel buffer to load with image.create())
Was the same as
uintbuffer[i+j*width]=RGBA; // RGBA = 0xff0000ff for a red color for example
But for some reason it's reversed (some endianness thing ?), I need to write the int in ABGR format to get the correct color once loaded with image.create()