Ejemplo n.º 1
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="device"></param>
 /// <param name="stream"></param>
 /// <param name="pa"></param>
 public ImageResource(PPDDevice device, Stream stream, bool pa)
 {
     try
     {
         using (var memoryStream = new MemoryStream())
         {
             byte[] bytes = new byte[1024 * 1024];
             while (stream.Position < stream.Length)
             {
                 var bytesRead = stream.Read(bytes, 0, bytes.Length);
                 if (bytesRead == 0)
                 {
                     break;
                 }
             }
             memoryStream.Seek(0, SeekOrigin.Begin);
             var ii = ImageInformation.FromMemory(memoryStream.ToArray());
             this.width     = ii.Width;
             this.height    = ii.Height;
             this.halfPixel = new Vector2(0.5f / this.width, 0.5f / this.height);
             this.texture   = (Texture.DX11.Texture)TextureFactoryManager.Factory.FromStream(device, stream, this.width, this.height, pa);
             CreateVertexBuffer(device);
         }
     }
     catch
     {
         MessageBox.Show(PPDExceptionContentProvider.Provider.GetContent(PPDExceptionType.ImageReadError));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// リソースを処分します
 /// </summary>
 protected override void DisposeResource()
 {
     if (texture != null)
     {
         texture.Dispose();
         texture = null;
     }
     if (vertices != null)
     {
         vertices.Dispose();
         vertices = null;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="device"></param>
 /// <param name="filename">ファイルパス</param>
 /// <param name="pa"></param>
 public ImageResource(PPDDevice device, string filename, bool pa)
 {
     try
     {
         this.filename = filename;
         var ii = ImageInformation.FromFile(filename);
         this.width     = ii.Width;
         this.height    = ii.Height;
         this.halfPixel = new Vector2(0.5f / this.width, 0.5f / this.height);
         this.texture   = (Texture.DX11.Texture)TextureFactoryManager.Factory.FromFile(device, filename, this.width, this.height, pa);
         CreateVertexBuffer(device);
     }
     catch
     {
         MessageBox.Show(PPDExceptionContentProvider.Provider.GetContent(PPDExceptionType.ImageReadError) + System.Environment.NewLine + filename);
     }
 }