/// <summary> /// GOING TO CHANGE /// </summary> /// <param name="data"></param> /// <returns></returns> public static DDSPreview GetAllButDXT3DDSData(byte[] data) { if (data == null) { DebugOutput.PrintLn("Unable to access file or invalid file."); return null; } DDSPreview ddsimg = new DDSPreview(data); return ddsimg; }
/// <summary> /// Check that texture format is what we want. PROBABLY GONNA BE REPLACED! /// </summary> /// <param name="newtexture">Path to new texture file.</param> /// <param name="desiredformat">Format retrieved from tree, to which newtexture must conform.</param> /// <returns>Format of new texture as string, empty string if not correct, BORKED if something broke.</returns> public static bool CheckTextureFormat(byte[] data, string desiredformat, out string format) { format = null; try { // KFreon: Load image to DDS to test its format DDSPreview dds = new DDSPreview(data); format = dds.FormatString; return CheckTextureFormat(format, desiredformat); } catch { return false; } }
/// <summary> /// Check that new texture contains enough mips. /// </summary> /// <param name="newtexture">Path to texture to load.</param> /// <param name="ExpectedMips">Number of expected mips.</param> /// <returns>True if number of mips is valid.</returns> public static bool CheckTextureMips(string newtexture, int ExpectedMips, out int numMips) { numMips = 0; try { DDSPreview dds = new DDSPreview(File.ReadAllBytes(newtexture)); numMips = (int)dds.NumMips; if (ExpectedMips > 1) { if (dds.NumMips < ExpectedMips) return false; else return true; } else return true; } catch { return false; } }
public static Bitmap DDSCheck(abstractTexInfo tmpTex, byte[] data) { DDSPreview dds = new DDSPreview(data); tmpTex.NumMips = (int)dds.NumMips; tmpTex.Format = dds.FormatString; byte[] datat = dds.GetMipData(); Bitmap retval = DDSImage.ToBitmap(datat, (dds.FormatString == "G8") ? DDSFormat.G8 : dds.Format, (int)dds.Width, (int)dds.Height); dds = null; return retval; }