it could be faster also, to store values of the same pixel consecutively in memory, considering locality of reference (CPU cache).