Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

WZ New wz png format decode code

Experienced Elementalist
Joined
Feb 15, 2010
Messages
201
Reaction score
296
There's some new format for the png inside the newer version of wz files.Besides the existing ones (1, 2, 513, 517) the new format(3,1026,2050) they are transparent in HaRepacker.

Here's decode code for all format.

Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;

namespace WzComparerR2.WzLib
{
    public class Wz_Png
    {
        public Wz_Png(int w, int h, int data_length, int form, int offs, Wz_File wz_f)
        {
            this.w = w;
            this.h = h;
            this.data_length = data_length;
            this.form = form;
            this.offs = offs;
            this.wz_f = wz_f;
        }

        private int w;
        private int h;
        private int data_length;
        private int form;
        private int offs;
        private Wz_File wz_f;

        /// <summary>
        /// 获取或设置图片的宽度。
        /// </summary>
        public int Width
        {
            get { return w; }
            set { w = value; }
        }

        /// <summary>
        /// 获取或设置图片的高度。
        /// </summary>
        public int Height
        {
            get { return h; }
            set { h = value; }
        }

        /// <summary>
        /// 获取或设置数据块的长度。
        /// </summary>
        public int DataLength
        {
            get { return data_length; }
            set { data_length = value; }
        }

        /// <summary>
        /// 获取或设置数据块对于文件的偏移。
        /// </summary>
        public int Offset
        {
            get { return offs; }
            set { offs = value; }
        }

        /// <summary>
        /// 获取或设置图片的数据压缩方式。
        /// </summary>
        public int Form
        {
            get { return form; }
            set { form = value; }
        }

        /// <summary>
        /// 获取或设置图片所属的WzFile
        /// </summary>
        public Wz_File WzFile
        {
            get { return wz_f; }
            set { wz_f = value; }
        }

        public byte[] GetRawData()
        {
            lock (this.WzFile.ReadLock)
            {
                DeflateStream zlib;
                byte[] plainData = null;

                this.WzFile.FileStream.Position = this.Offset;

                if (this.WzFile.BReader.ReadUInt16() == 0x9C78)
                {
                    byte[] buffer = this.WzFile.BReader.ReadBytes(this.data_length - 2);
                    MemoryStream dataStream = new MemoryStream(buffer);

                    zlib = new DeflateStream(dataStream, CompressionMode.Decompress);
                }
                else
                {
                    this.WzFile.FileStream.Position -= 2;
                    MemoryStream dataStream = new MemoryStream(this.DataLength);
                    int blocksize = 0;
                    int endPosition = (int)(this.DataLength + this.WzFile.FileStream.Position);

                    var encKeys = this.WzFile.WzStructure.encryption.keys;

                    while (this.WzFile.FileStream.Position < endPosition)
                    {
                        blocksize = this.WzFile.BReader.ReadInt32();
                        byte[] dataBlock = this.WzFile.BReader.ReadBytes(blocksize);
                        encKeys.Decrypt(dataBlock, 0, dataBlock.Length);

                        dataStream.Write(dataBlock, 0, dataBlock.Length);
                    }
                    dataStream.Position = 2;
                    zlib = new DeflateStream(dataStream, CompressionMode.Decompress);
                }

                switch (this.Form)
                {
                    case 1:
                        plainData = new byte[this.w * this.h * 2];
                        zlib.Read(plainData, 0, plainData.Length);
                        break;

                    case 2:
                        plainData = new byte[this.w * this.h * 4];
                        zlib.Read(plainData, 0, plainData.Length);
                        break;

                    case 3:
                        plainData = new byte[((int)Math.Ceiling(this.w / 4.0)) * 4 * ((int)Math.Ceiling(this.h / 4.0)) * 4 / 8];
                        zlib.Read(plainData, 0, plainData.Length);
                        break;

                    case 513:
                        plainData = new byte[this.w * this.h * 2];
                        zlib.Read(plainData, 0, plainData.Length);
                        break;

                    case 517:
                        plainData = new byte[this.w * this.h / 128];
                        zlib.Read(plainData, 0, plainData.Length);
                        break;

                    case 1026:
                        plainData = new byte[this.w * this.h];
                        zlib.Read(plainData, 0, plainData.Length);
                        break;

                    case 2050:
                        plainData = new byte[this.w * this.h];
                        zlib.Read(plainData, 0, plainData.Length);
                        break;

                    default:
                        break;
                }
                if (zlib != null)
                {
                    zlib.Close();
                }
                return plainData;
            }
        }

