public static Tuple <G_IM_FMT, G_IM_SIZ> ConvertFormat(N64TexFormat format) { switch (format) { case N64TexFormat.RGBA16: return(new Tuple <G_IM_FMT, G_IM_SIZ>(G_IM_FMT.G_IM_FMT_RGBA, G_IM_SIZ.G_IM_SIZ_16b)); case N64TexFormat.RGBA32: return(new Tuple <G_IM_FMT, G_IM_SIZ>(G_IM_FMT.G_IM_FMT_RGBA, G_IM_SIZ.G_IM_SIZ_32b)); case N64TexFormat.IA16: return(new Tuple <G_IM_FMT, G_IM_SIZ>(G_IM_FMT.G_IM_FMT_IA, G_IM_SIZ.G_IM_SIZ_16b)); case N64TexFormat.IA8: return(new Tuple <G_IM_FMT, G_IM_SIZ>(G_IM_FMT.G_IM_FMT_IA, G_IM_SIZ.G_IM_SIZ_8b)); case N64TexFormat.IA4: return(new Tuple <G_IM_FMT, G_IM_SIZ>(G_IM_FMT.G_IM_FMT_IA, G_IM_SIZ.G_IM_SIZ_4b)); case N64TexFormat.I8: return(new Tuple <G_IM_FMT, G_IM_SIZ>(G_IM_FMT.G_IM_FMT_I, G_IM_SIZ.G_IM_SIZ_8b)); case N64TexFormat.I4: return(new Tuple <G_IM_FMT, G_IM_SIZ>(G_IM_FMT.G_IM_FMT_I, G_IM_SIZ.G_IM_SIZ_4b)); case N64TexFormat.CI8: return(new Tuple <G_IM_FMT, G_IM_SIZ>(G_IM_FMT.G_IM_FMT_CI, G_IM_SIZ.G_IM_SIZ_8b)); case N64TexFormat.CI4: return(new Tuple <G_IM_FMT, G_IM_SIZ>(G_IM_FMT.G_IM_FMT_CI, G_IM_SIZ.G_IM_SIZ_4b)); default: throw new N64TextureException("Invalid Format"); } }
public TextureHolder(string name, int w, int h, N64TexFormat format, byte[] tex) : base(name) { Width = w; Height = h; Format = format; Tlut = null; SetData(tex); }
private void UpdateTexture(object sender = null, EventArgs e = null) { N64TexFormat fmt = (N64TexFormat)comboBoxTexFmt.SelectedIndex; int w = (int)valueW.Value; int h = (int)valueH.Value; int texSize = N64Texture.GetTexSize(w * h, fmt); if (!uint.TryParse(textBoxTexAddr.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint texAddr)) { return; } byte[] tlut = null; if ((fmt == N64TexFormat.CI4 || fmt == N64TexFormat.CI8) && uint.TryParse(textBoxTlutAddr.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint tlutAddr)) { try { if (fmt == N64TexFormat.CI4) { tlut = ReadBytes(tlutAddr, 64); } else if (fmt == N64TexFormat.CI8) { tlut = ReadBytes(tlutAddr, 256); } } catch (Exception) { return; } } try { byte[] tex = ReadBytes(texAddr, texSize); textureBox1.Image = N64Texture.DecodeBitmap(w, h, fmt, tex, tlut); } catch (Exception) { return; } }
public void SetBitmap(Bitmap bmp, N64TexFormat format) { throw new NotImplementedException(); }
public static unsafe byte[] EncodeBitmap(Bitmap bmp, N64TexFormat format) { var a = ConvertFormat(format); return(EncodeBitmap(bmp, a.Item1, a.Item2)); }
public static Bitmap DecodeBitmap(int w, int h, N64TexFormat format, byte[] buff, byte[] tlut = null) { var a = ConvertFormat(format); return(DecodeBitmap(w, h, a.Item1, a.Item2, buff, tlut)); }
public static int GetTexSize(int texels, N64TexFormat format) { var a = ConvertFormat(format); return(GetTexSize(texels, a.Item2)); }