public override void load(Stream stream) { aBinaryReader reader = new aBinaryReader(stream, Endianness.Big); mFormat = (gxTextureFormat)reader.Read8(); // 0000 mTransparency = reader.Read8(); // 0001 mWidth = reader.Read16(); // 0002 mHeight = reader.Read16(); // 0004 mWrapS = (gxWrapMode)reader.Read8(); // 0006 mWrapT = (gxWrapMode)reader.Read8(); // 0007 reader.Step(1); // 0008 (0001) mTlutFormat = (gxTlutFormat)reader.Read8(); // 0009 int tlutentrycount = reader.Read16(); // 000A long tlutoffset = reader.Read32(); // 000C mMipMap = (reader.Read8() != 0); // 0010 mEdgeLOD = (reader.Read8() != 0); // 0011 mBiasClamp = (reader.Read8() != 0); // 0012 mMaxAniso = (gxAnisotropy)reader.Read8(); // 0013 mMinFilter = (gxTextureFilter)reader.Read8(); // 0014 mMagFilter = (gxTextureFilter)reader.Read8(); // 0015 mMinLod = reader.ReadS8(); // 0016 mMaxLod = reader.ReadS8(); // 0017 mImageCount = reader.Read8(); // 0018 (0001) mLodBias = reader.ReadS16(); // 001A long texoffset = reader.Read32(); // 001C loadImageData(reader, texoffset); if (tlutentrycount > 0) { loadPaletteData(reader, tlutentrycount, tlutoffset); } }
public GlyphBlock(aBinaryReader reader) { firstCode = reader.Read16(); // 0008 lastCode = reader.Read16(); // 000A cellWidth = reader.Read16(); // 000C cellHeight = reader.Read16(); // 000E sheetSize = reader.ReadS32(); // 0010 sheetFormat = (gxTextureFormat)reader.Read16(); // 0014 sheetRow = reader.Read16(); // 0016 sheetColumn = reader.Read16(); // 0018 sheetWidth = reader.Read16(); // 001A sheetHeight = reader.Read16(); // 001C reader.Step(2); // 001E // we have to manually calculate how many sheets there are int sheetCount = (((lastCode - firstCode) / (sheetRow * sheetColumn)) + 1); sheets = aCollection.Initialize(sheetCount, () => reader.Read8s(sheetSize)); }
public static object loadImageData(aBinaryReader reader, int width, int height, gxTextureFormat format) { switch (format) { case gxTextureFormat.I4: return(loadI4(reader, width, height)); case gxTextureFormat.I8: return(loadI8(reader, width, height)); case gxTextureFormat.IA4: return(loadIA4(reader, width, height)); case gxTextureFormat.IA8: return(loadIA8(reader, width, height)); case gxTextureFormat.RGB565: return(loadRGB565(reader, width, height)); case gxTextureFormat.RGB5A3: return(loadRGB5A3(reader, width, height)); case gxTextureFormat.RGBA8: return(loadRGBA8(reader, width, height)); case gxTextureFormat.CI4: return(loadCI4(reader, width, height)); case gxTextureFormat.CI8: return(loadCI8(reader, width, height)); case gxTextureFormat.CI14X2: return(loadCI14X2(reader, width, height)); case gxTextureFormat.CMPR: return(loadCMPR(reader, width, height)); default: { throw new NotImplementedException(String.Format("Encountered an unimplemented texture format {0}.", format)); } } }
public static object loadImageData(Stream stream, Endianness endianness, int width, int height, gxTextureFormat format) { var reader = new aBinaryReader(stream, endianness); return(loadImageData(reader, width, height, format)); }
public static object loadImageData(byte[] data, long index, Endianness endianness, int width, int height, gxTextureFormat format) { using (var stream = new MemoryStream(data)) { stream.Seek(index, SeekOrigin.Begin); return(loadImageData(stream, endianness, width, height, format)); } }
// these return an instance of type aRGBA[] if the format is a non-paletted texture format; // for indexed texture formats, these functions return a short[] containing the palette-index data public static object loadImageData(byte[] data, Endianness endianness, int width, int height, gxTextureFormat format) { return(loadImageData(data, 0, endianness, width, height, format)); }