private void ShowMeshTextures() { // Clear texture flow panel TexturesPanel.Controls.Clear(); // Get the mesh data DFMesh mesh = arch3dFile.GetMesh(MeshIndexTrackBar.Value); // Loop through all submeshes foreach (DFMesh.DFSubMesh sm in mesh.SubMeshes) { // Load texture file string FileName = TextureFile.IndexToFileName(sm.TextureArchive); MyImageFileReader.LoadFile(FileName); // Get texture file DFImageFile textureFile = MyImageFileReader.ImageFile; // Get managed bitmap Bitmap bm = textureFile.GetManagedBitmap(sm.TextureRecord, 0, true, false); // Create a new picture box PictureBox pb = new PictureBox(); pb.Width = bm.Width; pb.Height = bm.Height; pb.Image = bm; // Add picture box to flow panel TexturesPanel.Controls.Add(pb); } }
private void ShowImageFile(string FileName) { // Clear panel ImagesPanel.Controls.Clear(); // Get image file DFImageFile imageFile = MyImageFileReader.GetImageFile(FileName); // Set description DescriptionLabel.Text = imageFile.Description; // Loop through all records for (int r = 0; r < imageFile.RecordCount; r++) { // Loop through each frame for this record for (int f = 0; f < imageFile.GetFrameCount(r); f++) { // Get managed bitmap Bitmap bm = imageFile.GetManagedBitmap(r, f, false, true); // Create a new picture box PictureBox pb = new PictureBox(); pb.Width = bm.Width; pb.Height = bm.Height; pb.Image = bm; // Add picture box to flow panel ImagesPanel.Controls.Add(pb); } } }
/// <summary> /// Sets the texture preview from specified index. /// </summary> /// <param name="terrain">Terrain component.</param> /// <param name="index">Texture index.</param> /// <param name="pictureBox">Picture box to receive image.</param> private void SetTexturePreview(QuadTerrainComponent terrain, int index, PictureBox pictureBox) { // Get texture description from index QuadTerrainComponent.DaggerfallTerrainTexture textureDesc = terrain.GetDaggerfallTexture(index); // Get Daggerfall image file imageReader.LibraryType = LibraryTypes.Texture; DFImageFile imageFile = imageReader.GetImageFile(TextureFile.IndexToFileName(textureDesc.Archive)); // Get managed bitmap and set on picture box Bitmap textureBitmap = imageFile.GetManagedBitmap(textureDesc.Record, 0, true, false); pictureBox.Image = textureBitmap; pictureBox.Refresh(); }
static void Main(string[] args) { // Specify Arena2 path of local Daggerfall installation string MyArena2Path = "C:\\dosgames\\DAGGER\\ARENA2"; // Instantiate ImageFileReader ImageFileReader MyImageFileReader = new ImageFileReader(MyArena2Path); // Set desired library type MyImageFileReader.LibraryType = LibraryTypes.Texture; // Load TEXTURE.285 file MyImageFileReader.LoadFile("TEXTURE.285"); // Output some information about this file Console.WriteLine("Image file {0} has {1} records", MyImageFileReader.FileName, MyImageFileReader.RecordCount); // Get image file to work with DFImageFile imageFile = MyImageFileReader.ImageFile; // Loop through all records for (int r = 0; r < imageFile.RecordCount; r++) { // Output some information about this record int frameCount = imageFile.GetFrameCount(r); Size sz = imageFile.GetSize(r); Console.WriteLine("Record {0} has {1} frames and is {2}x{3} pixels", r, frameCount, sz.Width, sz.Height); // Get first frame of record as a managed bitmap Bitmap managedBitmap = imageFile.GetManagedBitmap(r, 0, true, false); } }
private void BuildLayoutArray() { // Exit if image file not set if (null == MyDFImageFile) { return; } // Count total image items from all records and frames int ItemCount = 0; for (int record = 0; record < MyDFImageFile.RecordCount; record++) { if (!IsAnimatedValue) { // Count each frame as an item if not animated int frameCount = MyDFImageFile.GetFrameCount(record); for (int frame = 0; frame < frameCount; frame++) { ItemCount++; } } else { // Just increment count ItemCount++; } } // Create layout array MyLayout = new LayoutItem[ItemCount]; // Add bitmaps to layout array int curItem = 0; for (int record = 0; record < MyDFImageFile.RecordCount; record++) { // Get frame count and skip record with zero frames (no image) int FrameCount = MyDFImageFile.GetFrameCount(record); if (0 == FrameCount) { continue; } if (AnimateImages && FrameCount > 1) { // Create managed bitmap array MyLayout[curItem].ManagedBitmaps = new Bitmap[FrameCount]; // Add all frames for (int frame = 0; frame < FrameCount; frame++) { MyLayout[curItem].ManagedBitmaps[frame] = DFImageFile.GetManagedBitmap(record, frame, false, Transparency); } // Store details MyLayout[curItem].IsAnimated = true; MyLayout[curItem].Record = record; MyLayout[curItem].Frame = -1; MyLayout[curItem].FrameCount = FrameCount; MyLayout[curItem].CurrentFrame = 0; // Increment curItem++; } else { // Create new layout item MyLayout[curItem] = new LayoutItem(); // Add each frame as a single item for (int frame = 0; frame < FrameCount; frame++) { // Create managed bitmap array MyLayout[curItem].ManagedBitmaps = new Bitmap[1]; // Get single frame Bitmap bitmap = DFImageFile.GetManagedBitmap(record, frame, false, Transparency); // Store details MyLayout[curItem].IsAnimated = false; MyLayout[curItem].ManagedBitmaps[0] = bitmap; MyLayout[curItem].Record = record; MyLayout[curItem].Frame = frame; MyLayout[curItem].FrameCount = FrameCount; MyLayout[curItem].CurrentFrame = 0; // Increment curItem++; } } } // Reset mouse over and selected indices MyMouseOverIndex = -1; MySelectedIndex = -1; RaiseSelectedImageChangedEvent(); }