Quote:
Originally Posted by DeveloperJugs
oh! really bro? where's your proof? i am not like you bro :P
|
Then why don't you share it here?
Prove me wrong ;)
I could show people how to properly convert gtx files that are perfectly editable in a program that understands .tga and .dds. In fact here:
Code:
public static byte[] AdjustOutput(byte[] buff, out int offset)
{
offset = 0;
GfxType gfxtype = GetGfxType(buff, out offset);
if (buff.Length < 4)
return buff;
switch(gfxtype)
{
case GfxType.TGA:
offset = 3; // start of file follows "GEO" magic header
break;
case GfxType.DDS:
//replace "GEO " magic value with "DDS "
buff[0] = (byte)'D';
buff[1] = (byte)'D';
buff[2] = (byte)'S';
break;
}
return buff;
}
/*
* translate source buffer from GFX format to TGA or DDS as needed
*/
public static byte[] GetImageData(byte[] source)
{
byte[] output = new byte[0]; // in case things don't go well
int offset = 0;
source = AdjustOutput(source, out offset);
if (offset != 0)
output = new byte[source.Length - 4];
else
output = new byte[source.Length];
for (int i = 0; i < output.Length; i++)
output[i] = source[i + offset];
return output;
}
/*
* translate the buffer from TGA or DDS format to GFX format
*/
public static byte[] GetGfxData(byte[] source)
{
byte[] output = new byte[0]; // in case things don't go well
int offset = 0;
if (source[0] != 'D' && source[1] != 'D' && source[2] != 'S')
offset = 4;
output = new byte[source.Length + offset];
source.CopyTo(output, offset);
output[0] = (byte)'G';
output[1] = (byte)'E';
output[2] = (byte)'O';
if (offset == 4)
output[3] = (byte)0x00;
else
output[3] = (byte)' ';
return output;
}
/*
* Figure out the type of image in a .gfx file
* handles only .tgs and .dds type images
*/
public static GfxType GetGfxType(byte[] buff, out int offset)
{
offset = 0;
// if file content is nothing but a "GEO" header, nothing to do.
if (buff.Length < 4)
return GfxType.UNKNOWN; // unknown .gfx Type
if (buff[0] == 'G' && buff[1] == 'E' && buff[2] == 'O')
{
if (buff[3] == 0x00)
{
// this is a .tga (Targa) file
offset = 3; // start of file follows "GEO" magic header
return GfxType.TGA;
}
if (buff[3] == ' ' && buff[4] == 124)
{
return GfxType.DDS;
}
}
return GfxType.UNKNOWN;
}
public static void WriteFile(string target, byte[] buffer, int offset)
{
string dirs = Path.GetDirectoryName(target);
BinaryWriter bw = null;
try
{
Directory.CreateDirectory(dirs);
FileStream fs = new FileStream(target, FileMode.Create);
bw = new BinaryWriter(fs);
bw.Write(buffer, offset, (buffer.Length - offset));
bw.Flush();
}
catch (IOException e)
{ }
finally
{
if (bw != null)
bw.Close();
}
}
Quote:
Originally Posted by anoofy
why u don't share it ? aren't u Rohan God ?
i don't think u both want money too :D
|
Look up there ^
I don't need your money. I have plenty of my own.
What I won't tell you guys is how to pack it back into the gel/gem archives. I will let you jokers figure that out for yourselves.