• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Item Editor 64x64

drewny

Member
Joined
Sep 3, 2021
Messages
21
Reaction score
24
hi
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

nagorum.jpg


debugger say, error is in line
C++:
    rgbaData[512 * y + x * 4 + 0] = rgbData[(64 - y - 1) * 192 + x * 3 + 2]; // blue
out of range,
 
ok i have "working" program, please test it.
I create in ObjectBuilder new --> 10.98 --> 64x64 . adding some spr. and outfit.
Starting item editor and create new file. --> create missing files, save.
I was start map editor ... add some ground with id 100-104, save.
compiled otclient for 64x64px.. but TFS - server give error
[Fatal - Map::loadMap] [x:987, y:990, z:7] Failed to create item.
For tests.. give feedback

ps. server starting but in otclient -->

ERROR: invalid effect id 30987
C++ stack traceback:
[C++]: ProtocolGame::parseMagicEffect
...

ERROR: ProtocolGame parse message exception (657 bytes unread, last opcode is 1, prev opcode is 131): unhandled opcode 1
 

Attachments

  • ItemEditor-64x64px.zip
    5.5 MB · Views: 4 · VirusTotal
Last edited:
dosen't work.
in Item Editor
sprites loading
1690483491103.png
but when i save to file... item id 105 is looking fine and working, but problem is with argb, i can't fix this


in items.cs
C#:
 // reverse rgb
                                for (int y = 0; y < Sprite.DefaultSize; ++y)
                                {
                                    for (int x = 0; x < Sprite.DefaultSize; ++x)
                                    {
                                        rgbaData[128 * y + x * 4 + 0] = rgbData[(32 - y - 1) * 96 + x * 3 + 2]; // blue
                                        rgbaData[128 * y + x * 4 + 1] = rgbData[(32 - y - 1) * 96 + x * 3 + 1]; // green
                                        rgbaData[128 * y + x * 4 + 2] = rgbData[(32 - y - 1) * 96 + x * 3 + 0]; // red
                                        rgbaData[128 * y + x * 4 + 3] = 0;
                                    }
                                }
change to
C#:
 // reverse rgb
                                for (int y = 0; y < Sprite.DefaultSize; ++y)
                                {
                                    for (int x = 0; x < Sprite.DefaultSize; ++x)
                                    {
                                        rgbaData[256* y + x * 4 + 0] = rgbData[(64- y - 1) * 192 + x * 3 + 2]; // blue
                                        rgbaData[256* y + x * 4 + 1] = rgbData[(64- y - 1) * 192+ x * 3 + 1]; // green
                                        rgbaData[256* y + x * 4 + 2] = rgbData[(64- y - 1) * 192+ x * 3 + 0]; // red
                                        rgbaData[256* y + x * 4 + 3] = 0;
                                    }
                                }

and now you can select items and save.

"We need a clever programmer to fix the ARGB bug."
 
Last edited:
Back
Top