algorith LZX's variation?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Marcoto
    New Member
    • Apr 2010
    • 7

    algorith LZX's variation?

    Hello, I would like to know if someone can help me to do a bookshop for unpack a few files of textures or at least, that it(he,she) throws a bit of light and indicates me like to begin.
    Pardon for the translations of goolge, they are pernicious...
    4 bytes - Magic ('RSC')
    4 bytes - Type (version - textures has "7")
    4 bytes - Flags
    From 'flags' value can be calculated sizes of SysSegment and GpuSegment of unpacked data.
    Delphi:
    Code:
    CpuSegSiz := (flags and $7FF) shl (((flags shr 11) and $F) + 8);
      GpuSegSiz := ((flags shr 15) and $7FF) shl (((flags shr 26) and $F) +  8);
    C#:
    Code:
    uint systemSegSize = (flags & 0x7FF) << (((flags >> 11)  & 0xF) + 8);
    uint gpuSegSize = ((flags >> 15) & 0x7FF)  << (((flags >> 26) & 0xF) + 8);
    . Here it is archive which includes three examples of texture RSC.

    I believe that the compression is LZX's variation.
    Thanks
  • Marcoto
    New Member
    • Apr 2010
    • 7

    #2
    So... I do not understand what it wants to say...
    Nevertheless, you are moderating, it moves or delete the post because really I do not understand what it wants to say. The translator is not very good.

    Edit:OH I am sorry, now I realize that it is repeated. Do not be since it has happenedand I do not know like edit it and erase it.
    I am sorry, it will not return to happen.
    Last edited by Marcoto; Apr 1 '10, 03:56 PM. Reason: Sorry

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      You are using a translation software? That would explain why your question is unclear. I guess I didn't read that in your original post.

      I do not understand your words "bookshop". I think I understand what "unpack a few files" means but I do not understand "throws a bit of light and indicates me like to begin". I think you mean "shed a little light on my question and help me understand how to begin" but I am not sure.

      That website address is a link to a "rar" of textures? What do you want to do with it? Decompress it into something that you can use?

      What exactly is your question?

      Comment

      • Marcoto
        New Member
        • Apr 2010
        • 7

        #4
        "throws a bit of light and indicates me like to begin" Yes, I believe that it is it what I want to say
        "bookshop"=Libr ary?,Dll?
        The link is a "rar" of the files that I want to open or unpak, the format is .XTD.
        They are textures of a game, attempt to open them and to change them into my textures for personal use but only I know of code what I have written.
        If it is out of the procedure of the forum since the post resigns and I sit it (Sorry?)

        Comment

        • RedSon
          Recognized Expert Expert
          • Jan 2007
          • 4980

          #5
          You can try one of these tools:

          Comment

          • Marcoto
            New Member
            • Apr 2010
            • 7

            #6
            Already I have proved all. None they open it. Only they open the format .WTD and not the format .XTD because of it I asked it of the algorithm because I have seen in sites that they could have opened by the codes that exist post doing a library in C# but nobody says anything to me. Well, do not worry for the post thank you anyhow.
            ( Probably do not answer because with the translator they do not understand what I want to say...)

            Comment

            • RedSon
              Recognized Expert Expert
              • Jan 2007
              • 4980

              #7
              I get what you want. I don't think it is possible. The game makers intentionally make it difficult for you to steal their game resources. Even games that are defunct are difficult. You would need their proprietary tools to open the files.

              Comment

              • Marcoto
                New Member
                • Apr 2010
                • 7

                #8
                In a forum I found a person who managed to open the file and in a little time with the information that I put but to disappear of the forum and it does not answer to the message that I sent. There will be people who him is easy and other one that him is difficult according to the custom that has of working with this type of things.
                It has to be difficult enough.
                In addition, do not worry, thank you for your help, I do not want to seem to be heavy and you prop, this post always is above and probably not this giving the opportunity to other user's to expose his problems.
                Quote from AnthonyFiveSixT wo:
                "Well today I got around to looking at the xtd files that were posted and I was able to decompress them. I will make a tool to do it later on once we get a bit more info on the actual format of the decompressed data.
                Im kinda tired right now but maybe tomorrow ill post some more info."

                I repeat: I am sorry to entertain him so much with this topic

                Comment

                • RedSon
                  Recognized Expert Expert
                  • Jan 2007
                  • 4980

                  #9
                  Hopefully AnthonyFiveSixT wo will be able to help you then.

                  Comment

                  • Marcoto
                    New Member
                    • Apr 2010
                    • 7

                    #10
                    Impossible already, the post is of August, 2009... Llebo enough time looking now that I realize...

                    Comment

                    • Marcoto
                      New Member
                      • Apr 2010
                      • 7

                      #11
                      Sorry double post, i can“t edit it.
                      I have found this in code of a program that serves to open .WTD but that originally was opening .XTD. Archives are in Big endian
                      Will it use me as something?
                      It is that have a lot of time looking for the way of opening the files and if the codes serve me, I itself will try to learn to programme though almost all the tutorials are in English...
                      I sit such a long post.
                      Code:
                      using System.IO;
                      
                      namespace RageLib.Common.Resources
                      {
                          internal class ResourceHeader
                          {
                              private const uint MagicBigEndian = 0x52534305;
                              public const uint MagicValue = 0x05435352;
                      
                              public uint Magic { get; set; }
                              public ResourceType Type { get; set; }
                              public uint Flags { get; set; }
                              public CompressionType CompressCodec { get; set; }
                      
                              public int GetSystemMemSize()
                              {
                                  return (int)(Flags & 0x7FF) << (int)(((Flags >> 11) & 0xF) + 8);
                              }
                      
                              public int GetGraphicsMemSize()
                              {
                                  return (int)((Flags >> 15) & 0x7FF) << (int)(((Flags >> 26) & 0xF) + 8);
                              }
                      
                              public void SetMemSizes(int systemMemSize, int graphicsMemSize)
                              {
                                  // gfx = a << (b + 8)
                                  // minimum representable is block of 0x100 bytes
                      
                                  const int maxA = 0x3F;
                      
                                  int sysA = systemMemSize >> 8;
                                  int sysB = 0;
                      
                                  while(sysA > maxA)
                                  {
                                      if ((sysA & 1) != 0)
                                      {
                                          sysA += 2;
                                      }
                                      sysA >>= 1;
                                      sysB++;
                                  }
                      
                                  int gfxA = graphicsMemSize >> 8;
                                  int gfxB = 0;
                      
                                  while (gfxA > maxA)
                                  {
                                      if ((gfxA & 1) != 0)
                                      {
                                          gfxA += 2;
                                      }
                                      gfxA >>= 1;
                                      gfxB++;
                                  }
                                 
                                  Flags = (Flags & 0xC0000000) | (uint)(sysA | (sysB << 11) | (gfxA << 15) | (gfxB << 26));
                              }
                      
                              public void Read(BinaryReader br)
                              {
                                  Magic = br.ReadUInt32();
                                  Type = (ResourceType) br.ReadUInt32();
                                  Flags = br.ReadUInt32();
                                  CompressCodec = (CompressionType)br.ReadUInt16();
                      
                                  if (Magic == MagicBigEndian)
                                  {
                                      Magic = DataUtil.SwapEndian(Magic);
                                      Type = (ResourceType)DataUtil.SwapEndian((uint)Type);
                                      Flags = DataUtil.SwapEndian(Flags);
                                  }
                              }
                      
                              public void Write(BinaryWriter bw)
                              {
                                  bw.Write( MagicValue );
                                  bw.Write( (uint)Type );
                                  bw.Write( Flags );
                                  bw.Write( (ushort)CompressCodec );
                              }
                          }
                      }
                      Code:
                      using System.Reflection;
                      
                      namespace RageLib.Common.Resources
                      {
                          [Obfuscation(StripAfterObfuscation = true, ApplyToMembers = true, Exclude = true)]
                          public enum ResourceType
                          {
                              TextureXBOX = 0x7, // xtd
                              ModelXBOX = 0x6D, // xdr
                              Generic = 0x01, // xhm / xad (Generic files as rsc?)
                              Bounds = 0x20, // xbd, wbd
                              Particles = 0x24, // xpfl
                              Particles2 = 0x1B, // xpfl
                      
                              Texture = 0x8, // wtd
                              Model = 0x6E, // wdr
                              ModelFrag = 0x70, //wft
                      Code:
                      // Uncomment the following line to get this Decoder to work for XBOX360 DXT Encoded files
                      // Note that the data has to be untiled before running the decoder on it
                      
                      //#define XBOX360
                      
                      using System;
                      
                      namespace RageLib.Textures.Decoder
                      {
                          internal static class DXTDecoder
                          {
                              internal static byte[] DecodeDXT1(byte[] data, int width, int height)
                              {
                                  byte[] pixData = new byte[width * height * 4];
                                  int xBlocks = width / 4;
                                  int yBlocks = height / 4;
                                  for (int y = 0; y < yBlocks; y++)
                                  {
                                      for (int x = 0; x < xBlocks; x++)
                                      {
                                          int blockDataStart = ((y * xBlocks) + x) * 8;
                      
                      #if XBOX360
                                          uint color0 = ((uint)data[blockDataStart + 0] << 8) + data[blockDataStart + 1];
                                          uint color1 = ((uint)data[blockDataStart + 2] << 8) + data[blockDataStart + 3];
                      #else
                                          uint color0 = BitConverter.ToUInt16(data, blockDataStart);
                                          uint color1 = BitConverter.ToUInt16(data, blockDataStart + 2);
                      #endif
                      
                                          uint code = BitConverter.ToUInt32(data, blockDataStart + 4);
                      
                                          ushort r0 = 0, g0 = 0, b0 = 0, r1 = 0, g1 = 0, b1 = 0;
                                          r0 = (ushort)(8 * (color0 & 31));
                                          g0 = (ushort)(4 * ((color0 >> 5) & 63));
                                          b0 = (ushort)(8 * ((color0 >> 11) & 31));
                      
                                          r1 = (ushort)(8 * (color1 & 31));
                                          g1 = (ushort)(4 * ((color1 >> 5) & 63));
                                          b1 = (ushort)(8 * ((color1 >> 11) & 31));
                      
                                          for (int k = 0; k < 4; k++)
                                          {
                      #if XBOX360
                                              int j = k ^ 1;
                      #else
                                              int j = k;
                      #endif
                      
                                              for (int i = 0; i < 4; i++)
                                              {
                                                  int pixDataStart = (width * (y * 4 + j) * 4) + ((x * 4 + i) * 4);
                                                  uint codeDec = code & 0x3;
                      
                                                  switch (codeDec)
                                                  {
                                                      case 0:
                                                          pixData[pixDataStart + 0] = (byte)r0;
                                                          pixData[pixDataStart + 1] = (byte)g0;
                                                          pixData[pixDataStart + 2] = (byte)b0;
                                                          pixData[pixDataStart + 3] = 255;
                                                          break;
                                                      case 1:
                                                          pixData[pixDataStart + 0] = (byte)r1;
                                                          pixData[pixDataStart + 1] = (byte)g1;
                                                          pixData[pixDataStart + 2] = (byte)b1;
                                                          pixData[pixDataStart + 3] = 255;
                                                          break;
                                                      case 2:
                                                          pixData[pixDataStart + 3] = 255;
                                                          if (color0 > color1)
                                                          {
                                                              pixData[pixDataStart + 0] = (byte)((2 * r0 + r1) / 3);
                                                              pixData[pixDataStart + 1] = (byte)((2 * g0 + g1) / 3);
                                                              pixData[pixDataStart + 2] = (byte)((2 * b0 + b1) / 3);
                                                          }
                                                          else
                                                          {
                                                              pixData[pixDataStart + 0] = (byte)((r0 + r1) / 2);
                                                              pixData[pixDataStart + 1] = (byte)((g0 + g1) / 2);
                                                              pixData[pixDataStart + 2] = (byte)((b0 + b1) / 2);
                                                          }
                                                          break;
                                                      case 3:
                                                          if (color0 > color1)
                                                          {
                                                              pixData[pixDataStart + 0] = (byte)((r0 + 2 * r1) / 3);
                                                              pixData[pixDataStart + 1] = (byte)((g0 + 2 * g1) / 3);
                                                              pixData[pixDataStart + 2] = (byte)((b0 + 2 * b1) / 3);
                                                              pixData[pixDataStart + 3] = 255;
                                                          }
                                                          else
                                                          {
                                                              pixData[pixDataStart + 0] = 0;
                                                              pixData[pixDataStart + 1] = 0;
                                                              pixData[pixDataStart + 2] = 0;
                                                              pixData[pixDataStart + 3] = 0;
                                                          }
                                                          break;
                                                  }
                      
                                                  code >>= 2;
                                              }
                                          }
                      
                      
                                      }
                                  }
                                  return pixData;
                              }
                      
                              internal static byte[] DecodeDXT3(byte[] data, int width, int height)
                              {
                                  byte[] pixData = new byte[width * height * 4];
                                  int xBlocks = width / 4;
                                  int yBlocks = height / 4;
                                  for (int y = 0; y < yBlocks; y++)
                                  {
                                      for (int x = 0; x < xBlocks; x++)
                                      {
                                          int blockDataStart = ((y * xBlocks) + x) * 16;
                                          ushort[] alphaData = new ushort[4];
                                         
                      #if XBOX360
                                          alphaData[0] = (ushort)((data[blockDataStart + 0] << 8) + data[blockDataStart + 1]);
                                          alphaData[1] = (ushort)((data[blockDataStart + 2] << 8) + data[blockDataStart + 3]);
                                          alphaData[2] = (ushort)((data[blockDataStart + 4] << 8) + data[blockDataStart + 5]);
                                          alphaData[3] = (ushort)((data[blockDataStart + 6] << 8) + data[blockDataStart + 7]);
                      #else
                                          alphaData[0] = BitConverter.ToUInt16(data, blockDataStart + 0);
                                          alphaData[1] = BitConverter.ToUInt16(data, blockDataStart + 2);
                                          alphaData[2] = BitConverter.ToUInt16(data, blockDataStart + 4);
                                          alphaData[3] = BitConverter.ToUInt16(data, blockDataStart + 6);
                      #endif
                      
                                          byte[,] alpha = new byte[4, 4];
                                          for (int j = 0; j < 4; j++)
                                          {
                                              for (int i = 0; i < 4; i++)
                                              {
                                                  alpha[i, j] = (byte)((alphaData[j] & 0xF) * 16);
                                                  alphaData[j] >>= 4;
                                              }
                                          }
                      
                      #if XBOX360
                                          ushort color0 = (ushort)((data[blockDataStart + 8] << 8) + data[blockDataStart + 9]);
                                          ushort color1 = (ushort)((data[blockDataStart + 10] << 8) + data[blockDataStart + 11]);
                      #else
                                          ushort color0 = BitConverter.ToUInt16(data, blockDataStart + 8);
                                          ushort color1 = BitConverter.ToUInt16(data, blockDataStart + 8 + 2);
                      #endif
                      
                                          uint code = BitConverter.ToUInt32(data, blockDataStart + 8 + 4);
                      
                                          ushort r0 = 0, g0 = 0, b0 = 0, r1 = 0, g1 = 0, b1 = 0;
                                          r0 = (ushort)(8 * (color0 & 31));
                                          g0 = (ushort)(4 * ((color0 >> 5) & 63));
                                          b0 = (ushort)(8 * ((color0 >> 11) & 31));
                      
                                          r1 = (ushort)(8 * (color1 & 31));
                                          g1 = (ushort)(4 * ((color1 >> 5) & 63));
                                          b1 = (ushort)(8 * ((color1 >> 11) & 31));
                      
                                          for (int k = 0; k < 4; k++)
                                          {
                      #if XBOX360
                                              int j = k ^ 1;
                      #else
                                              int j = k;
                      #endif
                                             
                                              for (int i = 0; i < 4; i++)
                                              {
                                                  int pixDataStart = (width * (y * 4 + j) * 4) + ((x * 4 + i) * 4);
                                                  uint codeDec = code & 0x3;
                      
                                                  pixData[pixDataStart + 3] = alpha[i, j];
                      
                                                  switch (codeDec)
                                                  {
                                                      case 0:
                                                          pixData[pixDataStart + 0] = (byte)r0;
                                                          pixData[pixDataStart + 1] = (byte)g0;
                                                          pixData[pixDataStart + 2] = (byte)b0;
                                                          break;
                                                      case 1:
                                                          pixData[pixDataStart + 0] = (byte)r1;
                                                          pixData[pixDataStart + 1] = (byte)g1;
                                                          pixData[pixDataStart + 2] = (byte)b1;
                                                          break;
                                                      case 2:
                                                          if (color0 > color1)
                                                          {
                                                              pixData[pixDataStart + 0] = (byte)((2 * r0 + r1) / 3);
                                                              pixData[pixDataStart + 1] = (byte)((2 * g0 + g1) / 3);
                                                              pixData[pixDataStart + 2] = (byte)((2 * b0 + b1) / 3);
                                                          }
                                                          else
                                                          {
                                                              pixData[pixDataStart + 0] = (byte)((r0 + r1) / 2);
                                                              pixData[pixDataStart + 1] = (byte)((g0 + g1) / 2);
                                                              pixData[pixDataStart + 2] = (byte)((b0 + b1) / 2);
                                                          }
                                                          break;
                                                      case 3:
                                                          if (color0 > color1)
                                                          {
                                                              pixData[pixDataStart + 0] = (byte)((r0 + 2 * r1) / 3);
                                                              pixData[pixDataStart + 1] = (byte)((g0 + 2 * g1) / 3);
                                                              pixData[pixDataStart + 2] = (byte)((b0 + 2 * b1) / 3);
                                                          }
                                                          else
                                                          {
                                                              pixData[pixDataStart + 0] = 0;
                                                              pixData[pixDataStart + 1] = 0;
                                                              pixData[pixDataStart + 2] = 0;
                                                          }
                                                          break;
                                                  }
                      
                                                  code >>= 2;
                                              }
                                          }
                      
                      
                                      }
                                  }
                                  return pixData;
                              }
                      
                              internal static byte[] DecodeDXT5(byte[] data, int width, int height)
                              {
                                  byte[] pixData = new byte[width * height * 4];
                                  int xBlocks = width / 4;
                                  int yBlocks = height / 4;
                                  for (int y = 0; y < yBlocks; y++)
                                  {
                                      for (int x = 0; x < xBlocks; x++)
                                      {
                                          int blockDataStart = ((y * xBlocks) + x) * 16;
                                          uint[] alphas = new uint[8];
                                          ulong alphaMask = 0;
                      
                      #if XBOX360
                      
                                          alphas[0] = data[blockDataStart + 1];
                                          alphas[1] = data[blockDataStart + 0];
                      
                                          alphaMask |= data[blockDataStart + 6];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 7];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 4];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 5];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 2];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 3];
                      
                      #else
                      
                                          alphas[0] = data[blockDataStart + 0];
                                          alphas[1] = data[blockDataStart + 1];
                      
                                          alphaMask |= data[blockDataStart + 7];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 6];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 5];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 4];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 3];
                                          alphaMask <<= 8;
                                          alphaMask |= data[blockDataStart + 2];
                      
                      #endif
                      
                                          // 8-alpha or 6-alpha block
                                          if (alphas[0] > alphas[1])
                                          {
                                              // 8-alpha block: derive the other 6
                                              // Bit code 000 = alpha_0, 001 = alpha_1, others are interpolated.
                                              alphas[2] = (byte)((6 * alphas[0] + 1 * alphas[1] + 3) / 7);    // bit code 010
                                              alphas[3] = (byte)((5 * alphas[0] + 2 * alphas[1] + 3) / 7);    // bit code 011
                                              alphas[4] = (byte)((4 * alphas[0] + 3 * alphas[1] + 3) / 7);    // bit code 100
                                              alphas[5] = (byte)((3 * alphas[0] + 4 * alphas[1] + 3) / 7);    // bit code 101
                                              alphas[6] = (byte)((2 * alphas[0] + 5 * alphas[1] + 3) / 7);    // bit code 110
                                              alphas[7] = (byte)((1 * alphas[0] + 6 * alphas[1] + 3) / 7);    // bit code 111
                                          }
                                          else
                                          {
                                              // 6-alpha block.
                                              // Bit code 000 = alpha_0, 001 = alpha_1, others are interpolated.
                                              alphas[2] = (byte)((4 * alphas[0] + 1 * alphas[1] + 2) / 5);    // Bit code 010
                                              alphas[3] = (byte)((3 * alphas[0] + 2 * alphas[1] + 2) / 5);    // Bit code 011
                                              alphas[4] = (byte)((2 * alphas[0] + 3 * alphas[1] + 2) / 5);    // Bit code 100
                                              alphas[5] = (byte)((1 * alphas[0] + 4 * alphas[1] + 2) / 5);    // Bit code 101
                                              alphas[6] = 0x00;                                               // Bit code 110
                                              alphas[7] = 0xFF;                                               // Bit code 111
                                          }
                      
                                          byte[,] alpha = new byte[4, 4];
                      
                                          for (int i = 0; i < 4; i++)
                                          {
                                              for (int j = 0; j < 4; j++)
                                              {
                                                  alpha[j, i] = (byte)alphas[alphaMask & 7];
                                                  alphaMask >>= 3;
                                              }
                                          }
                      
                      #if XBOX360
                                          ushort color0 = (ushort)((data[blockDataStart + 8] << 8) + data[blockDataStart + 9]);
                                          ushort color1 = (ushort)((data[blockDataStart + 10] << 8) + data[blockDataStart + 11]);
                      #else
                                          ushort color0 = BitConverter.ToUInt16(data, blockDataStart + 8);
                                          ushort color1 = BitConverter.ToUInt16(data, blockDataStart + 8 + 2);
                      #endif
                      
                                          uint code = BitConverter.ToUInt32(data, blockDataStart + 8 + 4);
                      
                                          ushort r0 = 0, g0 = 0, b0 = 0, r1 = 0, g1 = 0, b1 = 0;
                                          r0 = (ushort)(8 * (color0 & 31));
                                          g0 = (ushort)(4 * ((color0 >> 5) & 63));
                                          b0 = (ushort)(8 * ((color0 >> 11) & 31));
                      
                                          r1 = (ushort)(8 * (color1 & 31));
                                          g1 = (ushort)(4 * ((color1 >> 5) & 63));
                                          b1 = (ushort)(8 * ((color1 >> 11) & 31));
                      
                                          for (int k = 0; k < 4; k++)
                                          {
                      #if XBOX360
                                              int j = k ^ 1;
                      #else
                                              int j = k;
                      #endif
                      
                                              for (int i = 0; i < 4; i++)
                                              {
                                                  int pixDataStart = (width * (y * 4 + j) * 4) + ((x * 4 + i) * 4);
                                                  uint codeDec = code & 0x3;
                      
                                                  pixData[pixDataStart + 3] = alpha[i, j];
                      
                                                  switch (codeDec)
                                                  {
                                                      case 0:
                                                          pixData[pixDataStart + 0] = (byte)r0;
                                                          pixData[pixDataStart + 1] = (byte)g0;
                                                          pixData[pixDataStart + 2] = (byte)b0;
                                                          break;
                                                      case 1:
                                                          pixData[pixDataStart + 0] = (byte)r1;
                                                          pixData[pixDataStart + 1] = (byte)g1;
                                                          pixData[pixDataStart + 2] = (byte)b1;
                                                          break;
                                                      case 2:
                                                          if (color0 > color1)
                                                          {
                                                              pixData[pixDataStart + 0] = (byte)((2 * r0 + r1) / 3);
                                                              pixData[pixDataStart + 1] = (byte)((2 * g0 + g1) / 3);
                                                              pixData[pixDataStart + 2] = (byte)((2 * b0 + b1) / 3);
                                                          }
                                                          else
                                                          {
                                                              pixData[pixDataStart + 0] = (byte)((r0 + r1) / 2);
                                                              pixData[pixDataStart + 1] = (byte)((g0 + g1) / 2);
                                                              pixData[pixDataStart + 2] = (byte)((b0 + b1) / 2);
                                                          }
                                                          break;
                                                      case 3:
                                                          if (color0 > color1)
                                                          {
                                                              pixData[pixDataStart + 0] = (byte)((r0 + 2 * r1) / 3);
                                                              pixData[pixDataStart + 1] = (byte)((g0 + 2 * g1) / 3);
                                                              pixData[pixDataStart + 2] = (byte)((b0 + 2 * b1) / 3);
                                                          }
                                                          else
                                                          {
                                                              pixData[pixDataStart + 0] = 0;
                                                              pixData[pixDataStart + 1] = 0;
                                                              pixData[pixDataStart + 2] = 0;
                                                          }
                                                          break;
                                                  }
                      
                                                  code >>= 2;
                                              }
                                          }
                      
                      
                                      }
                                  }
                                  return pixData;
                              }
                      
                          }
                      }

                      Comment

                      Working...