I would like to read pixel color from images. For example, I have a 64x64 resolution texture, I want to read the pixels from x=1,y=1 to x=64, y=64.
Thanks in advance!
I would like to read pixel color from images. For example, I have a 64x64 resolution texture, I want to read the pixels from x=1,y=1 to x=64, y=64.
Thanks in advance!
Can't say if this is the "best", but this is how I am doing it:
private Color[] m_Terrain;
private int m_TerrainWidth;
private int m_TerrainHeight;
Texture2D t = Resources.Load( "Textures/Terrain/terrain0" ) as Texture2D;
m_Terrain = t.GetPixels();
m_TerrainWidth = t.width;
m_TerrainHeight = t.height;
Color c = m_Terrain[h * m_TerrainWidth + w];
My texture is called "terrain0" and it is in the Resources/Textures/Terrain folder.
EDIT: Also be aware that in your example the first pixel is x=0,y=0 and the last pixel is x=63,y=63.