用C#预览视频文件(简略)

我的IR项目里要对视频文件进行预览,目前还没有解决,以下的方法是一个尝试。

在system32下,有一个qedit.dll文件,这是DirectShow的一个COM组件(DS大部份都是COM组件),就是说我们可以直接以COM的形式引用到C#项目里。

我做了一个简单测试项目。先把qedit.dll找到,然后以COM注册到项目中。对MediaDet类进行了一个简单的封装,然后运行一个测试项目:
运行结果(从AVI中提取第10桢的内容):
VideoCapture.JPG

部份代码:仅供参考:

ContractedBlock.gif ExpandedBlockStart.gif MediaDetector类
None.gifusing System;
None.gif
using System.IO;
None.gif
using DexterLib;
None.gif
using System.Drawing;
None.gif
using System.Drawing.Imaging;
None.gif
None.gif
namespace PublicLibrary
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// Summary description for MediaDetector.
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class MediaDetector
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
//fields
InBlock.gif
        protected MediaDetClass _MediaDet;
InBlock.gif        
protected Image.GetThumbnailImageAbort _ImageCallback;
InBlock.gif        
//events
InBlock.gif
        public event ErrorHandler OnError;
InBlock.gif        
//properties
InBlock.gif
        protected MediaDetClass MediaDecteor
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(this._MediaDet==null)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
try
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
this._MediaDet = new MediaDetClass();
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
catch(Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
this.FileErrorEvent(ex);
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
return _MediaDet;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
protected Image.GetThumbnailImageAbort ImageCallback
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(this._ImageCallback == null)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
this._ImageCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return this._ImageCallback;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
//methods
InBlock.gif
        private void FileErrorEvent(Exception i_ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.OnError!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
try
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
this.OnError(this,i_ex);
ExpandedSubBlockEnd.gif                }

InBlock.gif                
catch(Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    System.Diagnostics.Trace.WriteLine(ex.Message);
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Method to get thumbinal image from media file.
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="i_MediaFile">Media file full path and name.</param>
InBlock.gif        
/// <param name="i_Size">Image size.</param>
InBlock.gif        
/// <param name="i_type">Media type</param>
InBlock.gif        
/// <param name="i_Stream">If the media type is video, this parameter is the video's stream to grab and create image.</param>
ExpandedSubBlockEnd.gif        
/// <returns></returns>

InBlock.gif        public Image GetThumbnail(string i_MediaFile,Size i_Size,MediaTypes i_type,int i_Stream)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
switch(i_type)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
default:
InBlock.gif                
case MediaTypes.Unknow:
InBlock.gif                    
this.FileErrorEvent(new Exception("Unknow media type."));
InBlock.gif                    
return null;
InBlock.gif                
case MediaTypes.Audio:
InBlock.gif                    
this.FileErrorEvent(new Exception("This media type has not implemented to create an image."));
InBlock.gif                    
return null;
InBlock.gif                
case MediaTypes.Image:
InBlock.gif                    
return this.GetThumbnailFromImage(i_MediaFile,i_Size);
InBlock.gif                
case MediaTypes.Video:
InBlock.gif                    
return this.GetThumbnailFromVideo(i_MediaFile,i_Size,i_Stream);
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public Image GetThumbnailFromImage(string i_MediaFile,Size i_Size)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Image m_image 
= Image.FromFile(i_MediaFile);
InBlock.gif                
return m_image.GetThumbnailImage(i_Size.Width,i_Size.Height,this.ImageCallback,IntPtr.Zero);
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.FileErrorEvent(ex);
InBlock.gif                
return null;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public Image GetThumbnailFromVideo(string i_MediaFile,Size i_Size,int i_Stream)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.MediaDecteor.Filename = i_MediaFile;
InBlock.gif            
this.MediaDecteor.CurrentStream = 0;
InBlock.gif            
//int m_ImageSize = (int)this.MediaDecteor.StreamLength;
InBlock.gif
            try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.MediaDecteor.WriteBitmapBits(i_Stream,i_Size.Width,i_Size.Height,"Temp.bmp");
InBlock.gif                Stream m_stream 
= File.Open("Temp.bmp",FileMode.Open,FileAccess.Read,FileShare.None);
InBlock.gif                
byte[] m_bytes = new byte[m_stream.Length];
InBlock.gif                m_stream.Read(m_bytes,
0,m_bytes.Length);
InBlock.gif                m_stream.Close();
InBlock.gif                File.Delete(
"Temp.bmp");
InBlock.gif                MemoryStream m_MemoStream 
= new MemoryStream(m_bytes.Length);
InBlock.gif                m_MemoStream.Write(m_bytes,
0,m_bytes.Length);
InBlock.gif                
return Image.FromStream(m_MemoStream);
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.FileErrorEvent(ex);
InBlock.gif                
return null;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private bool ThumbnailCallback()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return false;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//ctor
InBlock.gif
        public MediaDetector()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{            
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif    
public class MediaHelper#region public class MediaHelper
InBlock.gif    
public class MediaHelper
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
static public MediaTypes ConvertToMediaType(int i_Type)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
switch(i_Type)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
default:
InBlock.gif                
case 0:
InBlock.gif                    
return MediaTypes.Unknow;
InBlock.gif                
case 1:
InBlock.gif                    
return MediaTypes.Image;
InBlock.gif                
case 2:
InBlock.gif                    
return MediaTypes.Video;
InBlock.gif                
case 3:
InBlock.gif                    
return MediaTypes.Audio;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
static public MediaTypes ConvertToMediaType(string i_Type)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
switch(i_Type.ToLower())
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
default:
InBlock.gif                
case "unknow":
InBlock.gif                    
return MediaTypes.Unknow;
InBlock.gif                
case "image":
InBlock.gif                    
return MediaTypes.Image;
InBlock.gif                
case "video":
InBlock.gif                    
return MediaTypes.Video;
InBlock.gif                
case "audio":
InBlock.gif                    
return MediaTypes.Audio;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    
#endregion

InBlock.gif
InBlock.gif    
public delegate void ErrorHandler(object i_Sender,Exception i_ex);
InBlock.gif    
public enum MediaTypes
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        Image 
= 1,
InBlock.gif        Video 
= 2,
InBlock.gif        Audio 
= 3,
InBlock.gif        Unknow 
= 0,
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedBlockEnd.gif}

None.gif

测试Form代码:
ContractedBlock.gif ExpandedBlockStart.gif Form类
None.gifusing System;
None.gif
using System.Drawing;
None.gif
using System.Collections;
None.gif
using System.ComponentModel;
None.gif
using System.Windows.Forms;
None.gif
//
None.gif
using PublicLibrary;
None.gif
None.gif
namespace Country.Study
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// Summary description for Thumbinal.
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class Thumbnail : System.Windows.Forms.Form
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private MediaDetector _MediaDetector;
InBlock.gif        
//
InBlock.gif
        private MediaDetector MediaDetector
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{                
InBlock.gif                
return this._MediaDetector;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
//
InBlock.gif
        private System.Windows.Forms.StatusBar statusBar1;
InBlock.gif        
private System.Windows.Forms.Panel panel1;
InBlock.gif        
private System.Windows.Forms.TextBox C_Path;
InBlock.gif        
private System.Windows.Forms.Button C_Browse;
InBlock.gif        
private System.Windows.Forms.Panel panel2;
InBlock.gif        
private System.Windows.Forms.Label C_LabWidth;
InBlock.gif        
private System.Windows.Forms.TextBox C_Width;
InBlock.gif        
private System.Windows.Forms.Label C_LabHeight;
InBlock.gif        
private System.Windows.Forms.TextBox C_Height;
InBlock.gif        
private System.Windows.Forms.Label C_LabType;
InBlock.gif        
private System.Windows.Forms.ComboBox C_MediaTypes;
InBlock.gif        
private System.Windows.Forms.Label C_LabStream;
InBlock.gif        
private System.Windows.Forms.Button C_Create;
InBlock.gif        
private System.Windows.Forms.OpenFileDialog C_OpenFileDialog;
InBlock.gif        
private System.Windows.Forms.TextBox C_Stream;
InBlock.gif        
private System.Windows.Forms.PictureBox C_PicBox;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Required designer variable.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        private System.ComponentModel.Container components = null;
InBlock.gif
InBlock.gif        
public Thumbnail()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//
InBlock.gif            
// Required for Windows Form Designer support
InBlock.gif            
//
InBlock.gif
            InitializeComponent();
InBlock.gif
InBlock.gif            
//
InBlock.gif            
// TODO: Add any constructor code after InitializeComponent call
InBlock.gif            
//
InBlock.gif
            this._MediaDetector = new MediaDetector();
InBlock.gif            
this._MediaDetector.OnError += new ErrorHandler(MediaDetector_OnError);
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Clean up any resources being used.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        protected override void Dispose( bool disposing )
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this._MediaDetector!=null)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this._MediaDetector.OnError -= new ErrorHandler(MediaDetector_OnError);
InBlock.gif                
this._MediaDetector = null;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
if( disposing )
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(components != null)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    components.Dispose();
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
base.Dispose( disposing );
ExpandedSubBlockEnd.gif        }

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
Windows Form Designer generated code#region Windows Form Designer generated code
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// Required method for Designer support - do not modify
InBlock.gif        
/// the contents of this method with the code editor.
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        private void InitializeComponent()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
this.statusBar1 = new System.Windows.Forms.StatusBar();
InBlock.gif            
this.panel1 = new System.Windows.Forms.Panel();
InBlock.gif            
this.C_Browse = new System.Windows.Forms.Button();
InBlock.gif            
this.C_Path = new System.Windows.Forms.TextBox();
InBlock.gif            
this.panel2 = new System.Windows.Forms.Panel();
InBlock.gif            
this.C_Create = new System.Windows.Forms.Button();
InBlock.gif            
this.C_Stream = new System.Windows.Forms.TextBox();
InBlock.gif            
this.C_LabStream = new System.Windows.Forms.Label();
InBlock.gif            
this.C_MediaTypes = new System.Windows.Forms.ComboBox();
InBlock.gif            
this.C_LabType = new System.Windows.Forms.Label();
InBlock.gif            
this.C_Height = new System.Windows.Forms.TextBox();
InBlock.gif            
this.C_LabHeight = new System.Windows.Forms.Label();
InBlock.gif            
this.C_LabWidth = new System.Windows.Forms.Label();
InBlock.gif            
this.C_Width = new System.Windows.Forms.TextBox();
InBlock.gif            
this.C_PicBox = new System.Windows.Forms.PictureBox();
InBlock.gif            
this.C_OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
InBlock.gif            
this.panel1.SuspendLayout();
InBlock.gif            
this.panel2.SuspendLayout();
InBlock.gif            
this.SuspendLayout();
InBlock.gif            
// 
InBlock.gif            
// statusBar1
InBlock.gif            
// 
InBlock.gif
            this.statusBar1.Location = new System.Drawing.Point(0391);
InBlock.gif            
this.statusBar1.Name = "statusBar1";
InBlock.gif            
this.statusBar1.Size = new System.Drawing.Size(56822);
InBlock.gif            
this.statusBar1.TabIndex = 0;
InBlock.gif            
this.statusBar1.Text = "statusBar1";
InBlock.gif            
// 
InBlock.gif            
// panel1
InBlock.gif            
// 
InBlock.gif
            this.panel1.Controls.Add(this.C_Browse);
InBlock.gif            
this.panel1.Controls.Add(this.C_Path);
InBlock.gif            
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
InBlock.gif            
this.panel1.Location = new System.Drawing.Point(00);
InBlock.gif            
this.panel1.Name = "panel1";
InBlock.gif            
this.panel1.Size = new System.Drawing.Size(56840);
InBlock.gif            
this.panel1.TabIndex = 1;
InBlock.gif            
// 
InBlock.gif            
// C_Browse
InBlock.gif            
// 
InBlock.gif
            this.C_Browse.Location = new System.Drawing.Point(4808);
InBlock.gif            
this.C_Browse.Name = "C_Browse";
InBlock.gif            
this.C_Browse.TabIndex = 1;
InBlock.gif            
this.C_Browse.Text = "Browsedot.gif";
InBlock.gif            
this.C_Browse.Click += new System.EventHandler(this.C_Browse_Click);
InBlock.gif            
// 
InBlock.gif            
// C_Path
InBlock.gif            
// 
InBlock.gif
            this.C_Path.Location = new System.Drawing.Point(88);
InBlock.gif            
this.C_Path.Name = "C_Path";
InBlock.gif            
this.C_Path.ReadOnly = true;
InBlock.gif            
this.C_Path.Size = new System.Drawing.Size(46420);
InBlock.gif            
this.C_Path.TabIndex = 0;
InBlock.gif            
this.C_Path.Text = "textBox1";
InBlock.gif            
// 
InBlock.gif            
// panel2
InBlock.gif            
// 
InBlock.gif
            this.panel2.Controls.Add(this.C_Create);
InBlock.gif            
this.panel2.Controls.Add(this.C_Stream);
InBlock.gif            
this.panel2.Controls.Add(this.C_LabStream);
InBlock.gif            
this.panel2.Controls.Add(this.C_MediaTypes);
InBlock.gif            
this.panel2.Controls.Add(this.C_LabType);
InBlock.gif            
this.panel2.Controls.Add(this.C_Height);
InBlock.gif            
this.panel2.Controls.Add(this.C_LabHeight);
InBlock.gif            
this.panel2.Controls.Add(this.C_LabWidth);
InBlock.gif            
this.panel2.Controls.Add(this.C_Width);
InBlock.gif            
this.panel2.Dock = System.Windows.Forms.DockStyle.Left;
InBlock.gif            
this.panel2.Location = new System.Drawing.Point(040);
InBlock.gif            
this.panel2.Name = "panel2";
InBlock.gif            
this.panel2.Size = new System.Drawing.Size(176351);
InBlock.gif            
this.panel2.TabIndex = 2;
InBlock.gif            
// 
InBlock.gif            
// C_Create
InBlock.gif            
// 
InBlock.gif
            this.C_Create.Location = new System.Drawing.Point(8136);
InBlock.gif            
this.C_Create.Name = "C_Create";
InBlock.gif            
this.C_Create.Size = new System.Drawing.Size(15223);
InBlock.gif            
this.C_Create.TabIndex = 10;
InBlock.gif            
this.C_Create.Text = "Create Thumbnail Image";
InBlock.gif            
this.C_Create.Click += new System.EventHandler(this.C_Create_Click);
InBlock.gif            
// 
InBlock.gif            
// C_Stream
InBlock.gif            
// 
InBlock.gif
            this.C_Stream.Location = new System.Drawing.Point(64104);
InBlock.gif            
this.C_Stream.Name = "C_Stream";
InBlock.gif            
this.C_Stream.TabIndex = 9;
InBlock.gif            
this.C_Stream.Text = "1";
InBlock.gif            
// 
InBlock.gif            
// C_LabStream
InBlock.gif            
// 
InBlock.gif
            this.C_LabStream.Location = new System.Drawing.Point(8104);
InBlock.gif            
this.C_LabStream.Name = "C_LabStream";
InBlock.gif            
this.C_LabStream.Size = new System.Drawing.Size(5616);
InBlock.gif            
this.C_LabStream.TabIndex = 8;
InBlock.gif            
this.C_LabStream.Text = "Stream";
InBlock.gif            
// 
InBlock.gif            
// C_MediaTypes
InBlock.gif            
// 
ExpandedSubBlockStart.gifContractedSubBlock.gif
            this.C_MediaTypes.Items.AddRange(new object[] dot.gif{
InBlock.gif                                                              
"Unknow",
InBlock.gif                                                              
"Image",
InBlock.gif                                                              
"Audio",
ExpandedSubBlockEnd.gif                                                              
"Video"}
);
InBlock.gif            
this.C_MediaTypes.Location = new System.Drawing.Point(6472);
InBlock.gif            
this.C_MediaTypes.Name = "C_MediaTypes";
InBlock.gif            
this.C_MediaTypes.Size = new System.Drawing.Size(10421);
InBlock.gif            
this.C_MediaTypes.TabIndex = 7;
InBlock.gif            
// 
InBlock.gif            
// C_LabType
InBlock.gif            
// 
InBlock.gif
            this.C_LabType.Location = new System.Drawing.Point(872);
InBlock.gif            
this.C_LabType.Name = "C_LabType";
InBlock.gif            
this.C_LabType.Size = new System.Drawing.Size(5616);
InBlock.gif            
this.C_LabType.TabIndex = 6;
InBlock.gif            
this.C_LabType.Text = "Type";
InBlock.gif            
// 
InBlock.gif            
// C_Height
InBlock.gif            
// 
InBlock.gif
            this.C_Height.Location = new System.Drawing.Point(6440);
InBlock.gif            
this.C_Height.Name = "C_Height";
InBlock.gif            
this.C_Height.TabIndex = 5;
InBlock.gif            
this.C_Height.Text = "300";
InBlock.gif            
// 
InBlock.gif            
// C_LabHeight
InBlock.gif            
// 
InBlock.gif
            this.C_LabHeight.Location = new System.Drawing.Point(840);
InBlock.gif            
this.C_LabHeight.Name = "C_LabHeight";
InBlock.gif            
this.C_LabHeight.Size = new System.Drawing.Size(5616);
InBlock.gif            
this.C_LabHeight.TabIndex = 4;
InBlock.gif            
this.C_LabHeight.Text = "Height";
InBlock.gif            
// 
InBlock.gif            
// C_LabWidth
InBlock.gif            
// 
InBlock.gif
            this.C_LabWidth.Location = new System.Drawing.Point(88);
InBlock.gif            
this.C_LabWidth.Name = "C_LabWidth";
InBlock.gif            
this.C_LabWidth.Size = new System.Drawing.Size(5616);
InBlock.gif            
this.C_LabWidth.TabIndex = 3;
InBlock.gif            
this.C_LabWidth.Text = "Width";
InBlock.gif            
// 
InBlock.gif            
// C_Width
InBlock.gif            
// 
InBlock.gif
            this.C_Width.Location = new System.Drawing.Point(648);
InBlock.gif            
this.C_Width.Name = "C_Width";
InBlock.gif            
this.C_Width.TabIndex = 3;
InBlock.gif            
this.C_Width.Text = "300";
InBlock.gif            
// 
InBlock.gif            
// C_PicBox
InBlock.gif            
// 
InBlock.gif
            this.C_PicBox.Location = new System.Drawing.Point(17640);
InBlock.gif            
this.C_PicBox.Name = "C_PicBox";
InBlock.gif            
this.C_PicBox.Size = new System.Drawing.Size(392351);
InBlock.gif            
this.C_PicBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
InBlock.gif            
this.C_PicBox.TabIndex = 3;
InBlock.gif            
this.C_PicBox.TabStop = false;
InBlock.gif            
// 
InBlock.gif            
// Thumbnail
InBlock.gif            
// 
InBlock.gif
            this.AutoScaleBaseSize = new System.Drawing.Size(513);
InBlock.gif            
this.ClientSize = new System.Drawing.Size(568413);
InBlock.gif            
this.Controls.Add(this.C_PicBox);
InBlock.gif            
this.Controls.Add(this.panel2);
InBlock.gif            
this.Controls.Add(this.panel1);
InBlock.gif            
this.Controls.Add(this.statusBar1);
InBlock.gif            
this.Name = "Thumbnail";
InBlock.gif            
this.Text = "Thumbinal";
InBlock.gif            
this.panel1.ResumeLayout(false);
InBlock.gif            
this.panel2.ResumeLayout(false);
InBlock.gif            
this.ResumeLayout(false);
InBlock.gif
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
InBlock.gif        
private void C_Create_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
int m_width = Convert.ToInt32(this.C_Width.Text);
InBlock.gif                
int m_height = Convert.ToInt32(this.C_Height.Text);
InBlock.gif                
int m_stream = Convert.ToInt32(this.C_Stream.Text);
InBlock.gif                MediaTypes m_MediaType 
= MediaHelper.ConvertToMediaType(this.C_MediaTypes.SelectedItem.ToString());
InBlock.gif                Image m_image 
= this.MediaDetector.GetThumbnail(this.C_Path.Text,new Size(m_width,m_height),m_MediaType,m_stream);
InBlock.gif                
this.C_PicBox.Image = m_image;
InBlock.gif                
this.C_PicBox.Width = m_width;
InBlock.gif                
this.C_PicBox.Height = m_height;                
InBlock.gif                
this.C_PicBox.Refresh();
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch(Exception ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                MessageBox.Show(
string.Format("Error:{0}",ex.Message));
ExpandedSubBlockEnd.gif            }
        
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void MediaDetector_OnError(object i_Sender, Exception i_ex)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            MessageBox.Show(
this,string.Format("Create thumbnail image error. Message:{0}",i_ex.Message));
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private void C_Browse_Click(object sender, System.EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(this.C_OpenFileDialog.ShowDialog(this)==DialogResult.OK)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.C_Path.Text = this.C_OpenFileDialog.FileName;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif

仅做参考!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值