C#将图像文件压缩为AVI文件播放

继续上一篇blogusing System;using System.Runtime.InteropServices;using System.Drawing;using System.Drawing.Imaging;namespace org.loon.util...{    /**////     /// AVIWriter 的摘要说明,chenpeng,Email:ceponline
摘要由CSDN通过智能技术生成
继续上一篇blog

using  System;
using  System.Runtime.InteropServices;
using  System.Drawing;
using  System.Drawing.Imaging;

namespace  org.loon.util
{
    
/// <summary>
    
/// AVIWriter 的摘要说明,chenpeng,Email:ceponline@yahoo.com.cn。
    
/// </summary>

    public class AVIWriter
    
{
        
const string AVIFILE32 = "AVIFIL32";
        
private int _pfile = 0;
        
private IntPtr _ps = new IntPtr(0);
        
private IntPtr _psCompressed = new IntPtr(0);
        
private UInt32 _frameRate = 0;
        
private int _count = 0;
        
private UInt32 _width = 0;
        
private UInt32 _stride = 0;
        
private UInt32 _height = 0;
        
//avi标识
        private UInt32 _fccType = 1935960438// vids
        private UInt32 _fccHandler = 808810089;// IV50
    
        
private Bitmap _bmp;

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

        [DllImport(AVIFILE32)]
        
private static extern int AVIFileOpenW(ref int ptr_pfile, [MarshalAs(UnmanagedType.LPWStr)]string fileName, int flags, int dummy);

        [DllImport(AVIFILE32)]
        
private static extern int AVIFileCreateStream(int ptr_pfile, out IntPtr ptr_ptr_avi, ref AVISTREAMINFOW ptr_streaminfo);
        [DllImport(AVIFILE32)]
        
private static extern int AVIMakeCompressedStream(out IntPtr ppsCompressed, IntPtr aviStream, ref AVICOMPRESSOPTIONS ao, int dummy);

        [DllImport(AVIFILE32)]
        
private static extern int AVIStreamSetFormat(IntPtr aviStream, Int32 lPos, ref BITMAPINFOHEADER lpFormat, Int32 cbFormat);

        [DllImport(AVIFILE32)]
        
unsafe private static extern int AVISaveOptions(int hwnd, UInt32 flags,int nStreams, IntPtr* ptr_ptr_avi, AVICOMPRESSOPTIONS** ao);

        [DllImport(AVIFILE32)]
        
private static extern int AVIStreamWrite(IntPtr aviStream, Int32 lStart,Int32 lSamples, IntPtr lpBuffer, Int32 cbBuffer, Int32 dwFlags, Int32 dummy1, Int32 dummy2);

        [DllImport(AVIFILE32)]
        
private static extern int AVIStreamRelease(IntPtr aviStream);

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

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

        [StructLayout(LayoutKind.Sequential, Pack 
= 1)]
            
private struct AVISTREAMINFOW
        
{
            
public UInt32 fccType;
            
public UInt32 fccHandler;
            
public UInt32 dwFlags;
            
public UInt32 dwCaps;
            
public UInt16 wPriority;
  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 20
    评论
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值