示例#1
0
        /// <summary>
        /// Load crosshair texture.
        /// </summary>
        private void LoadCrosshairTexture()
        {
            // Load crosshair image
            ImageFileReader reader = new ImageFileReader(host.Arena2Path);

            reader.LibraryType = LibraryTypes.Cif;
            DFImageFile crosshair       = reader.GetImageFile("PNTER.CIF");
            DFBitmap    crosshairBitmap = crosshair.GetBitmapFormat(4, 0, 0, DFBitmap.Formats.RGBA);

            // Create texture
            crosshairTexture = new Texture2D(
                host.GraphicsDevice,
                crosshairBitmap.Width,
                crosshairBitmap.Height,
                false,
                SurfaceFormat.Color);

            // Set data
            crosshairTexture.SetData <byte>(
                0,
                null,
                crosshairBitmap.Data,
                0,
                crosshairBitmap.Width * crosshairBitmap.Height * 4);
        }
        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);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Builds compass textures.
        /// </summary>
        private void BuildCompass()
        {
            // Load compass images
            ImageFileReader imageReader = new ImageFileReader(arena2Path);

            imageReader.LibraryType = LibraryTypes.Img;
            DFImageFile compass    = imageReader.GetImageFile("COMPASS.IMG");
            DFImageFile compassBox = imageReader.GetImageFile("COMPBOX.IMG");

            // Get DFBitmaps
            DFBitmap compassBitmap    = compass.GetBitmapFormat(0, 0, 0, DFBitmap.Formats.RGBA);
            DFBitmap compassBoxBitmap = compassBox.GetBitmapFormat(0, 0, 0, DFBitmap.Formats.RGBA);

            // Create textures
            compassTexture = new Texture2D(
                GraphicsDevice,
                compassBitmap.Width,
                compassBitmap.Height,
                false,
                SurfaceFormat.Color);
            compassBoxTexture = new Texture2D(
                GraphicsDevice,
                compassBoxBitmap.Width,
                compassBoxBitmap.Height,
                false,
                SurfaceFormat.Color);

            // Set data
            compassTexture.SetData <byte>(
                0,
                null,
                compassBitmap.Data,
                0,
                compassBitmap.Width * compassBitmap.Height * 4);
            compassBoxTexture.SetData <byte>(
                0,
                null,
                compassBoxBitmap.Data,
                0,
                compassBoxBitmap.Width * compassBoxBitmap.Height * 4);
        }
示例#4
0
        /// <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();
        }