void LoadResources() { // Get background image and store base palette ImgFile img = new ImgFile(Path.Combine(DaggerfallUnity.Arena2Path, backgroundFile), FileUsage.UseMemory, true); backgroundBitmap = img.GetDFBitmap(0, 0); basePalette = backgroundBitmap.Palette; // Get scroll images and set palette GfxFile scroll0 = new GfxFile(Path.Combine(DaggerfallUnity.Arena2Path, scroll0File), FileUsage.UseMemory, true); GfxFile scroll1 = new GfxFile(Path.Combine(DaggerfallUnity.Arena2Path, scroll1File), FileUsage.UseMemory, true); scroll0.Palette = basePalette; scroll1.Palette = basePalette; // Build color buffers for all scroll frames ahead of time scrollFrames = new ScrollFrame[scrollFrameCount]; for (int frame = 0; frame < scrollFrameCount; frame++) { if (frame < 8) { scrollFrames[frame].colors = scroll0.GetColor32(0, frame); } else { scrollFrames[frame].colors = scroll1.GetColor32(0, frame - 8); } } }
/// <summary> /// Read palette for specified record. /// </summary> /// <param name="index">Index of palette.</param> private void ReadPalette(int index) { // Read palette data if not already stored if (null == palettes[index]) { BinaryReader Reader = managedFile.GetReader(paletteDataPosition + (776 * index) + 8); palettes[index] = new DFPalette(); palettes[index].Read(ref Reader); } }
/// <summary> /// Get extracted PAK data as a managed bitmap. /// </summary> /// <returns>Bitmap object.</returns> public Bitmap GetManagedBitmap() { DFBitmap bmp = GetDFBitmap(); DFImageFile img = new ImgFile(); DFPalette pal = new DFPalette(); pal.MakeGrayscale(); img.Palette = pal; return(img.GetManagedBitmap(ref bmp, true, false)); }
Texture2D GetBackgroundTexture() { DFPalette palette = new DFPalette(basePalette); // TODO: Set mage, rogue, warrior values backgroundBitmap.Palette = palette; Texture2D backgroundTexture = new Texture2D((int)mainPanelSize.x, (int)mainPanelSize.y); backgroundTexture.SetPixels32(backgroundBitmap.GetColor32()); backgroundTexture.Apply(); backgroundTexture.filterMode = DaggerfallUI.Instance.GlobalFilterMode; return(backgroundTexture); }
/// <summary> /// Load constructor with palette assignment. /// Some IMG files contain palette information, this will overwrite the specified palette. /// </summary> /// <param name="filePath">Absolute path to *.IMG file.</param> /// <param name="usage">Specify if file will be accessed from disk, or loaded into RAM.</param> /// <param name="palette">Palette to use when building images.</param> /// <param name="readOnly">File will be read-only if true, read-write if false.</param> public ImgFile(string filePath, FileUsage usage, DFPalette palette, bool readOnly) { myPalette = palette; Load(filePath, usage, readOnly); }
/// <summary> /// Load constructor with palette assignment. /// </summary> /// <param name="FilePath">Absolute path to *.CIF or *.RCI file.</param> /// <param name="Usage">Specify if file will be accessed from disk, or loaded into RAM.</param> /// <param name="Palette">Palette to use when building images.</param> /// <param name="ReadOnly">File will be read-only if true, read-write if false.</param> public CifRciFile(string FilePath, FileUsage Usage, DFPalette Palette, bool ReadOnly) { MyPalette = Palette; Load(FilePath, Usage, ReadOnly); }