Colour Cube: Difference between revisions

Replaced references to "32" with m_size
(Added information about the Xbox 360 swizzle algorithm)
(Replaced references to "32" with m_size)
Line 33:
 
= Xbox 360 Swizzle Algorithm =
The following algorithm assumes that the data is stored and accessed as m_size cubes, each 32x32m_size*m_size pixels, oriented left to right with an m_size*32m_size*3 bytes stride, rather than as m_size cubes oriented top to bottom with a 32m_size*3 bytes stride (i.e. only one cube's data per line). Regardless of which is true, it seems that the following algorithm works to produce exact conversions from Xbox 360 colourcubes to PC colourcubes.
 
With the above in mind, to find the 3-byte (R, G and B) pixel data for position (x,y) in the PC m_pixels data, 3 bytes (R, G and B) can be read from the Xbox 360 m_pixels data at the offset calculated as follows where x and y are represented as a number of bits, x0 to x9 (values 0-1023m_size*m_size) and y0 to y4 (values 0-31m_size).
 
{| class="wikitable"
Line 109:
# now, convert the m_pixels data
data="".b
32m_size.times do |y|
(m_size *32 m_size).times do |x|
offset = calc_offset(x, y)
pixel_data = m_pixels[offset.pixels...(offset + 1).pixels]
6

edits