        public Bitmap ExtractPng()
        {
            byte[] pixel = this.GetRawData();
            if (pixel == null)
            {
                return null;
            }
            Bitmap pngDecoded = null;
            BitmapData bmpdata;

            switch (this.form)
            {
                case 1: //16位argba4444
                    byte[] argb = GetPixelDataBgra4444(pixel, this.w, this.h);
                    pngDecoded = new Bitmap(this.w, this.h, PixelFormat.Format32bppArgb);
                    bmpdata = pngDecoded.LockBits(new Rectangle(Point.Empty, pngDecoded.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                    Marshal.Copy(argb, 0, bmpdata.Scan0, argb.Length);
                    pngDecoded.UnlockBits(bmpdata);
                    break;

                case 2: //32位argb8888
                    pngDecoded = new Bitmap(this.w, this.h, PixelFormat.Format32bppArgb);
                    bmpdata = pngDecoded.LockBits(new Rectangle(Point.Empty, pngDecoded.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                    Marshal.Copy(pixel, 0, bmpdata.Scan0, pixel.Length);
                    pngDecoded.UnlockBits(bmpdata);
                    break;

                case 3: //黑白缩略图
                    pngDecoded = new Bitmap(this.w, this.h, PixelFormat.Format32bppArgb);
                    int[] argb2 = new int[this.w * this.h];
                    {
                        int index;
                        int index2;
                        int p;
                        int w = ((int)Math.Ceiling(this.w / 4.0));
                        int h = ((int)Math.Ceiling(this.h / 4.0));
                        for (int y = 0; y < h; y++)
                        {
                            for (int x = 0; x < w; x++)
                            {
                                index = (x + y * w) * 2; //原像素索引
                                index2 = x * 4 + y * this.w * 4; //目标像素索引
                                p = (pixel[index] & 0x0F) | ((pixel[index] & 0x0F) << 4);
                                p |= ((pixel[index] & 0xF0) | ((pixel[index] & 0xF0) >> 4)) << 8;
                                p |= ((pixel[index + 1] & 0x0F) | ((pixel[index + 1] & 0x0F) << 4)) << 16;
                                p |= ((pixel[index + 1] & 0xF0) | ((pixel[index] & 0xF0) >> 4)) << 24;

                                for (int i = 0; i < 4; i++)
                                {
                                    if (x * 4 + i < this.w)
                                    {
                                        argb2[index2 + i] = p;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                            //复制行
                            index2 = y * this.w * 4;
                            for (int j = 1; j < 4; j++)
                            {
                                if (y *4 + j < this.h)
                                {
                                    Array.Copy(argb2, index2, argb2, index2 + j * this.w, this.w);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                    bmpdata = pngDecoded.LockBits(new Rectangle(Point.Empty, pngDecoded.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                    Marshal.Copy(argb2, 0, bmpdata.Scan0, argb2.Length);
                    pngDecoded.UnlockBits(bmpdata);
                    break;

                case 513: //16位rgb565
                    pngDecoded = new Bitmap(this.w, this.h, PixelFormat.Format16bppRgb565);
                    bmpdata = pngDecoded.LockBits(new Rectangle(new Point(), pngDecoded.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                    Marshal.Copy(pixel, 0, bmpdata.Scan0, pixel.Length);
                    pngDecoded.UnlockBits(bmpdata);
                    break;

                case 517: //16位rgb565缩略图
                    pngDecoded = new Bitmap(this.w, this.h, PixelFormat.Format16bppRgb565);
                    bmpdata = pngDecoded.LockBits(new Rectangle(0, 0, this.w, this.h), ImageLockMode.WriteOnly, PixelFormat.Format16bppRgb565);
                    byte[] lineData = new byte[this.w * 2];
                    for (int j0 = 0, j1 = this.h / 16; j0 < j1; j0++)
                    {
                        for (int i0 = 0, i1 = this.w / 16; i0 < i1; i0++)
                        {
                            int idx = (i0 + j0 * i1) * 2;
                            for (int k = 0; k < 16; k++)
                            {
                                lineData[i0 * 32 + k * 2] = pixel[idx];
                                lineData[i0 * 32 + k * 2 + 1] = pixel[idx + 1];
                            }
                        }
                        for (int k = 0; k < 16; k++)
                        {
                            Marshal.Copy(lineData, 0, new IntPtr(bmpdata.Scan0.ToInt32() + lineData.Length * (j0 * 16 + k)), lineData.Length);
                        }
                    }
                    pngDecoded.UnlockBits(bmpdata);
                    break;
                   /* pngDecoded = new Bitmap(this.w, this.h);
                    pngSize = this.w * this.h / 128;
                    plainData = new byte[pngSize];
                    zlib.Read(plainData, 0, pngSize);
                    byte iB = 0;
                    for (int i = 0; i < pngSize; i++)
                    {
                        for (byte j = 0; j < 8; j++)
                        {
                            iB = Convert.ToByte(((plainData[i] & (0x01 << (7 - j))) >> (7 - j)) * 0xFF);
                            for (int k = 0; k < 16; k++)
                            {
                                if (x == this.w) { x = 0; y++; }
                                pngDecoded.SetPixel(x, y, Color.FromArgb(0xFF, iB, iB, iB));
                                x++;
                            }
                        }
                    }
                    break;*/

                case 1026: //dxt3
                    argb = GetPixelDataDXT3(pixel, this.w, this.h);
                    pngDecoded = new Bitmap(this.w, this.h, PixelFormat.Format32bppArgb);
                    bmpdata = pngDecoded.LockBits(new Rectangle(new Point(), pngDecoded.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                    Marshal.Copy(argb, 0, bmpdata.Scan0, argb.Length);
                    pngDecoded.UnlockBits(bmpdata);
                    break;

                case 2050: //dxt5
                    argb = GetPixelDataDXT5(pixel, this.w, this.h);
                    pngDecoded = new Bitmap(this.w, this.h, PixelFormat.Format32bppArgb);
                    bmpdata = pngDecoded.LockBits(new Rectangle(new Point(), pngDecoded.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                    Marshal.Copy(argb, 0, bmpdata.Scan0, argb.Length);
                    pngDecoded.UnlockBits(bmpdata);
                    break;
            }

            return pngDecoded;
        }

        public static byte[] GetPixelDataBgra4444(byte[] rawData, int width, int height)
        {
            byte[] argb = new byte[width * height * 4];
            {
                int p;
                for (int i = 0; i < rawData.Length; i++)
                {
                    p = rawData[i] & 0x0F; p |= (p << 4); argb[i * 2] = (byte)p;
                    p = rawData[i] & 0xF0; p |= (p >> 4); argb[i * 2 + 1] = (byte)p;
                }
            }
            return argb;
        }

        public static byte[] GetPixelDataDXT3(byte[] rawData, int width, int height)
        {
            byte[] pixel = new byte[width * height * 4];

            Color[] colorTable = new Color[4];
            int[] colorIdxTable = new int[16];
            byte[] alphaTable = new byte[16];
            for (int y = 0; y < height; y += 4)
            {
                for (int x = 0; x < width; x += 4)
                {
                    int off = x * 4 + y * width;
                    ExpandAlphaTableDXT3(alphaTable, rawData, off);
                    ushort u0 = BitConverter.ToUInt16(rawData, off + 8);
                    ushort u1 = BitConverter.ToUInt16(rawData, off + 10);
                    ExpandColorTable(colorTable, u0, u1);
                    ExpandColorIndexTable(colorIdxTable, rawData, off + 12);

                    for (int j = 0; j < 4; j++)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            SetPixel(pixel,
                                x + i,
                                y + j,
                                width, 
                                colorTable[colorIdxTable[j * 4 + i]],
                                alphaTable[j * 4 + i]);
                        }
                    }
                }
            }

            return pixel;
        }

        public static byte[] GetPixelDataDXT5(byte[] rawData, int width, int height)
        {
            byte[] pixel = new byte[width * height * 4];

            Color[] colorTable = new Color[4];
            int[] colorIdxTable = new int[16];
            byte[] alphaTable = new byte[8];
            int[] alphaIdxTable = new int[16];
            for (int y = 0; y < height; y += 4)
            {
                for (int x = 0; x < width; x += 4)
                {
                    int off = x * 4 + y * width;
                    ExpandAlphaTableDXT5(alphaTable, rawData[off + 0], rawData[off + 1]);
                    ExpandAlphaIndexTableDXT5(alphaIdxTable, rawData, off + 2);
                    ushort u0 = BitConverter.ToUInt16(rawData, off + 8);
                    ushort u1 = BitConverter.ToUInt16(rawData, off + 10);
                    ExpandColorTable(colorTable, u0, u1);
                    ExpandColorIndexTable(colorIdxTable, rawData, off + 12);

                    for (int j = 0; j < 4; j++)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            SetPixel(pixel,
                                x + i,
                                y + j,
                                width,
                                colorTable[colorIdxTable[j * 4 + i]],
                                alphaTable[alphaIdxTable[j * 4 + i]]);
                        }
                    }
                }
            }

            return pixel;
        }

        private static void SetPixel(byte[] pixelData, int x, int y, int width, Color color, byte alpha)
        {
            int offset = (y * width + x) * 4;
            pixelData[offset + 0] = color.B;
            pixelData[offset + 1] = color.G;
            pixelData[offset + 2] = color.R;
            pixelData[offset + 3] = alpha;
        }

        #region DXT1 Color
        private static void ExpandColorTable(Color[] color, ushort c0, ushort c1)
        {
            color[0] = RGB565ToColor(c0);
            color[1] = RGB565ToColor(c1);
            if (c0 > c1)
            {
                color[2] = Color.FromArgb(0xff, (color[0].R * 2 + color[1].R + 1) / 3, (color[0].G * 2 + color[1].G + 1) / 3, (color[0].B * 2 + color[1].B + 1) / 3);
                color[3] = Color.FromArgb(0xff, (color[0].R + color[1].R * 2 + 1) / 3, (color[0].G + color[1].G * 2 + 1) / 3, (color[0].B + color[1].B * 2 + 1) / 3);
            }
            else
            {
                color[2] = Color.FromArgb(0xff, (color[0].R + color[1].R) / 2, (color[0].G + color[1].G) / 2, (color[0].B + color[1].B) / 2);
                color[3] = Color.FromArgb(0xff, Color.Black);
            }
        }

        private static void ExpandColorIndexTable(int[] colorIndex, byte[] rawData, int offset)
        {
            for (int i = 0; i < 16; i += 4, offset++)
            {
                colorIndex[i + 0] = (rawData[offset] & 0x03);
                colorIndex[i + 1] = (rawData[offset] & 0x0c) >> 2;
                colorIndex[i + 2] = (rawData[offset] & 0x30) >> 4;
                colorIndex[i + 3] = (rawData[offset] & 0xc0) >> 6;
            }
        }
        #endregion

        #region DXT3/DXT5 Alpha
        private static void ExpandAlphaTableDXT3(byte[] alpha, byte[] rawData, int offset)
        {
            for (int i = 0; i < 16; i += 2, offset++)
            {
                alpha[i + 0] = (byte)(rawData[offset] & 0x0f);
                alpha[i + 1] = (byte)((rawData[offset] & 0xf0) >> 4);
            }
            for (int i = 0; i < 16; i++)
            {
                alpha[i] = (byte)(alpha[i] | (alpha[i] << 4));
            }
        }

        private static void ExpandAlphaTableDXT5(byte[] alpha, byte a0, byte a1)
        {
            alpha[0] = a0;
            alpha[1] = a1;
            if (a0 > a1)
            {
                for(int i = 2; i < 8; i++)
                {
                    alpha[i] = (byte)(((8 - i) * a0 + (i - 1) * a1 + 3) / 7);
                }
            }
            else
            {
                for(int i = 2; i < 6; i++)
                {
                    alpha[i] = (byte)(((6 - i) * a0 + (i - 1) * a1 + 2) / 5);
                }
                alpha[6] = 0;
                alpha[7] = 255;
            }
        }

        private static void ExpandAlphaIndexTableDXT5(int[] alphaIndex, byte[] rawData, int offset)
        {
            for (int i = 0; i < 16; i += 8, offset += 3)
            {
                int flags = rawData[offset]
                    | (rawData[offset + 1] << 8)
                    | (rawData[offset + 2] << 16);
                for(int j = 0; j < 8; j++)
                {
                    int mask = 0x07 << (3 * j);
                    alphaIndex[i + j] = (flags & mask) >> (3 * j);
                }
            }
        }
        #endregion

        public static Color RGB565ToColor(ushort val)
        {
            const int rgb565_mask_r = 0xf800;
            const int rgb565_mask_g = 0x07e0;
            const int rgb565_mask_b = 0x001f;
            int r = (val & rgb565_mask_r) >> 11;
            int g = (val & rgb565_mask_g) >> 5;
            int b = (val & rgb565_mask_b);
            var c = Color.FromArgb(
                (r << 3) | (r >> 2),
                (g << 2) | (g >> 4),
                (b << 3) | (b >> 2));
            return c;
        }
    }
}
 
Junior Spellweaver
Joined
Dec 22, 2013
Messages
105
Reaction score
15
How do i show you my eternal gratitude

INJP4sA - New wz png format decode code - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Last edited:
Joined
Nov 22, 2009
Messages
83
Reaction score
4
eugh, now I have to download vs :sleep:
Thanks!

EDIT : where does this go ? WzPngpropterty.cs if so do I replace the whole code or add this in
Sorry I've tried looking through everything on my own even though I have no prior experience with vs..
 
Last edited:
Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,264
eugh, now I have to download vs :sleep:
Thanks!

EDIT : where does this go ? WzPngpropterty.cs if so do I replace the whole code or add this in
Sorry I've tried looking through everything on my own even though I have no prior experience with vs..

I believe he just showed his code and his implementation, if you'd like to apply this whole class to HaRepacker it won't work.
 
Joined
Nov 22, 2009
Messages
83
Reaction score
4
Yeah, I'm completely in the dark when it comes to visual studios..
But I did try to figure it out on my own and I ended up downloading vs and creating a new class in wzlib>wzproperties.

I did some searching through hasuite and found something similar to the code he posted and I ended up finding WzPngProperty.cs so I thought of either adding the code to that class or making a completely new class.

I came to the conclusion that it would make more sense to make a new class because of certain things I saw in the WzPngProperty class after looking through the code...

Anyways I made a new class in WzLib called WzPng2Property, pasted his code and built it in any cpu mode as haha suggeted on his github and it gave me a error about Wz_Png not being defined or whatever.

I've had experience with coding maplestory sources in netbeans and the code I was looking at in visual studios looked similar so I kind of understood what was going on

this probably seems like the easiest thing ever to certain people who know about this stuff but yeah, total noob here...

Rip.
 
Experienced Elementalist
Joined
Feb 15, 2010
Messages
201
Reaction score
296
The newest version of maplelib has already implemented(format 1026).You just need to change/add one line of code for format 2050.


case 2050:
..........
..........
decBuf = GetPixelDataDXT5(decBuf, Width, Height); //(change DX3 to DX5)
...........
break;
 
Last edited:
Experienced Elementalist
Joined
Sep 27, 2016
Messages
217
Reaction score
68
Where exactly do I put this? Do I make a new property called WzPng? I don't know how to make DLL's and I have an IQ of 1, so can someone teach me please?
 
Skilled Illusionist
Joined
Jul 3, 2011
Messages
372
Reaction score
18
How do i show you my eternal gratitude

INJP4sA - New wz png format decode code - RaGEZONE Forums

Lmao i get "has stopped working" after i compile the code and overwrite the .dll



Where exactly do I put this? Do I make a new property called WzPng? I don't know how to make DLL's and I have an IQ of 1, so can someone teach me please?

You might need to find the harepacker source code and look for WzPngProperty.cs, add those missing code (just copy paste and edit some stuff) and try, And "Has stopped working" is my result after compile it lol.
 

Attachments

You must be registered for see attachments list
Junior Spellweaver
Joined
Dec 21, 2013
Messages
140
Reaction score
3
This interests me as well, it sounds as easy as changing a few values, but when it comes to compiling the actual MapleLib, there is one missing file that it refers to "NAudio", so I just added it as a reference from the dll available from the Harepacker files (Not sure if that's how it's done).

Similar to davidling, the end result is Harepacker functioning at all. Comparing the sizes, I'm pretty sure changing 2 values isn't suppose to increase the dll by 20kb, but I wouldn't know. What else am I missing? (I know nothing with these kinds of subjects please forgive me >~<)

Anyone know how to compile it successfully?
 
Junior Spellweaver
Joined
Dec 21, 2013
Messages
140
Reaction score
3
Hi Fraysa :eek:

1. Clone MapleLib
2. Fire up Visual Studio
3. Add the required code @Elem8100 posted
4. ???
5.

This put a big smile on my face, but I just want to confirm a few things before I have another attempt at this curse again

When I clone MapleLib, start up the MapleLib.csproj, then place the required code based off where the namespace "WzComparerR2.WzLib" is as a file called Wz_Png?

-> I just realized I thought of something similar to what JellyIsHawt did
 
Last edited:
Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,264
Hi Fraysa :eek:



This put a big smile on my face, but I just want to confirm a few things before I have another attempt at this curse again

When I clone MapleLib, start up the MapleLib.csproj, then place the required code based off where the namespace "WzComparerR2.WzLib" is as a file called Wz_Png?

-> I just realized I thought of something similar to what JellyIsHawt did

WzComparerR2.WzLib is a different variation of MapleLib it appears, so you can't use this file with MapleLib.

Anyways - I already did the work for you. Check the link in my previous post (hint: hidden under "profitzzzzzzzz!!!").
 
Junior Spellweaver
Joined
Dec 21, 2013
Messages
140
Reaction score
3
I honestly feel bad about this, but I appreciate that a lot >~< (Didn't notice it was a link :eek:)

What do you mean by a different variation? :eek: When comparing the the code above and WzPngProperty, it looks the exact same except what Elem8100 stated.

Based on instinct, I placed the dll where my Harepacker is located and it crashes immediately similar to what happened when I tried to create the dll. Did I even use this correctly? *-*

And can you explain briefly how you made the dll? I'm really curious about that :eek:

(Sorry for all the questions)

I'm using the Harepacker from here.
 
Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,264
I honestly feel bad about this, but I appreciate that a lot >~< (Didn't notice it was a link :eek:)

What do you mean by a different variation? :eek: When comparing the the code above and WzPngProperty, it looks the exact same except what Elem8100 stated.

Based on instinct, I placed the dll where my Harepacker is located and it crashes immediately similar to what happened when I tried to create the dll. Did I even use this correctly? *-*

And can you explain briefly how you made the dll? I'm really curious about that :eek:

(Sorry for all the questions)

I'm using the Harepacker from here.

I don't know what version of MapleStory WZ files you're trying to load, but I uploaded my HaSuite .
Works great for me.
 
Junior Spellweaver
Joined
Dec 21, 2013
Messages
140
Reaction score
3
I don't know what version of MapleStory WZ files you're trying to load, but I uploaded my HaSuite .
Works great for me.

I haven't even gotten to the point of loading WZ files unfortunately, just trying to run it crashes me :/

I'll try out yours and uhh "give an update" if it works for me >~<


EDIT: It worked perfectly thank you!

If anyone else has been able to compile it successfully, can someone tell me how they did it? Trying to compile it for me gave me reference errors which preventing me from compiling at all. :eek: Thank you!
 
Last edited:
Junior Spellweaver
Joined
Mar 24, 2012
Messages
156
Reaction score
1
I don't know what version of MapleStory WZ files you're trying to load, but I uploaded my HaSuite .
Works great for me.

Hey I used your link, and I try to open maple wz files v142.2 (also tried v62/v83 same errors)
and getting this error

11111 - New wz png format decode code - RaGEZONE Forums
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidCastException: Unable to cast object of type 'MapleLib.WzLib.WzProperties.WzUOLProperty' to type 'MapleLib.WzLib.WzProperties.WzSoundProperty'.
at HaCreator.Wz.WzFileManager.ExtractSoundFile()
at HaCreator.GUI.Initialization.InitializeWzFiles(String wzPath, WzMapleVersion fileVersion)
at HaCreator.GUI.Initialization.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1076.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
HaCreator
Assembly Version: 2.1.1.0
Win32 Version:
CodeBase: file:///D:/maplecoding/HaSuite/HaSuite/HaCreator.exe
----------------------------------------
PresentationCore
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1080.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/PresentationCore/v4.0_4.0.0.0__31bf3856ad364e35/PresentationCore.dll
----------------------------------------
WindowsBase
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1080.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/WindowsBase/v4.0_4.0.0.0__31bf3856ad364e35/WindowsBase.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1055.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1075.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1068.2 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
MonoGame.Framework
Assembly Version: 3.4.0.456
Win32 Version: 3.4.0.456
CodeBase: file:///D:/maplecoding/HaSuite/HaSuite/MonoGame.Framework.DLL
----------------------------------------
MapleLib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.0.0
CodeBase: file:///D:/maplecoding/HaSuite/HaSuite/MapleLib.DLL
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1055.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
HaRepackerLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/maplecoding/HaSuite/HaSuite/HaRepackerLib.DLL
----------------------------------------
NAudio
Assembly Version: 1.7.3.0
Win32 Version: 1.7.3.0
CodeBase: file:///D:/maplecoding/HaSuite/HaSuite/NAudio.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
and HaCreator are crushing


and this is HaRepacker
11111-2 - New wz png format decode code - RaGEZONE Forums
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentOutOfRangeException: InvalidArgument=Value of '3' is not valid for 'SelectedIndex'.
Parameter name: SelectedIndex
at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
at HaRepacker.GUI.MainForm.MainForm_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1076.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
HaRepacker
Assembly Version: 4.2.4.0
Win32 Version:
CodeBase: file:///D:/maplecoding/HaSuite/HaSuite/HaRepacker.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1055.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1075.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1068.2 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1055.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
HaRepackerLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/maplecoding/HaSuite/HaSuite/HaRepackerLib.DLL
----------------------------------------
MapleLib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.0.0
CodeBase: file:///D:/maplecoding/HaSuite/HaSuite/MapleLib.DLL
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1055.0 built by: NETFXREL2
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.6.1067.0 built by: NETFXREL3STAGE
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
WeifenLuo.WinFormsUI.Docking
Assembly Version: 2.9.0.0
Win32 Version: 2.9.0.0
CodeBase: file:///D:/maplecoding/HaSuite/HaSuite/WeifenLuo.WinFormsUI.Docking.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
also Crashing

I'm runnig them as Admin
 

Attachments

You must be registered for see attachments list
Last edited:
Initiate Mage
Joined
May 14, 2015
Messages
26
Reaction score
1
For some reason some images with the case 1 format show up transparent as well.
 
Experienced Elementalist
Joined
Feb 15, 2010
Messages
201
Reaction score
296
Newer KMS wz introduces a new PNG format--format 257(A1R5G5B5).The new NPCs with IDs starting with 257XXXX.img

PHP:
case 257: 
        {
          pngDecoded = new Bitmap(this.w, this.h, PixelFormat.Format16bppArgb1555);
          bmpdata = pngDecoded.LockBits(new Rectangle(Point.Empty, pngDecoded.Size), ImageLockMode.WriteOnly, PixelFormat.Format16bppArgb1555);
          CopyBmpDataWithStride(pixel, pngDecoded.Width * 2, bmpdata);
          pngDecoded.UnlockBits(bmpdata);
          break;
        }
........
........
 public static void CopyBmpDataWithStride(byte[] source, int stride, BitmapData bmpData)
        {
            if (bmpData.Stride == stride)
            {
                Marshal.Copy(source, 0, bmpData.Scan0, source.Length);
            }
            else
            {
                for (int y = 0; y < bmpData.Height; y++)
                {
                    Marshal.Copy(source, stride * y, bmpData.Scan0 + bmpData.Stride * y, stride);
                }
            }

        }
 
Last edited:
Back
Top