hi
Im trying to change default 32x32 to 64x64 in ItemEditor
I was changed in:
sprite.cs
in item.cs
i get error
debugger say, error is in line
out of range,
Im trying to change default 32x32 to 64x64 in ItemEditor
I was changed in:
sprite.cs
C++:
public const byte DefaultSize = 64;
public const ushort RGBPixelsDataSize = 12228; // 32*32*3 // 64x64*3
public const ushort ARGBPixelsDataSize = 16384; // 32*32*4 // 64x64*4
C++:
while (bytes < Size)
{
chunkSize = this.CompressedPixels[bytes] | this.CompressedPixels[bytes + 1] << 8;
bytes += 2;
for (int i = 0; i < chunkSize; ++i)
{
// Transparent pixel
rgb32x32x3[192 * y + x * 3 + 0] = transparentColor;
rgb32x32x3[192 * y + x * 3 + 1] = transparentColor;
rgb32x32x3[192 * y + x * 3 + 2] = transparentColor;
x++;
if (x >= 64)
{
x = 0;
++y;
}
}
// We're done
if (bytes >= Size)
{
break;
}
// Now comes a pixel chunk, read it!
chunkSize = this.CompressedPixels[bytes] | this.CompressedPixels[bytes + 1] << 8;
bytes += 2;
for (int i = 0; i < chunkSize; ++i)
{
byte red = this.CompressedPixels[bytes + 0];
byte green = this.CompressedPixels[bytes + 1];
byte blue = this.CompressedPixels[bytes + 2];
rgb32x32x3[192 * y + x * 3 + 0] = red;
rgb32x32x3[192 * y + x * 3 + 1] = green;
rgb32x32x3[192 * y + x * 3 + 2] = blue;
bytes += bitPerPixel;
x++;
if (x >= 64)
{
x = 0;
++y;
}
}
}
// Fill up any trailing pixels
while (y < DefaultSize && x < DefaultSize)
{
rgb32x32x3[192 * y + x * 3 + 0] = transparentColor;
rgb32x32x3[192 * y + x * 3 + 1] = transparentColor;
rgb32x32x3[192 * y + x * 3 + 2] = transparentColor;
x++;
if (x >= DefaultSize)
{
x = 0;
++y;
}
}
return rgb32x32x3;
}
in item.cs
C++:
public override byte[] SpriteHash
{
get
{
if (this.spriteHash == null)
{
MD5 md5 = MD5.Create();
int spriteBase = 0;
MemoryStream stream = new MemoryStream();
byte[] rgbaData = new byte[Sprite.ARGBPixelsDataSize];
for (byte l = 0; l < this.Layers; l++)
{
for (byte h = 0; h < this.Height; h++)
{
for (byte w = 0; w < this.Width; w++)
{
int index = spriteBase + w + h * this.Width + l * this.Width * this.Height;
Sprite sprite = this.SpriteList[index];
byte[] rgbData = sprite.GetRGBData();
// reverse rgb
for (int y = 0; y < Sprite.DefaultSize; ++y)
{
for (int x = 0; x < Sprite.DefaultSize; ++x)
{
rgbaData[512 * y + x * 4 + 0] = rgbData[(64 - y - 1) * 192 + x * 3 + 2]; // blue
rgbaData[512 * y + x * 4 + 1] = rgbData[(64 - y - 1) * 192 + x * 3 + 1]; // green
rgbaData[512 * y + x * 4 + 2] = rgbData[(64 - y - 1) * 192 + x * 3 + 0]; // red
rgbaData[512 * y + x * 4 + 3] = 0;
}
}
stream.Write(rgbaData, 0, Sprite.ARGBPixelsDataSize);
}
}
}
stream.Position = 0;
this.spriteHash = md5.ComputeHash(stream);
}
return this.spriteHash;
}
set
{
this.spriteHash = value;
}
}
i get error
debugger say, error is in line
C++:
rgbaData[512 * y + x * 4 + 0] = rgbData[(64 - y - 1) * 192 + x * 3 + 2]; // blue