• 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!

Trying to open a .gfx file (Zezenia)

MikeOT

Well-Known Member
Joined
Jan 22, 2017
Messages
232
Solutions
2
Reaction score
86
Hello,


I've been trying for quite some time to open the .gfx file in the Zezenia client in order to play around with their sprites.

I have seen a few people floating around here that has them. I can't for the life of me find a way to open or view their gfx file.


Could anyone point me in the right direction?
 
Hello,


I've been trying for quite some time to open the .gfx file in the Zezenia client in order to play around with their sprites.

I have seen a few people floating around here that has them. I can't for the life of me find a way to open or view their gfx file.


Could anyone point me in the right direction?
That is the whole point, they compile it in another format so that it isn't as easy to mess with their sprites or use them for your own project.

But if you want nice sprites you can look up some on Browse What's Hot | DeviantArt
 
Right, I do understand why they do that. Believe it or not, I'm not trying to steal their sprites to use in a project.

I just like their spriting style, and I'm trying to learn to sprite myself, but so far I am atrocious at it. I was hoping to be able to get a zoomed in view of some of the outfits and monster animations, as that is where I'm struggling.
 
Right, I do understand why they do that. Believe it or not, I'm not trying to steal their sprites to use in a project.

I just like their spriting style, and I'm trying to learn to sprite myself, but so far I am atrocious at it. I was hoping to be able to get a zoomed in view of some of the outfits and monster animations, as that is where I'm struggling.
just go to client and lock stretch window boom all sprites are 32pixels screenshoot add 255,0,255 and you can look all you want
 
in C#

Code:
public static Image GetSpriteZezenia(string file, int spriteId)    // From TibiaAPI
        {            
            #region variables
            Bitmap bitmap = new Bitmap(1,1);
            UInt32 sprites = 0;
            UInt16 width = 0;
            UInt16 height = 0;
            UInt32 dataLength = 0;            
            UInt32 total = 0;    
            UInt32 processed = 0;    
            
            byte v1 = 0;
            byte v2 = 0;
            byte v3 = 0;
            byte v4 = 0;
            
            byte px_r;
            byte px_g;
            byte px_b;
            byte px_a;
            
            int x = 0;
            int y = 0;
            int W = 0;
            int H = 0;
            
            long aux = 0;
            #endregion
            long mover;
            long move_aux;
            
            
            using (BinaryReader reader = new BinaryReader(File.OpenRead(file)))
            {
                try
                {            
                    mover = 5;
                    reader.BaseStream.Seek(mover, SeekOrigin.Begin);
                    
                    long allspr = reader.ReadUInt16();
                    reader.ReadUInt16();
                    
                    for(int k =0;k<spriteId;k++)
                    {
                        reader.BaseStream.Seek(4, SeekOrigin.Current);
                        reader.BaseStream.Seek(move_aux = reader.ReadUInt32(), SeekOrigin.Current);
                    }
                    
                    
                    //mover = 5 + 4 + 2+ 2 + 4 + 4096 +2 +2 + 4 +262144 +2 +2 +4 + 16777216 + 2+ 2 + 4 + 4096;    
                    //reader.BaseStream.Seek(mover, SeekOrigin.Begin);
                    //sprites = reader.ReadUInt32();                    
                    
                    
                    x = 0;    
                    y = 0;
                    //inicia con el primero
                    width = reader.ReadUInt16();
                    height = reader.ReadUInt16();
                    dataLength= reader.ReadUInt32();
                    bitmap = new Bitmap(width,height);    
                    W = Convert.ToInt16(width);
                    H = Convert.ToInt16(height);                    
                    total = Convert.ToUInt32(W * H * 4);                    
                    processed = 0;
                    
                    
                    
                    #region while
                    while (dataLength > 0)
                    {
                        v1= reader.ReadByte();
                        v2 = reader.ReadByte();
                        // if the first pixel data has a 0x1 value we need to add v2 times of transparent pixels
                        //&& dataLength < total
                        if (v1 == 0x1)
                        {
                            // transparent pixel
                            px_r = 0x00;
                            px_g = 0x00;
                            px_b = 0x00;
                            px_a = 0x00;
                            
                            for (int i = 0; i < v2; i++)
                            {
                                // saving in the bmp file
                                if(x >= width){x = 0; y = y+1;}
                                bitmap.SetPixel(x,y,Color.FromArgb(px_a, px_r, px_g, px_b));                                
                                x++;
                                processed += 4;
                            }
            
                            // update dataLenght left to process and offset                        
                            dataLength -= 2 * sizeof(byte);
                        }
                        // read the other 2 bytes and write the pixel rgba data
                        else
                        {
                            // reading the last 2 bytes of a pixel
                            v3= reader.ReadByte();
                            v4 = reader.ReadByte();
            
                            // case for the background image of the client it has a reserved size of 2048x2048, but the size of the image is less than this resolution
                            // so you can read until you find 0x0 0x0 0x0 0x0 for optimization
                            if (v1 == 0x0 && v2 == 0x0 && v3 == 0x0 && v4 == 0x0)
                            {                                
                                dataLength -= 4 * sizeof(byte);                        
                                // skipping all the zeros
                                reader.BaseStream.Seek(dataLength, SeekOrigin.Begin);                                
                                break;
                            }
            
                            // populate the pixel struct
                            px_r = v1;
                            px_g = v2;
                            px_b = v3;
                            px_a = v4;
                            
                            // saving in the bmp file
                            if(x >= width){x = 0; y = y+1;}
                            bitmap.SetPixel(x,y,Color.FromArgb(px_b, px_g, px_r));                            
                            x++;
                            
                            processed += 4;            
                            // update processed/offset/datalength                                                
                            dataLength -= 4 * sizeof(byte);    
                        }
                        
                    }//end while
                    
                    #endregion
                    
                    #region fill the rest
                    // fill the rest of sprite with transparent pixels
                        if (processed < total)
                        {
                            // creating the transparent pixel
                            px_r = 0x00;
                            px_g = 0x00;
                            px_b = 0x00;
                            px_a = 0x00;
                            for (int i = 0; i < total - processed; i++)
                            {
                                // write pixel in the bmp
                                if(x >= width){x = 0; y = y+1;}
                                bitmap.SetPixel(x,y,Color.FromArgb(px_a, px_r, px_g, px_b));                                
                                x++;
                            }
                        }
                    #endregion
                    
                    
                    
                }
                catch {}
            }
            
            bitmap.Save(spriteId + ".png");
            

            return bitmap;
        }

=)
 
Back
Top