伸进女同桌乳沟里摸爽了,小雪解开乳罩给老杨摸,少妇被按摩师摸高潮了,亲嘴扒胸摸屁股激烈视频,强摸秘书人妻大乳BD,摸BBB揉BBB揉BBB视频

新疆軟件開發(fā)

本站首頁 軟件開發(fā) 成功案例 公司新聞 公司簡介 客服中心 軟件技術(shù) 網(wǎng)站建設(shè)
  您現(xiàn)在的位置: 新疆二域軟件開發(fā)公司 >> .Net技術(shù) >> 文章正文

C#如何轉(zhuǎn)換AVI文件為BMP位圖文件


在Windows系統(tǒng)中,借助于API之利,我們能夠輕易的實(shí)現(xiàn)AVI文件的分解與重組。下面,我給出一個(gè)C#版本的AVI分解示例。
AVI英文全稱為Audio Video Interleaved,即音頻視頻交錯(cuò)格式。它是一種將語音和影像同步組合在一起的文件格式。AVI支持256色和RLE壓縮,主要應(yīng)用在多媒體光盤上,主要用來保存電視、電影等各種影像信息。
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.IO;
namespace org.loon.util
...{
/**//// <summary>
/// org.loon.util.AVIUtil 用于AVI文件處理 
/// </summary>
 public class AVIUtil...{
                   [StructLayout(LayoutKind.Sequential, Pack = 1)]
                       struct BITMAPFILEHEADER
                   ...{
                       public ushort bfType;
                       public uint bfSize;
                       public ushort bfReserved1;
                       public ushort bfReserved2;
                       public uint bfOffBits;
                   }

                   [StructLayout(LayoutKind.Sequential, Pack = 1)]
                       struct BITMAPINFOHEADER
                   ...{
                       public uint biSize;
                       public int biWidth;
                       public int biHeight;
                       public ushort biPlanes;
                       public ushort biBitCount;
                       public uint biCompression;
                       public uint biSizeImage;
                       public int biXPelsPerMeter;
                       public int biYPelsPerMeter;
                       public uint biClrUsed;
                       public uint biClrImportant;
                       public const int BI_RGB = 0;
                   }

                   const uint DIB_RGB_COLORS = 0;

                   const uint DIB_PAL_COLORS = 1; 

            /**//// <summary>
            /// 對象轉(zhuǎn)換
            /// </summary>
            /// <param name="pBITMAPINFOHEADER"></param>
            /// <returns></returns>
                   public static Bitmap ToBitmap(IntPtr pBITMAPINFOHEADER)
                   ...{
                       unsafe
                       ...{
                           BITMAPINFOHEADER* pbmi = (BITMAPINFOHEADER*)pBITMAPINFOHEADER;
                           BITMAPFILEHEADER pbmfi;
                           pbmfi.bfType = (int)’M’ << 8 | (int)’B’;
                           pbmfi.bfOffBits = (uint)(sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER));
                           pbmfi.bfSize = pbmfi.bfOffBits + pbmi->biSizeImage;

                           MemoryStream stream = new MemoryStream();
                           BinaryWriter bw = new BinaryWriter(stream);
                           byte[] data = new byte[sizeof(BITMAPFILEHEADER)];
                           Marshal.Copy((IntPtr)(&pbmfi), data, 0, data.Length);
                           bw.Write(data);

                           data = new byte[sizeof(BITMAPINFOHEADER)];
                           Marshal.Copy(pBITMAPINFOHEADER, data, 0, data.Length);
                           bw.Write(data);

                           data = new byte[pbmi->biSizeImage];
                           ++pbmi;
                           Marshal.Copy((IntPtr)pbmi, data, 0, data.Length);
                           bw.Write(data);
                           bw.Flush();
                           bw.BaseStream.Position = 0;

                           return new Bitmap(bw.BaseStream);
                       }
                   }
               }

        /**//// <summary>
        /// AviFile,用于AVI文件處理
        /// </summary>
        public class AviFile : IDisposable
        ...{
            const string AVIFILE32 = "AVIFIL32";
            const int AVIGETFRAMEF_BESTDISPLAYFMT = 1;

            internal enum OpenFileFlags : uint
            ...{
                OF_READ = 0x00000000,
                OF_WRITE = 0x00000001,
                OF_READWRITE = 0x00000002,
                OF_SHARE_COMPAT = 0x00000000,
                OF_SHARE_EXCLUSIVE = 0x00000010,
                OF_SHARE_DENY_WRITE = 0x00000020,
                OF_SHARE_DENY_READ = 0x00000030,
                OF_SHARE_DENY_NONE = 0x00000040,
                OF_PARSE = 0x00000100,
                OF_DELETE = 0x00000200,
                OF_VERIFY = 0x00000400,
                OF_CANCEL = 0x00000800,
                OF_CREATE = 0x00001000,
                OF_PROMPT = 0x00002000,
                OF_EXIST = 0x00004000,
                OF_REOPEN = 0x00008000,
            }


            [DllImport(AVIFILE32)]
            extern internal static void AVIFileInit();

            [DllImport(AVIFILE32)]
            extern internal static void AVIFileExit();

            [DllImport(AVIFILE32)]
            extern internal static uint AVIFileOpen(out IntPtr ppfile, string szFile, OpenFileFlags mode, IntPtr pclsidHandler);

            [DllImport(AVIFILE32)]
            extern internal static int AVIFileRelease(IntPtr pfile);

            [DllImport(AVIFILE32)]
            extern internal static uint AVIFileGetStream(IntPtr pfile, out IntPtr ppavi, uint fccType, int lParam);

            [DllImport(AVIFILE32)]
            extern internal static int AVIStreamRelease(IntPtr pavi);

            [DllImport(AVIFILE32)]
            extern internal static IntPtr AVIStreamGetFrameOpen(IntPtr pavi, int lpbiWanted);

            [DllImport(AVIFILE32)]
            extern internal static IntPtr AVIStreamGetFrame(IntPtr pgf, int lPos);

            [DllImport(AVIFILE32)]
            extern internal static int AVIStreamLength(IntPtr pavi); 
            [DllImport(AVIFILE32)]
            extern internal static uint AVIStreamGetFrameClose(IntPtr pget); =
           static uint mmioFOURCC(char c0, char c1, char c2, char c3)
            ...{
                return (uint)c3 << 24 | (uint)c2 << 16 | (uint)c1 << 8 | (uint)c0;
            }

            static readonly uint streamtypeVIDEO = mmioFOURCC(’v’, ’i’, ’d’, ’s’);
            static readonly uint streamtypeAUDIO = mmioFOURCC(’a’, ’u’, ’d’, ’s’);
            static readonly uint streamtypeMIDI = mmioFOURCC(’m’, ’i’, ’d’, ’s’);
            static readonly uint streamtypeTEXT = mmioFOURCC(’t’, ’x’, ’t’, ’s’);

            IntPtr aviFile = IntPtr.Zero;
            IntPtr aviStream = IntPtr.Zero;
            bool disposed = false;

            public static void Initialize()
            ...{
                AVIFileInit();
            }

            public static void Terminate()
            ...{
                AVIFileExit();
            }

            public AviFile(string filename)
            ...{
                uint result;
                result = AVIFileOpen(out aviFile, filename, OpenFileFlags.OF_READ, IntPtr.Zero);
                if (result != 0)
                ...{
                    Release();
                    throw new Exception("AVIFileOpen failure.");
                }

                result = AVIFileGetStream(aviFile, out aviStream, streamtypeVIDEO, 0);
                if (result != 0)
                ...{
                    Release();
                    throw new Exception("AVIFileGetStream failure.");
                }
            }

            ~AviFile()
            ...{
                Dispose(false);
            }

            void Release()
            ...{
                if (aviStream != IntPtr.Zero)
                ...{
                    AVIStreamRelease(aviStream);
                    aviStream = IntPtr.Zero;
                }

                if (aviFile != IntPtr.Zero)
                ...{
                    AVIFileRelease(aviFile);
                    aviFile = IntPtr.Zero;
                }
            }

            public int GetMaxFrameCount()
            ...{
                if (aviStream == IntPtr.Zero)
                    throw new InvalidOperationException();
                return AVIStreamLength(aviStream);
            }

            public Bitmap GetFrame(int no)
            ...{
                if (aviStream == IntPtr.Zero)
                    throw new InvalidOperationException();

                IntPtr frame = IntPtr.Zero;
                try
                ...{
                    frame = AVIStreamGetFrameOpen(aviStream, AVIGETFRAMEF_BESTDISPLAYFMT);
                    IntPtr pbmi = AVIStreamGetFrame(frame, no);
                    return org.loon.util.AVIUtil.ToBitmap(pbmi);

                }
                finally
                ...{
                    if (frame != IntPtr.Zero)
                        AVIStreamGetFrameClose(frame);
                }
            }

            protected void Dispose(bool disposing)
            ...{
                if (disposed)
                    return;
                disposed = true;
                Release();
            }

            public void Dispose()
            ...{
                //不讓垃圾回收器終止指定對象(即不將指定對象調(diào)入終止序列中)
                GC.SuppressFinalize(this);
                Dispose(true);
            }

        }
    
}
分解AVI:
                string filename = "d:\test.avi";
                                //初始化
                org.loon.util.AviFile.Initialize();

                using (org.loon.util.AviFile avi = new org.loon.util.AviFile(filename))
                ...{
                    int max = avi.GetMaxFrameCount();
                    for (int i = 0; i < max; ++i)
                    ...{
                        Bitmap bmp = avi.GetFrame(i);
                        bmp.Save("d:\test\"+i + ".bmp");
                        bmp.Dispose();
                    }
                }
                                //完成
                org.loon.util.AviFile.Terminate();

作者:未知 | 文章來源:未知 | 更新時(shí)間:2008-1-15 16:44:26

  • 上一篇文章:

  • 下一篇文章:

  • 相關(guān)文章:
    .net將視頻文件格式轉(zhuǎn)換成flv格式
    C#實(shí)現(xiàn)短信發(fā)送程序的例子
    .net學(xué)習(xí):c#事件的深入分析
    基礎(chǔ)學(xué)習(xí):java中使用存儲過程
    C#如何設(shè)置或者獲取目錄的權(quán)限?
    解析c#語言和java語言最相似的地方
    C#中如何才能調(diào)用QTP自動化對象
    c#如何連接各類數(shù)據(jù)庫
    C#abstact interface 學(xué)習(xí)
    c#中的interface abstract與virtual學(xué)習(xí)
    軟件技術(shù)
    · 開發(fā)語言
    · Java技術(shù)
    · .Net技術(shù)
    · 數(shù)據(jù)庫開發(fā)
    最新文章  
    ·.net技術(shù) asp.net MVC3 Vi
    ·.net將視頻文件格式轉(zhuǎn)換成
    ·NET Framework 2.0 Servic
    ·如何動態(tài)修改winform的app
    ·asp,net軟件結(jié)構(gòu)設(shè)計(jì)和相關(guān)
    ·學(xué)習(xí)怎樣使用ASP.NET中的虛
    ·,net基礎(chǔ)類的學(xué)習(xí):system
    ·.net學(xué)習(xí):c#事件的深入分
    ·Facade Pattern學(xué)習(xí)總結(jié)
    ·C#如何設(shè)置或者獲取目錄的
    ·如何使用XSL來定義ASP.NET
    ·理解WCF Data Contract契約
    ·如何能在.net2.0開發(fā)的控件
    ·模式怎樣使用,講解模式的
    ·如何解決Menu菜單被frame遮
    關(guān)于我們 | 軟件開發(fā) | 下載試用 | 客服中心 | 聯(lián)系我們 | 友情鏈接 | 網(wǎng)站地圖 | 新疆電子地圖 | RSS訂閱
    版權(quán)所有 © 2016 新疆二域軟件開發(fā)網(wǎng) www.zgna.net All Rights Reserved 新ICP備14003571號
    新疆軟件開發(fā)總機(jī):0991-4842803、4811639.
    客服QQ:596589785 ;地址:新疆烏魯木齊北京中路華聯(lián)大廈A-5C 郵編:830000
     
    温泉县| 融水| 迁安市| 迁安市| 乡宁县| 眉山市| 城步| 上高县| 西畴县| 沙湾县| 江西省| 汪清县| 社旗县| 榆中县| 论坛| 新巴尔虎左旗| 郸城县| 青田县| 达尔| 罗甸县| 红原县| 惠州市| 南阳市| 龙口市| 富民县| 静安区| 铜鼓县| 班玛县| 庆城县| 通山县| 白水县| 沁水县| 加查县| 平度市| 华容县| 剑川县| 中西区| 视频| 错那县| 望都县| 务川|