Hello guys,
I want to know how to convert the JPG file into the WAD file ?
the thing is not common as all. its not about to change extension, I need it to convert it as like
"HI tag Converter" or "Decal Converter" or "wally" tec...
I just google some of this and get the one nice program but that Program is in CONSOLE.

SO thats useless for me.
So I need Help... Can anyone help me with this?

If you need to know about CONSOLE program coding then get this from here.https://www.daniweb.com/images/attachments/4/57a4e8cb0be563b79a8ae52a5bf1b8f2.zip
[REMEMBER THIS IS SOURCE PROJECT FROM WHICH YOU CAN HELP ME, I AM NOT SHARING EXECUATBLE FILES.]

Recommended Answers

All 54 Replies

It's a bit lengthy to post everything, but this thread should start you off in the right direction:

http://www.doomworld.com/vb/doom-editing/10766-wad-file-format/

You will likely have to convert the binary jpg into something usable by the file format, or just have the jpg as an asset of some sort.

@Anthony21
I want to learn how can i create to change the file from JPG/PNG to WAD...??
I know about this software.
This software just change the File but dont give me the code...
and are you sure this is build in VB/VB.net??
I dont think so as it not required net framework 2.0 (atleast...)

@ryantroop
I cant understand that what they are talking about...
and the link in description lead to 403 forbidden error.

