OSDN Git Service

DTXManiaソリューション、DTXManiaプロジェクト、DTXCreatorプロジェクト、FDKプロジェクトについて英語化。
[dtxmania/dtxmania.git] / FDK17プロジェクト / コード / 04.グラフィック / CAvi.cs
diff --git a/FDK17プロジェクト/コード/04.グラフィック/CAvi.cs b/FDK17プロジェクト/コード/04.グラフィック/CAvi.cs
deleted file mode 100644 (file)
index e5fbd25..0000000
+++ /dev/null
@@ -1,306 +0,0 @@
-using System;\r
-using System.Collections.Generic;\r
-using System.Text;\r
-using System.Runtime.InteropServices;\r
-using System.Drawing;\r
-using SharpDX;\r
-\r
-namespace FDK\r
-{\r
-       public class CAvi : IDisposable\r
-       {\r
-               // プロパティ\r
-\r
-               public uint dwスケール \r
-               {\r
-                       get;\r
-                       set; \r
-               }\r
-               public uint dwレート\r
-               {\r
-                       get;\r
-                       set;\r
-               }\r
-               public uint nフレーム高さ\r
-               { \r
-                       get;\r
-                       set;\r
-               }\r
-               public uint nフレーム幅\r
-               {\r
-                       get;\r
-                       set; \r
-               }\r
-\r
-\r
-               // コンストラクタ\r
-\r
-               public CAvi( string filename )\r
-               {\r
-                       if ( AVIFileOpen( out this.aviFile, filename, OpenFileFlags.OF_READ, IntPtr.Zero ) != 0 )\r
-                       {\r
-                               this.Release();\r
-                               throw new Exception( "AVIFileOpen failed." );\r
-                       }\r
-                       if ( AVIFileGetStream( this.aviFile, out this.aviStream, streamtypeVIDEO, 0 ) != 0 )\r
-                       {\r
-                               this.Release();\r
-                               throw new Exception( "AVIFileGetStream failed." );\r
-                       }\r
-                       var info = new AVISTREAMINFO();\r
-                       AVIStreamInfo( this.aviStream, ref info, Marshal.SizeOf( info ) );\r
-                       this.dwレート = info.dwRate;\r
-                       this.dwスケール = info.dwScale;\r
-                       this.nフレーム幅 = info.rcFrame.right - info.rcFrame.left;\r
-                       this.nフレーム高さ = info.rcFrame.bottom - info.rcFrame.top;\r
-                       try\r
-                       {\r
-                               this.frame = AVIStreamGetFrameOpen( this.aviStream, 0 );\r
-                       }\r
-                       catch\r
-                       {\r
-                               this.Release();\r
-                               throw new Exception( "AVIStreamGetFrameOpen failed." );\r
-                       }\r
-               }\r
-\r
-\r
-               // メソッド\r
-\r
-               public static void t初期化()\r
-               {\r
-                       AVIFileInit();\r
-               }\r
-               public static void t終了()\r
-               {\r
-                       AVIFileExit();\r
-               }\r
-               \r
-               public Bitmap GetFrame( int no )\r
-               {\r
-                       if( this.aviStream == IntPtr.Zero )\r
-                               throw new InvalidOperationException();\r
-\r
-                       return BitmapUtil.ToBitmap( AVIStreamGetFrame( this.frame, no ) );\r
-               }\r
-               public int GetFrameNoFromTime( int time )\r
-               {\r
-                       return (int) ( time * ( ( (double) this.dwレート ) / ( 1000.0 * this.dwスケール ) ) );\r
-               }\r
-               public IntPtr GetFramePtr( int no )\r
-               {\r
-                       if( this.aviStream == IntPtr.Zero )\r
-                               throw new InvalidOperationException();\r
-\r
-                       return AVIStreamGetFrame( this.frame, no );\r
-               }\r
-               public int GetMaxFrameCount()\r
-               {\r
-                       if( this.aviStream == IntPtr.Zero )\r
-                               throw new InvalidOperationException();\r
-\r
-                       return AVIStreamLength( this.aviStream );\r
-               }\r
-               \r
-               public unsafe void tBitmap24ToGraphicsStreamR5G6B5( BitmapUtil.BITMAPINFOHEADER* pBITMAPINFOHEADER, DataStream gs, int nWidth, int nHeight )\r
-               {\r
-                       int nBmpWidth = pBITMAPINFOHEADER->biWidthビットマップの幅dot;\r
-                       int nBmpHeight = pBITMAPINFOHEADER->biHeightビットマップの高さdot;\r
-                       int nBmpLineByte = ( nBmpWidth * 3 ) + ( ( 4 - ( ( nBmpWidth * 3 ) % 4 ) ) % 4 );\r
-\r
-                       ushort* pTexture = (ushort*) gs.DataPointer.ToPointer();\r
-                       byte* pBitmap = (byte*) ( pBITMAPINFOHEADER + 1 );\r
-                       \r
-                       for( int i = 0; i < nBmpHeight; i++ )\r
-                       {\r
-                               if( i >= nHeight )\r
-                                       break;\r
-\r
-                               for( int j = 0; j < nBmpWidth; j++ )\r
-                               {\r
-                                       if( j >= nWidth )\r
-                                               break;\r
-\r
-                                       ushort B = (ushort) ( ( *( ( pBitmap + ( ( ( nBmpHeight - i ) - 1 ) * nBmpLineByte ) ) + ( j * 3 ) + 0 ) >> 3 ) & 0x1f );\r
-                                       ushort G = (ushort) ( ( *( ( pBitmap + ( ( ( nBmpHeight - i ) - 1 ) * nBmpLineByte ) ) + ( j * 3 ) + 1 ) >> 2 ) & 0x3f );\r
-                                       ushort R = (ushort) ( ( *( ( pBitmap + ( ( ( nBmpHeight - i ) - 1 ) * nBmpLineByte ) ) + ( j * 3 ) + 2 ) >> 3 ) & 0x1f );\r
-                                       *( pTexture + ( i * nWidth ) + j ) = (ushort) ( ( R << 11 ) | ( G << 5 ) | B );\r
-                               }\r
-                       }\r
-               }\r
-               public unsafe void tBitmap24ToGraphicsStreamX8R8G8B8( BitmapUtil.BITMAPINFOHEADER* pBITMAPINFOHEADER, DataStream ds, int nWidth, int nHeight )\r
-               {\r
-                       int nBmpWidth = pBITMAPINFOHEADER->biWidthビットマップの幅dot;\r
-                       int nBmpHeight = pBITMAPINFOHEADER->biHeightビットマップの高さdot;\r
-                       int nBmpLineByte = ( nBmpWidth * 3 ) + ( ( 4 - ( ( nBmpWidth * 3 ) % 4 ) ) % 4 );\r
-                       \r
-                       uint* pTexture = (uint*) ds.DataPointer.ToPointer();\r
-                       byte* pBitmap = (byte*) ( pBITMAPINFOHEADER + 1 );\r
-                       \r
-                       for( int i = 0; i < nBmpHeight; i++ )\r
-                       {\r
-                               if( i >= nHeight )\r
-                                       break;\r
-\r
-                               for( int j = 0; j < nBmpWidth; j++ )\r
-                               {\r
-                                       if( j >= nWidth )\r
-                                               break;\r
-\r
-                                       uint B = *( ( pBitmap + ( ( ( nBmpHeight - i ) - 1 ) * nBmpLineByte ) ) + ( j * 3 ) + 0 );\r
-                                       uint G = *( ( pBitmap + ( ( ( nBmpHeight - i ) - 1 ) * nBmpLineByte ) ) + ( j * 3 ) + 1 );\r
-                                       uint R = *( ( pBitmap + ( ( ( nBmpHeight - i ) - 1 ) * nBmpLineByte ) ) + ( j * 3 ) + 2 );\r
-                                       *( pTexture + ( i * nWidth ) + j ) = ( R << 16 ) | ( G << 8 ) | B;\r
-                               }\r
-                       }\r
-               }\r
-\r
-               #region [ Dispose-Finalize パターン実装 ]\r
-               //-----------------\r
-               public void Dispose()\r
-               {\r
-                       this.Dispose( true );\r
-                       GC.SuppressFinalize( this );            // 2011.8.19 from: 忘れてた。\r
-               }\r
-               protected void Dispose( bool disposeManagedObjects )\r
-               {\r
-                       if( this.bDispose完了済み )\r
-                               return;\r
-\r
-                       if( disposeManagedObjects )\r
-                       {\r
-                               // (A) Managed リソースの解放\r
-                       }\r
-\r
-                       // (B) Unamanaged リソースの解放\r
-\r
-                       if( this.frame != IntPtr.Zero )\r
-                               AVIStreamGetFrameClose( this.frame );\r
-\r
-                       this.Release();\r
-                       this.bDispose完了済み = true;\r
-               }\r
-               ~CAvi()\r
-               {\r
-                       this.Dispose( false );\r
-               }\r
-               //-----------------\r
-               #endregion\r
-\r
-\r
-               // その他\r
-\r
-               #region [ Win32 AVI関連関数インポート ]\r
-               //-----------------\r
-               internal enum OpenFileFlags : uint\r
-               {\r
-                       OF_CANCEL = 0x800,\r
-                       OF_CREATE = 0x1000,\r
-                       OF_DELETE = 0x200,\r
-                       OF_EXIST = 0x4000,\r
-                       OF_PARSE = 0x100,\r
-                       OF_PROMPT = 0x2000,\r
-                       OF_READ = 0,\r
-                       OF_READWRITE = 2,\r
-                       OF_REOPEN = 0x8000,\r
-                       OF_SHARE_COMPAT = 0,\r
-                       OF_SHARE_DENY_NONE = 0x40,\r
-                       OF_SHARE_DENY_READ = 0x30,\r
-                       OF_SHARE_DENY_WRITE = 0x20,\r
-                       OF_SHARE_EXCLUSIVE = 0x10,\r
-                       OF_VERIFY = 0x400,\r
-                       OF_WRITE = 1\r
-               }\r
-\r
-               [StructLayout( LayoutKind.Sequential, Pack = 1 )]\r
-               internal struct AVISTREAMINFO\r
-               {\r
-                       public uint fccType;\r
-                       public uint fccHandler;\r
-                       public uint dwFlags;\r
-                       public uint dwCaps;\r
-                       public ushort wPriority;\r
-                       public ushort wLanguage;\r
-                       public uint dwScale;\r
-                       public uint dwRate;\r
-                       public uint dwStart;\r
-                       public uint dwLength;\r
-                       public uint dwInitialFrames;\r
-                       public uint dwSuggestedBufferSize;\r
-                       public uint dwQuality;\r
-                       public uint dwSampleSize;\r
-                       public CAvi.RECT rcFrame;\r
-                       public uint dwEditCount;\r
-                       public uint dwFormatChangeCount;\r
-                       [MarshalAs( UnmanagedType.ByValArray, SizeConst = 0x40 )]\r
-                       public ushort[] szName;\r
-               }\r
-\r
-               [StructLayout( LayoutKind.Sequential, Pack = 1 )]\r
-               internal struct RECT\r
-               {\r
-                       public uint left;\r
-                       public uint top;\r
-                       public uint right;\r
-                       public uint bottom;\r
-               }\r
-\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern void AVIFileExit();\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern uint AVIFileGetStream( IntPtr pfile, out IntPtr ppavi, uint fccType, int lParam );\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern void AVIFileInit();\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern uint AVIFileOpen( out IntPtr ppfile, string szFile, OpenFileFlags mode, IntPtr pclsidHandler );\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern int AVIFileRelease( IntPtr pfile );\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern IntPtr AVIStreamGetFrame( IntPtr pgf, int lPos );\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern uint AVIStreamGetFrameClose( IntPtr pget );\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern IntPtr AVIStreamGetFrameOpen( IntPtr pavi, int lpbiWanted );\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern int AVIStreamInfo( IntPtr pavi, ref AVISTREAMINFO psi, int lSize );\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern int AVIStreamLength( IntPtr pavi );\r
-               [DllImport( "AVIFIL32" )]\r
-               private static extern int AVIStreamRelease( IntPtr pavi );\r
-               //-----------------\r
-               #endregion\r
-\r
-               #region [ private ]\r
-               //-----------------\r
-               private IntPtr aviFile = IntPtr.Zero;\r
-               private const string AVIFILE32 = "AVIFIL32";\r
-               private const int AVIGETFRAMEF_BESTDISPLAYFMT = 1;\r
-               private IntPtr aviStream = IntPtr.Zero;\r
-               private bool bDispose完了済み;\r
-               private IntPtr frame = IntPtr.Zero;\r
-               private static readonly uint streamtypeAUDIO = mmioFOURCC( 'a', 'u', 'd', 's' );\r
-               private static readonly uint streamtypeMIDI = mmioFOURCC( 'm', 'i', 'd', 's' );\r
-               private static readonly uint streamtypeTEXT = mmioFOURCC( 't', 'x', 't', 's' );\r
-               private static readonly uint streamtypeVIDEO = mmioFOURCC( 'v', 'i', 'd', 's' );\r
-\r
-               private static uint mmioFOURCC( char c0, char c1, char c2, char c3 )\r
-               {\r
-                       return ( (uint) c3 << 0x18 ) | ( (uint) c2 << 0x10 ) | ( (uint) c1 << 0x08 ) | (uint) c0;\r
-               }\r
-               private void Release()\r
-               {\r
-                       if( this.aviStream != IntPtr.Zero )\r
-                       {\r
-                               AVIStreamRelease( this.aviStream );\r
-                               this.aviStream = IntPtr.Zero;\r
-                       }\r
-                       if( this.aviFile != IntPtr.Zero )\r
-                       {\r
-                               AVIFileRelease( this.aviFile );\r
-                               this.aviFile = IntPtr.Zero;\r
-                       }\r
-               }\r
-               //-----------------\r
-               #endregion\r
-       }\r
-}\r