private void AddBitmap(DirectDrawSurfaceStream Surface)
        {
            Array.Resize<H2BitmapCollection.BitmapData>(ref LoadedTagMeta.Bitmaps, LoadedTagMeta.Bitmaps.Length + 1);
            H2BitmapCollection.BitmapData bitmap = new H2BitmapCollection.BitmapData();

            bitmap.Width = (short)Surface.SurfaceDescription.dwWidth;
            bitmap.Height = (short)Surface.SurfaceDescription.dwHeight;
            bitmap.Depth = (short)Surface.SurfaceDescription.dwDepth;
            bitmap.MIPMapCount = (short)Surface.SurfaceDescription.dwMipMapCount;
            bitmap.Format = Surface.GetFormat();
            bitmap.Flags = bitmap.Width % 2 == 0 && bitmap.Height % 2 == 0 ? H2BitmapCollection.BitmapData.EFlags.Power_Of_2_Dimensions : 0;
            bitmap.LOD1Offset = LoadedTags[CurrentTagIndex].RawInfos.Length;

            LoadedTagMeta.Bitmaps[LoadedTagMeta.Bitmaps.Length - 1] = bitmap;

            LoadedTags[CurrentTagIndex].AddRaw(Surface.GetData()); 
            
            MemoryStream memStream = new MemoryStream();
            LoadedTagMeta.Serialize(memStream, 0, H2BitmapCollection.SizeOf, 0);
            LoadedTags[CurrentTagIndex].TagStream = memStream;

            CurrentTagIndex = CurrentTagIndex;
        }
 private void LoadBitmapStream()
 {
     xnaBitmapViewer2.ClearTextures();
     int rawInfoIndex = LoadedTagMeta.Bitmaps[CurrentBitmapIndex].LOD1Offset;
     if ((rawInfoIndex & 0xC0000000) == 0x00000000)
     {
         BinaryReader binReader = new BinaryReader(LoadedTags[CurrentTagIndex].RawStream);
         LoadedTags[CurrentTagIndex].RawStream.Position = LoadedTags[CurrentTagIndex].RawInfos[rawInfoIndex].Address;
         byte[] Buffer = new byte[LoadedTags[CurrentTagIndex].RawInfos[rawInfoIndex].Length];
         binReader.Read(Buffer, 0, Buffer.Length);
         DirectDrawSurfaceStream SurfaceStream = new DirectDrawSurfaceStream();
         switch (LoadedTagMeta.Bitmaps[CurrentBitmapIndex].Type)
         {
             case H2BitmapCollection.EType.TEXTURES_2D:
                 xnaBitmapViewer2.LoadTexture2D(TextureLoader.LoadTexture(xnaBitmapViewer2.Device, LoadedTagMeta.Bitmaps[CurrentBitmapIndex], Buffer), LoadedTagMeta.Bitmaps[CurrentBitmapIndex].Height, LoadedTagMeta.Bitmaps[CurrentBitmapIndex].Width);
                 break;
             case H2BitmapCollection.EType.CUBEMAPS:
                 xnaBitmapViewer2.LoadCubemap(TextureLoader.LoadCubemap(xnaBitmapViewer2.Device, LoadedTagMeta.Bitmaps[CurrentBitmapIndex], Buffer));
                 break;
         }
     }
 }
Example #3
0
 private void toolStripButton5_Click(object sender, EventArgs e)
 {
     if (openDialog.ShowDialog() == DialogResult.OK)
     {
         FileStream File = new FileStream(openDialog.FileName, FileMode.Open);
         byte[] Buffer = new byte[File.Length];
         File.Read(Buffer, 0, Buffer.Length);
         File.Close();
         DirectDrawSurfaceStream Surface = new DirectDrawSurfaceStream(Buffer);
         AddBitmap(Surface);
         RefreshBitmapInformation();
     }
 }