Ah so you're looking for the actual code to do it? Hmm, check out this: http://wadmangle.sourceforge.net/ I'm not sure if it does what you need, but the source code to it (C# not VB.NET) can be found here.

@Anthony21 Yes wadmangles.
but this is showing me in true direction but its too complecated to get it.
and I dont find the C# file so I can just see code and translate it...

ANY OF ONE KNOWS ABOUT THE VIDEO TO CONVERT THE PNG/JPG/BMP TO WAD.
LET me tell you I am creating to change the CS custom Spray Logo.
I am searching for this from last month but i dont get so if someone knows please participate in this thread, and help me...

I want to update my program...

Hang in there Deep Modi. I think i've found how to extract contents of a Wad file. Give me time to familiarise myself with it and I'll see what I can do.

commented: Ok, You can take some time, (please target upto this week) +4

Yeah you can,
And please can somone more are interested in this article plz share your ideas to extract Png or Jpg or bmp into the WAD File.
(Half Life Package)
Listen i dont need applivation, I need the VB.net Coding with explanation so that I can get how that works

My target to complete this project: this week

Sorry Deep Modi, I think I missunderstood what you wrote there "Someone more are interested"? Are you saying I am not interested or you don't want my help?

I have converted your given project into winforms... I have figured out how to read the byte information and what's stored where and am currently in the process of 1. Overwriting the original bytes with your new image (pixel and pallette data), and 2. totally rebuilding the wad file with new images.

Also Note, there are 4 MIPs in total per texture in a WAD3 file, th sizes are 1, 1\4, 1\16, and 1\64.

I have to work and I have my own projects, I can't guarantee a week, there's no documentation at all on this.

Here is the un-edited winform version so you yourself can investigate at the same time. I've included some aditional comments so you can see whats going on. Note: This is only a conversion from console to WinForms so you can play too.

Oh you misunderstood.
I was saying some else also start to investigate on this.
So that We can get the true information faster.

I need Help of All programer and You are NOT my enemy so I will DONT TAKE HELP.
I will Take help if you can...

"You are interested, Those who try to help are always interested on the topic or PROGRAMMING." (I didn't mention that you are not interested.

I missunderstood what you wrote there "Someone more are interested"? Are you saying I am not interested or you don't want my help?

@ J.C. SolvoTerra

When I open the exe, there one btn which tell to get wad3 file.
but here i am bit confused.

We need to get the PNG/JPG/BMP file into WAD File (half life package)
So what the procdure?

CAN ANYONE TELL ME:
what we exactly need to do if we want to convert any picture file to WAD File.
(I mean I want algorithm, so that I can think of about the code.)

@J.C. SolvoTerra
Nice try my frnd, but need more help from you.
and I like that you are interested... Plz help me more.

Deep Modi. This isn't my solution. This zip is only your zip converted to WinForms instead of console which you complained about. Listen bud, if you can't understand the code in this program then I'm sorry to point out that thus project may be way over your head... to be polite of course.

I will finish my solution for you which will allow you to overwrite a mip entry based on the original dimensions and palette size.

After that i suggest you study mip files, textures etc like i did last night and try to get a better understanding of what you are trying to do.

Respectfully.
Jay

When i get home I'll explain in much more detail what is happening and why you need to stop using the phrase "convert bmp etc to WAD file". Note: a wad file is more like a cab or zip (without the compression) containing textures that are of indexed palette. I know this because i not only researched mips last night but i also inspected the code you ptovided in the zip.

Ok as towards your first post you have found the solution but it not graphically so why don't you take that consol app and intergrate it VB so that it will still do what it suppose to do but now intead of typing commands on a console the app will do it for you, you will only wright codes once but can use it as many times as you wish.

Mr. M to be fair the console app only reads the data, it doesn't write or rearrange the contents. Though the console program does (should) give all the clues how to achieve this.

@Deep Modi I thought you would have tried to run the console program, or read my alterations. After you ran my version and you selected your WAD file, the program should have created an "Output" directory in your My Documents folder and extracted all the images. Can you confirm you have the Output folder in your My Documents and can you confirm there are images in the folder. In fact my version should automatically open the Output directory for you.

Oh, I got the console app with wrong title. (I searched for PNG to WAD) and got this so i posted here. and I dont understand to use it. If I am not aware then how can I ? ( I mean the console dont show any help like to get in correct direction) Salute to you, you did that successfully...
Now just waiting for your solution...

Can you give me link so that I can read about this in details...

I suggest you study mip files, textures etc like i did last night and try to get a better understanding of what you are trying to do.

Please elaborate this, explain me in details...

When i get home I'll explain in much more detail what is happening and why you need to stop using the phrase "convert bmp etc to WAD file". Note: a wad file is more like a cab or zip (without the compression) containing textures that are of indexed palette. I know this because i not only researched mips last night but i also inspected the code you ptovided in the zip.

Hey this is not working that Output.
Where can I show you proof I dont know, It extract The WAD file into PNG but that not the same wad File That was extracted.

So the File That I attached is really fails.. (SORRY) I just get it to know right now only. so now we have only one thing to do.

Let get started from First.
I will watch more articles on this, and taking a watch on this,
If you find anmy articles related to this, then send me link...

MipMaps.

My interpretation. MipMaps as a collection of pre-rendered images to save processing time (Furher away textures have less pixels to process) and reduce the effects of antialiasing. Each MipMap contains several images from full size down to really small. The 3d enine will select which texture (Images in MipMaps are textures) to apply to the surface depending on the mathmatical distance from the user. In a wad3 file there are four images 1 1\4 1\16 and 1\64. this tells me that the furthest away texture will be resized to a maximum of 1\32 and minimum of 0. When scaling up (getting closer) the software will switch the texture at 1\32 to the second smallest image and resize it from smallest 1\32 passed it's pre-rendered size at 1\16 to an elargement of 1\8 and so on.

http://en.wikipedia.org/wiki/Mipmap

Indexed Images,
Files such as PNG can use and indexed palette, typically up to 256 colours. Unlike a bitmap where the RGB values are written in the byte order they appear, each byte in an indexed PNG holds the index reference to the palette and the color stored within. The palette can be various formats including RGB and ARGB. It seems WAD3 files use this method though much of the PNG's meta headers are removed leaving only the meta values, the image data and the palette information.

Here's more information about indexed images

http://en.wikipedia.org/wiki/Indexed_color

Ok, so over to the code in the zip file

        'Read the header
        Dim Header As WAD3HEADER_T = New WAD3HEADER_T

        Try
            WAD3HEADER_T.ReadStream(InputFile, Header)
        Catch
        End Try

Here we are storing initial information on the WAD3 file. Headers properties are

DirOffset = The byte position the directory start's from
Magic = The WAD3's magic number sequence, in this case the 4 bytes convert to WAD3

and

NumberOfEntries = How Many Entries Are In The Wad file

Next the binary reader seeks to the start of the directory

InputFile.Position = Header.DirectoryOffset

The program then loops through the number of entries in the directory

    For I As Integer = 0 To (Header.NumberOfEntries - 1)
    ...
    Next

It then reads the directory entry information

WAD3DIR_T.ReadStream(InputFile, TmpDir)'TmpDir is WAD3DIR_T structure

TmpDir then contains the following values

CompressedSize, Name, Offset etc.

It then seeks to the Texture data

InputFile.Position = TmpDir.Offset

and reads the Mip data

WAD3MIP_T.ReadStream(InputFile, TmpMip)' TmpMip is the WAD3MIP_T structure

TmpMip now holds information such as dimensions, palette size and offsets for each of the pre-rendered textures (1 1\4 1\16 1\64)

and sets a few variables accordingly to read

            Dim ImageSize As Integer = (TmpMip.Width * TmpMip.Height)
            Dim ImageBitmap As New Bitmap(TmpMip.Width, TmpMip.Height)

            Dim Palette As WAD3RGB_T()
            Dim PaletteSize As Integer

Next the program reads the color palette. The platte information is stored at the end of all four texture images, it's byte location is found by the following code

InputFile.Position = PostMipPosition + (ImageSize + (ImageSize / 4) + (ImageSize / 16) + (ImageSize / 64))

The palette size is read and an array is created to hold the palette values

            PaletteSize = Binary.ReadInt16()
            ReDim Palette(PaletteSize)

The palette information is then read into the array of WAD3RGB_T (Which is just a structure cunsisting of Red, Green and Blue values)

           For J As Integer = 0 To (PaletteSize - 1)
                Palette(J) = New WAD3RGB_T
                Palette(J).Red = Binary.ReadByte()
                Palette(J).Green = Binary.ReadByte()
                Palette(J).Blue = Binary.ReadByte()
            Next

The BinaryReaders position is then moved back to the start of the first textures location

    '## Notice in this example though, only the first texture is read
    '## From each MipMap, here you could create a new for\ next loop and run
    '## from 0 to 3
    InputFile.Position = TmpDir.Offset + TmpMip.Offset(0)   '0 = First Image offset
                                                            '...
                                                            '...
                                                            '3 = 4th texture offset

It then proceeds to read the texture information one byte or pixel at a time. Since the palette is only 256 colours, each byte (or pixel) holds the relevant reference to the palette's index

For Y As Integer = 0 To (TmpMip.Height - 1)
                    For X As Integer = 0 To (TmpMip.Width - 1)
                        Dim ColorOffset As Integer = Binary.ReadByte()
                        C = Color.Black
                        '## This seems a little wierd, it seems to be setting
                        '## color blue to transparent black??
                        If Palette(ColorOffset).Red = 0 AndAlso _
                           Palette(ColorOffset).Green = 0 AndAlso _
                           Palette(ColorOffset).Blue = 255 Then
                            C = Color.FromArgb(0, 0, 0, 0)
                        Else
                            'C is now poulated with the relevant RGB values from 
                            'it's corresponding index in the Palette array
                            C = Color.FromArgb(255, _
                                               Palette(ColorOffset).Red, _
                                               Palette(ColorOffset).Green, _
                                               Palette(ColorOffset).Blue)
                        End If
                        'The colour is painted on to the bitmap at the current X\Y location
                        ImageBitmap.SetPixel(X, Y, C)
                    Next
                Next

and finally saved

            Dim FileSave As String = TmpDir.Name
            'There are some odd bytes at the end of the file name, this is 
            ' removing a 0 byte
            FileSave = FileSave.Replace(Convert.ToChar(Convert.ToByte(0)), "")

            'Save our renderered texture

            If Not (Directory.Exists(OutDir)) Then Directory.CreateDirectory(OutDir)
            ImageBitmap.Save(OutDir & FileSave & ".png", Imaging.ImageFormat.Png)

The process is then repeated for each Mip Entry.

I hope this helps you understand the code you are looking at. The reason why I'm interested in this we project is because I am a self proclaimed byte basher... I love working with byte information in files... it's challenging to try and rip something apart from the inside.

@Deep Modi... Can you send me your WAD file, the one im using is limited to a 256 colour palette. I want to see what the one you are using is. I refuse to believe a modern game is using 256 colour textures.

You can use Wally, Decal Converter, or HI Tag Converter.
I am not using wad file, I have to create WAD File from PNG file and then all I need to Use that File.

I prefer Wally...

You mean, all you want to do is create a new WAD file, not update an existing one?

I've done it.... Just re-factoring and commenting.

Here you go, The complete solution. I've included a sample image with the correct dimensions etc (Multiples of 16) and a sample wad file to extract.

a2a51b2a0f14b66065888044384d6c14

I hope this works for you. Remember... Images dimensions X\Y MUST BE MULTIPLES OF 16. i've included a pre check option to help.

yes. Exactly the dimension should be multiple of 16 only. (X*Y must be less then 10752)

You send me old File.
WAD Editor is not the latest as you show image.
So please Get the Latest File to me...

And Yes I liked This.
According to Image, What I want is exactly that I was searching all about

In the image I show Checkbox. (Include Pre-Check)
What this do?

I hope you all do what i need, And if this is working then you should get the proper credits so after you give the correct file (that you updated)
PM me your Credits details:
Name, email, website, age, etc

Cant believe its the wrong zip. I'll upload when home.

Pre-check ensures basic things like correct image dimensions, prevent overwrite existing wad, image file exists etc

ok
Check This too then
the image shows you what dimension are valid.

Sorry, I forgot to tell that the WAD File Attributes should be changed
I mean the "Read Only" should be always Checked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.