public PcxFile GetPicture() { if (Type != DataType.Image) { return(null); } if (cachedPicture != null) { return(cachedPicture); } cachedPicture = new PcxFile(); if (cachedPicture.Load(Data)) { return(cachedPicture); } throw new System.Exception("unknown error"); }
public bool Load() { if (Ready) { return(true); } Archive = new DatFile(ArchiveFile); // unpack archive if (!Archive.Unpack()) { Error = "Processing archive failed: " + Archive.Error; return(false); } // load frame pcx which contains the main game palette DatFileEntry framePcx = Archive.GetByName(PcxContainingMainPalette); if (framePcx == null) { Error = $"Unable to find '{PcxContainingMainPalette}'"; return(false); } try { PcxFile pcx = framePcx.GetPicture(); MainPalette = (Color[])pcx.Palette.Clone(); MainPalette[0] = Color.Transparent; } catch (Exception e) { Error = $"Failed to decode PCX image '{PcxContainingMainPalette}': {e.Message}"; return(false); } Ready = true; return(true); }