2014-03-13 3 views
0

나는이 article을 보았고 이미지 목록으로 브러시를 교체 할 수 있을지 궁금한가요? 여기 브러시를 이미지 목록으로 바꾸시겠습니까?

브러시에서 AVI 파일을 생성하는 코드입니다 :

 private void buttonCreateVideo_Click(object sender, EventArgs e) 
    { 
     int width = 640; 
     int height = 480; 

     VideoFileWriter writer = new VideoFileWriter(); 
     writer.Open("code-bude_test_video.avi", width, height, 25, VideoCodec.MPEG4, 100000); 

     Bitmap image = new Bitmap(width, height); 
     Graphics g = Graphics.FromImage(image); 
     g.FillRectangle(Brushes.Black, 0, 0, width, height); 
     Brush[] brushList = new Brush[] { Brushes.Green, Brushes.Red, Brushes.Yellow, Brushes.Pink, Brushes.LimeGreen }; 

     for (int i = 0; i < listBox1.Items.Count; i++) 
     { 
      Application.DoEvents(); 
      g.FillRectangle(brushList[i % 5], (i % width) * 2, (i % height) * 0.5f, i % 30, i % 30); 
      g.FillRectangle(brushList[i % 5], (i % width) * 2, (i % height) * 2, i % 30, i % 30); 
      g.FillRectangle(brushList[i % 5], (i % width) * 0.5f, (i % height) * 2, i % 30, i % 30); 
      g.Save(); 
      writer.WriteVideoFrame(image); 
     } 

     writer.Close(); 
    } 

을 여기 내 목록입니다

private void button2_Click(object sender, EventArgs e) 
{ 
    FolderBrowserDialog fbd = new FolderBrowserDialog(); 
    DialogResult result = fbd.ShowDialog(); 

    if (result == DialogResult.OK) 
    { 
     NumericComparer ns = new NumericComparer(); 
     string[] array1 = Directory.GetFiles(fbd.SelectedPath, "*.Jpeg"); 
     ns = new NumericComparer(); // new object 
     Array.Sort(array1, ns); 

     listBox1.Items.Clear(); 
     foreach (string name in array1) 
     { 
      listBox1.Items.Add(name); 
     } 
    } 
} 

내가 필요로하는 모든이 .avi 비디오를 폴더에서 이미지를 추가하고 저장하는 것입니다

답변

1

다음과 같이 생각합니다.

for(int i = 0; i < listBox1.Items.Count; i++) 
{ 
    Application.DoEvents(); 
    var frame = new Bitmap(name); 
    g.DrawImage(frame, 0, 0, width, height); 
    writer.WriteVideoFrame(image); 
} 
관련 문제