public static bool LoadTexture(BinaryReader br, out LRFTexture texture) { texture = new LRFTexture(); texture.width = br.ReadUInt32(); texture.height = br.ReadUInt32(); texture.components = br.ReadUInt32(); texture.flags = (LRFTexture.Flags)br.ReadUInt32(); texture.level = br.ReadUInt32(); texture.size = br.ReadUInt64(); texture.data = br.ReadBytes((int)texture.size); return(true); }
public static LRFTexture LoadTexture(string path) { LRFTexture ret = null; FileStream fs = File.OpenRead(path); using (BinaryReader br = new BinaryReader(fs)) { if (!IsLRFFile(br)) { return(ret); } string id; UInt64 siz; while (true) { if (!ReadChunkHeader(br, out id, out siz)) { break; } switch (id) { case lrf_chunk_header: LRFHeader hdr; ReadHeader(br, out hdr); if (HeaderTypeToType(hdr.type) != Type.Texture) { ret = null; break; } break; case lrf_chunk_texture: LRFTexture texture; if (LoadTexture(br, out texture)) { ret = texture; break; } break; } } } return(ret); }