38 lines
708 B
C#
38 lines
708 B
C#
using System.IO;
|
|
|
|
namespace Tga.Core
|
|
{
|
|
|
|
public class TGAHelper
|
|
{
|
|
|
|
#region Public Methods
|
|
|
|
public static byte[] SwapBGRAndRGB(byte[] buffer)
|
|
{
|
|
if (null == buffer)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
int size = buffer.Length;
|
|
|
|
using (MemoryStream mem = new MemoryStream())
|
|
{
|
|
for (int i = 0; i < size; i += 3)
|
|
{
|
|
mem.WriteByte(buffer[i + 2]);
|
|
mem.WriteByte(buffer[i + 1]);
|
|
mem.WriteByte(buffer[i + 0]);
|
|
}
|
|
return mem.ToArray();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|