Game Development Reference
In-Depth Information
086 //Get dest pixels
087 Color[] DestPixels = Dest.GetPixels();
088
089 for(int x=0; x<Source.width; x++)
090 {
091 for(int y=0; y<Source.height; y++)
092 {
093 //Get source pixel
094 Color Pixel = GetPixelFromArray(SourcePixels, x, y,
Source.width);
095
096 //Get offset in destination
097 int DestOffsetX = Left + x;
098 int DestOffsetY = Top + y;
099
100 if(DestOffsetX < Dest.width && DestOffsetY < Dest.height)
101 SetPixelInArray(DestPixels, DestOffsetX, DestOffsetY,
Dest.width, Pixel, true);
102 }
103 }
104
105 //Update destination texture
106 Dest.SetPixels(DestPixels);
107 Dest.Apply();
108 }
109 //-------------------------------------------------------
110 //Reads color from pixel array
111 public static Color GetPixelFromArray(Color[] Pixels,
int X, int Y, int Width)
112 {
113 return Pixels[X+Y*Width];
114 }
115 //------------------------------------------------
116 //Sets color in pixel array
117 public static void SetPixelInArray(Color[] Pixels, int
X, int Y, int Width, Color NewColor, bool Blending=false)
118 {
119 if(!Blending)
120 Pixels[X+Y*Width] = NewColor;
121 else
122 {
 
Search WWH ::




Custom Search