Форум программистов, компьютерный форум, киберфорум
C# для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.94/32: Рейтинг темы: голосов - 32, средняя оценка - 4.94
0 / 0 / 0
Регистрация: 27.02.2011
Сообщений: 38

Как склеить изображения в один avi файл?

30.04.2011, 19:07. Показов 6484. Ответов 7
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
в общем вопрос такой....имеется несколько сотен изображений как их можно склеить в один avi файл???возможно ли такое?
0
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
30.04.2011, 19:07
Ответы с готовыми решениями:

Как склеить всё в один exe файл?
Есть много dll файлов, без которых программа не работает. Можно ли как то вшить в exe всё это через visual studio? И хотелось бы узнать,...

Как склеить несколько рисунков в один файл ?
Вот такая вот проблема : у меня есть три picturebox с изображениями и я хочу чтобы по нажатию кнопки 'сохранить' содержимое pictureбоксов...

Файлы: склеить содержимое в один файл в том порядке, как приведены имена
Написать программу, которая вводит с клавиатуры список имён текстовых файлов, разделённых запятой, и склеивает их содержимое в один файл в...

7
 Аватар для nuke4303
99 / 100 / 16
Регистрация: 30.03.2011
Сообщений: 350
30.04.2011, 19:11
клас для склейки изображений, как с ним работать думаю разберетесь
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
namespace M2D
{
    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Runtime.InteropServices;
    //using AForge;   
    /// 
    public class AVIWriter : IDisposable
    {
        // AVI file
        private IntPtr file;
        // video stream
        private IntPtr stream;
        // compressed stream
        private IntPtr streamCompressed;
        // buffer
        private IntPtr buffer = IntPtr.Zero;
 
        // width of video frames
        private int width;
        // height of vide frames
        private int height;
        // length of one line
        private int stride;
        // quality
        private int quality = -1;
        // frame rate
        private int rate = 25;
        // current position
        private int position;
        // codec used for video compression
        private string codec = "DIB ";
 
        /// <summary>
        /// Width of video frames.
        /// </summary>
        /// 
        /// <remarks><para>The property specifies the width of video frames, which are acceptable
        /// by <see cref="AddFrame"/> method for saving, which is set in <see cref="Open"/>
        /// method.</para></remarks>
        /// 
        public int Width
        {
            get { return (buffer != IntPtr.Zero) ? width : 0; }
        }
 
        /// <summary>
        /// Height of video frames.
        /// </summary>
        /// 
        /// <remarks><para>The property specifies the height of video frames, which are acceptable
        /// by <see cref="AddFrame"/> method for saving, which is set in <see cref="Open"/>
        /// method.</para></remarks>
        /// 
        public int Height
        {
            get { return (buffer != IntPtr.Zero) ? height : 0; }
        }
 
        /// <summary>
        /// Current position in video stream.
        /// </summary>
        /// 
        /// <remarks><para>The property tell current position in video stream, which actually equals
        /// to the amount of frames added using <see cref="AddFrame"/> method.</para></remarks>
        /// 
        public int Position
        {
            get { return position; }
        }
 
        /// <summary>
        /// Desired playing frame rate.
        /// </summary>
        /// 
        /// <remarks><para>The property sets the video frame rate, which should be use during playing
        /// of the video to be saved.</para>
        /// 
        /// <para><note>The property should be set befor opening new file to take effect.</note></para>
        /// 
        /// <para>Default frame rate is set to <b>25</b>.</para></remarks>
        /// 
        public int FrameRate
        {
            get { return rate; }
            set { rate = value; }
        }
 
        /// <summary>
        /// Codec used for video compression.
        /// </summary>
        /// 
        /// <remarks><para>The property sets the FOURCC code of video compression codec, which needs to
        /// be used for video encoding.</para>
        /// 
        /// <para><note>The property should be set befor opening new file to take effect.</note></para>
        /// 
        /// <para>Default video codec is set <b>"DIB "</b>, which means no compression.</para></remarks>
        /// 
        public string Codec
        {
            get { return codec; }
            set { codec = value; }
        }
 
        /// <summary>
        /// Compression video quality.
        /// </summary>
        /// 
        /// <remarks><para>The property sets video quality used by codec in order to balance compression rate
        /// and image quality. The quality is measured usually in the [0, 100] range.</para>
        /// 
        /// <para><note>The property should be set befor opening new file to take effect.</note></para>
        /// 
        /// <para>Default value is set to <b>-1</b> - default compression quality of the codec.</para></remarks>
        /// 
        public int Quality
        {
            get { return quality; }
            set { quality = value; }
        }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="AVIWriter"/> class.
        /// </summary>
        /// 
        /// <remarks>Initializes Video for Windows library.</remarks>
        /// 
        public AVIWriter()
        {
            Win32.AVIFileInit();
        }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="AVIWriter"/> class.
        /// </summary>
        /// 
        /// <param name="codec">Codec to use for compression.</param>
        /// 
        /// <remarks>Initializes Video for Windows library.</remarks>
        /// 
        public AVIWriter(string codec)
            : this()
        {
            this.codec = codec;
        }
 
        /// <summary>
        /// Destroys the instance of the <see cref="AVIWriter"/> class.
        /// </summary>
        /// 
        ~AVIWriter()
        {
            Dispose(false);
        }
 
        /// <summary>
        /// Dispose the object.
        /// </summary>
        /// 
        /// <remarks>Frees unmanaged resources used by the object. The object becomes unusable
        /// after that.</remarks>
        /// 
        public void Dispose()
        {
            Dispose(true);
            // remove me from the Finalization queue 
            GC.SuppressFinalize(this);
        }
 
        /// <summary>
        /// Dispose the object.
        /// </summary>
        /// 
        /// <param name="disposing">Indicates if disposing was initiated manually.</param>
        /// 
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // dispose managed resources
            }
            // close current AVI file if any opened and uninitialize AVI library
            Close();
            Win32.AVIFileExit();
        }
 
        /// <summary>
        /// Create new AVI file and open it for writing.
        /// </summary>
        /// 
        /// <param name="fileName">AVI file name to create.</param>
        /// <param name="width">Video width.</param>
        /// <param name="height">Video height.</param>
        /// 
        /// <remarks><para>The method opens (creates) a video files, configure video codec and prepares
        /// the stream for saving video frames with a help of <see cref="AddFrame"/> method.</para></remarks>
        /// 
        /// <exception cref="ApplicationException">Failure of opening video files (the exception message
        /// specifies the issues).</exception>
        /// 
        public void Open(string fileName, int width, int height)
        {
            // close previous file
            Close();
 
            lock (this)
            {
                // calculate stride
                stride = width * 3;
                if ((stride % 4) != 0)
                    stride += (4 - stride % 4);
 
                // create new file
                if (Win32.AVIFileOpen(out file, fileName, Win32.OpenFileMode.Create | Win32.OpenFileMode.Write, IntPtr.Zero) != 0)
                    throw new ApplicationException("Failed opening file");
 
                this.width = width;
                this.height = height;
 
                // describe new stream
                Win32.AVISTREAMINFO info = new Win32.AVISTREAMINFO();
 
                info.type = Win32.mmioFOURCC("vids");
                info.handler = Win32.mmioFOURCC(codec);
                info.scale = 1;
                info.rate = rate;
                info.suggestedBufferSize = stride * height;
 
                // create stream
                if (Win32.AVIFileCreateStream(file, out stream, ref info) != 0)
                    throw new ApplicationException("Failed creating stream");
 
                // describe compression options
                Win32.AVICOMPRESSOPTIONS options = new Win32.AVICOMPRESSOPTIONS();
 
                options.handler = Win32.mmioFOURCC(codec);
                options.quality = quality;
 
                // uncomment if video settings dialog is required to show
                // Win32.AVISaveOptions( stream, ref options );
 
                // create compressed stream
                if (Win32.AVIMakeCompressedStream(out streamCompressed, stream, ref options, IntPtr.Zero) != 0)
                    throw new ApplicationException("Failed creating compressed stream");
 
                // describe frame format
                Win32.BITMAPINFOHEADER bitmapInfoHeader = new Win32.BITMAPINFOHEADER();
 
                bitmapInfoHeader.size = Marshal.SizeOf(bitmapInfoHeader.GetType());
                bitmapInfoHeader.width = width;
                bitmapInfoHeader.height = height;
                bitmapInfoHeader.planes = 1;
                bitmapInfoHeader.bitCount = 24;
                bitmapInfoHeader.sizeImage = 0;
                bitmapInfoHeader.compression = 0; // BI_RGB
 
                // set frame format
                if (Win32.AVIStreamSetFormat(streamCompressed, 0, ref bitmapInfoHeader, Marshal.SizeOf(bitmapInfoHeader.GetType())) != 0)
                    throw new ApplicationException("Failed creating compressed stream");
 
                // alloc unmanaged memory for frame
                buffer = Marshal.AllocHGlobal(stride * height);
 
                if (buffer == IntPtr.Zero)
                    throw new ApplicationException("Insufficient memory for internal buffer");
 
                position = 0;
            }
        }
 
        /// <summary>
        /// Close video file.
        /// </summary>
        /// 
        public void Close()
        {
            lock (this)
            {
                // free unmanaged memory
                if (buffer != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(buffer);
                    buffer = IntPtr.Zero;
                }
 
                // release compressed stream
                if (streamCompressed != IntPtr.Zero)
                {
                    Win32.AVIStreamRelease(streamCompressed);
                    streamCompressed = IntPtr.Zero;
                }
 
                // release stream
                if (stream != IntPtr.Zero)
                {
                    Win32.AVIStreamRelease(stream);
                    stream = IntPtr.Zero;
                }
 
                // release file
                if (file != IntPtr.Zero)
                {
                    Win32.AVIFileRelease(file);
                    file = IntPtr.Zero;
                }
            }
        }
 
        /// <summary>
        /// Add new frame to the AVI file.
        /// </summary>
        /// 
        /// <param name="frameImage">New frame image.</param>
        /// 
        /// <remarks><para>The method adds new video frame to an opened video file. The width and heights
        /// of the frame should be the same as it was specified in <see cref="Open"/> method
        /// (see <see cref="Width"/> and <see cref="Height"/> properties).</para></remarks>
        /// 
        /// <exception cref="ApplicationException">Failure of opening video files (the exception message
        /// specifies the issues).</exception>
        /// 
        public void AddFrame(Bitmap frameImage)
        {
            lock (this)
            {
                // check if AVI file was properly opened
                if (buffer == IntPtr.Zero)
                    throw new ApplicationException("AVI file should be successfully opened before writing");
 
                // check image dimension
                if ((frameImage.Width != width) || (frameImage.Height != height))
                    throw new ApplicationException("Invalid image dimension");
 
                // lock bitmap data
                BitmapData imageData = frameImage.LockBits(
                    new Rectangle(0, 0, width, height),
                    ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
 
                // copy image data
                int srcStride = imageData.Stride;
                int dstStride = stride;
 
                int src = imageData.Scan0.ToInt32() + srcStride * (height - 1);
                int dst = buffer.ToInt32();
 
                for (int y = 0; y < height; y++)
                {
                    Win32.memcpy(dst, src, dstStride);
                    dst += dstStride;
                    src -= srcStride;
                }
 
                // unlock bitmap data
                frameImage.UnlockBits(imageData);
 
                // write to stream
                if (Win32.AVIStreamWrite(streamCompressed, position, 1, buffer,
                    stride * height, 0, IntPtr.Zero, IntPtr.Zero) != 0)
                    throw new ApplicationException("Failed adding frame");
 
                position++;
            }
        }
    }
}
0
0 / 0 / 0
Регистрация: 27.02.2011
Сообщений: 38
02.05.2011, 18:00  [ТС]
Цитата Сообщение от nuke4303 Посмотреть сообщение
клас для склейки изображений, как с ним работать думаю разберетесь
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
namespace M2D
{
    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Runtime.InteropServices;
    //using AForge;   
    /// 
    public class AVIWriter : IDisposable
    {
        // AVI file
        private IntPtr file;
        // video stream
        private IntPtr stream;
        // compressed stream
        private IntPtr streamCompressed;
        // buffer
        private IntPtr buffer = IntPtr.Zero;
 
        // width of video frames
        private int width;
        // height of vide frames
        private int height;
        // length of one line
        private int stride;
        // quality
        private int quality = -1;
        // frame rate
        private int rate = 25;
        // current position
        private int position;
        // codec used for video compression
        private string codec = "DIB ";
 
        /// <summary>
        /// Width of video frames.
        /// </summary>
        /// 
        /// <remarks><para>The property specifies the width of video frames, which are acceptable
        /// by <see cref="AddFrame"/> method for saving, which is set in <see cref="Open"/>
        /// method.</para></remarks>
        /// 
        public int Width
        {
            get { return (buffer != IntPtr.Zero) ? width : 0; }
        }
 
        /// <summary>
        /// Height of video frames.
        /// </summary>
        /// 
        /// <remarks><para>The property specifies the height of video frames, which are acceptable
        /// by <see cref="AddFrame"/> method for saving, which is set in <see cref="Open"/>
        /// method.</para></remarks>
        /// 
        public int Height
        {
            get { return (buffer != IntPtr.Zero) ? height : 0; }
        }
 
        /// <summary>
        /// Current position in video stream.
        /// </summary>
        /// 
        /// <remarks><para>The property tell current position in video stream, which actually equals
        /// to the amount of frames added using <see cref="AddFrame"/> method.</para></remarks>
        /// 
        public int Position
        {
            get { return position; }
        }
 
        /// <summary>
        /// Desired playing frame rate.
        /// </summary>
        /// 
        /// <remarks><para>The property sets the video frame rate, which should be use during playing
        /// of the video to be saved.</para>
        /// 
        /// <para><note>The property should be set befor opening new file to take effect.</note></para>
        /// 
        /// <para>Default frame rate is set to <b>25</b>.</para></remarks>
        /// 
        public int FrameRate
        {
            get { return rate; }
            set { rate = value; }
        }
 
        /// <summary>
        /// Codec used for video compression.
        /// </summary>
        /// 
        /// <remarks><para>The property sets the FOURCC code of video compression codec, which needs to
        /// be used for video encoding.</para>
        /// 
        /// <para><note>The property should be set befor opening new file to take effect.</note></para>
        /// 
        /// <para>Default video codec is set <b>"DIB "</b>, which means no compression.</para></remarks>
        /// 
        public string Codec
        {
            get { return codec; }
            set { codec = value; }
        }
 
        /// <summary>
        /// Compression video quality.
        /// </summary>
        /// 
        /// <remarks><para>The property sets video quality used by codec in order to balance compression rate
        /// and image quality. The quality is measured usually in the [0, 100] range.</para>
        /// 
        /// <para><note>The property should be set befor opening new file to take effect.</note></para>
        /// 
        /// <para>Default value is set to <b>-1</b> - default compression quality of the codec.</para></remarks>
        /// 
        public int Quality
        {
            get { return quality; }
            set { quality = value; }
        }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="AVIWriter"/> class.
        /// </summary>
        /// 
        /// <remarks>Initializes Video for Windows library.</remarks>
        /// 
        public AVIWriter()
        {
            Win32.AVIFileInit();
        }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="AVIWriter"/> class.
        /// </summary>
        /// 
        /// <param name="codec">Codec to use for compression.</param>
        /// 
        /// <remarks>Initializes Video for Windows library.</remarks>
        /// 
        public AVIWriter(string codec)
            : this()
        {
            this.codec = codec;
        }
 
        /// <summary>
        /// Destroys the instance of the <see cref="AVIWriter"/> class.
        /// </summary>
        /// 
        ~AVIWriter()
        {
            Dispose(false);
        }
 
        /// <summary>
        /// Dispose the object.
        /// </summary>
        /// 
        /// <remarks>Frees unmanaged resources used by the object. The object becomes unusable
        /// after that.</remarks>
        /// 
        public void Dispose()
        {
            Dispose(true);
            // remove me from the Finalization queue 
            GC.SuppressFinalize(this);
        }
 
        /// <summary>
        /// Dispose the object.
        /// </summary>
        /// 
        /// <param name="disposing">Indicates if disposing was initiated manually.</param>
        /// 
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // dispose managed resources
            }
            // close current AVI file if any opened and uninitialize AVI library
            Close();
            Win32.AVIFileExit();
        }
 
        /// <summary>
        /// Create new AVI file and open it for writing.
        /// </summary>
        /// 
        /// <param name="fileName">AVI file name to create.</param>
        /// <param name="width">Video width.</param>
        /// <param name="height">Video height.</param>
        /// 
        /// <remarks><para>The method opens (creates) a video files, configure video codec and prepares
        /// the stream for saving video frames with a help of <see cref="AddFrame"/> method.</para></remarks>
        /// 
        /// <exception cref="ApplicationException">Failure of opening video files (the exception message
        /// specifies the issues).</exception>
        /// 
        public void Open(string fileName, int width, int height)
        {
            // close previous file
            Close();
 
            lock (this)
            {
                // calculate stride
                stride = width * 3;
                if ((stride % 4) != 0)
                    stride += (4 - stride % 4);
 
                // create new file
                if (Win32.AVIFileOpen(out file, fileName, Win32.OpenFileMode.Create | Win32.OpenFileMode.Write, IntPtr.Zero) != 0)
                    throw new ApplicationException("Failed opening file");
 
                this.width = width;
                this.height = height;
 
                // describe new stream
                Win32.AVISTREAMINFO info = new Win32.AVISTREAMINFO();
 
                info.type = Win32.mmioFOURCC("vids");
                info.handler = Win32.mmioFOURCC(codec);
                info.scale = 1;
                info.rate = rate;
                info.suggestedBufferSize = stride * height;
 
                // create stream
                if (Win32.AVIFileCreateStream(file, out stream, ref info) != 0)
                    throw new ApplicationException("Failed creating stream");
 
                // describe compression options
                Win32.AVICOMPRESSOPTIONS options = new Win32.AVICOMPRESSOPTIONS();
 
                options.handler = Win32.mmioFOURCC(codec);
                options.quality = quality;
 
                // uncomment if video settings dialog is required to show
                // Win32.AVISaveOptions( stream, ref options );
 
                // create compressed stream
                if (Win32.AVIMakeCompressedStream(out streamCompressed, stream, ref options, IntPtr.Zero) != 0)
                    throw new ApplicationException("Failed creating compressed stream");
 
                // describe frame format
                Win32.BITMAPINFOHEADER bitmapInfoHeader = new Win32.BITMAPINFOHEADER();
 
                bitmapInfoHeader.size = Marshal.SizeOf(bitmapInfoHeader.GetType());
                bitmapInfoHeader.width = width;
                bitmapInfoHeader.height = height;
                bitmapInfoHeader.planes = 1;
                bitmapInfoHeader.bitCount = 24;
                bitmapInfoHeader.sizeImage = 0;
                bitmapInfoHeader.compression = 0; // BI_RGB
 
                // set frame format
                if (Win32.AVIStreamSetFormat(streamCompressed, 0, ref bitmapInfoHeader, Marshal.SizeOf(bitmapInfoHeader.GetType())) != 0)
                    throw new ApplicationException("Failed creating compressed stream");
 
                // alloc unmanaged memory for frame
                buffer = Marshal.AllocHGlobal(stride * height);
 
                if (buffer == IntPtr.Zero)
                    throw new ApplicationException("Insufficient memory for internal buffer");
 
                position = 0;
            }
        }
 
        /// <summary>
        /// Close video file.
        /// </summary>
        /// 
        public void Close()
        {
            lock (this)
            {
                // free unmanaged memory
                if (buffer != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(buffer);
                    buffer = IntPtr.Zero;
                }
 
                // release compressed stream
                if (streamCompressed != IntPtr.Zero)
                {
                    Win32.AVIStreamRelease(streamCompressed);
                    streamCompressed = IntPtr.Zero;
                }
 
                // release stream
                if (stream != IntPtr.Zero)
                {
                    Win32.AVIStreamRelease(stream);
                    stream = IntPtr.Zero;
                }
 
                // release file
                if (file != IntPtr.Zero)
                {
                    Win32.AVIFileRelease(file);
                    file = IntPtr.Zero;
                }
            }
        }
 
        /// <summary>
        /// Add new frame to the AVI file.
        /// </summary>
        /// 
        /// <param name="frameImage">New frame image.</param>
        /// 
        /// <remarks><para>The method adds new video frame to an opened video file. The width and heights
        /// of the frame should be the same as it was specified in <see cref="Open"/> method
        /// (see <see cref="Width"/> and <see cref="Height"/> properties).</para></remarks>
        /// 
        /// <exception cref="ApplicationException">Failure of opening video files (the exception message
        /// specifies the issues).</exception>
        /// 
        public void AddFrame(Bitmap frameImage)
        {
            lock (this)
            {
                // check if AVI file was properly opened
                if (buffer == IntPtr.Zero)
                    throw new ApplicationException("AVI file should be successfully opened before writing");
 
                // check image dimension
                if ((frameImage.Width != width) || (frameImage.Height != height))
                    throw new ApplicationException("Invalid image dimension");
 
                // lock bitmap data
                BitmapData imageData = frameImage.LockBits(
                    new Rectangle(0, 0, width, height),
                    ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
 
                // copy image data
                int srcStride = imageData.Stride;
                int dstStride = stride;
 
                int src = imageData.Scan0.ToInt32() + srcStride * (height - 1);
                int dst = buffer.ToInt32();
 
                for (int y = 0; y < height; y++)
                {
                    Win32.memcpy(dst, src, dstStride);
                    dst += dstStride;
                    src -= srcStride;
                }
 
                // unlock bitmap data
                frameImage.UnlockBits(imageData);
 
                // write to stream
                if (Win32.AVIStreamWrite(streamCompressed, position, 1, buffer,
                    stride * height, 0, IntPtr.Zero, IntPtr.Zero) != 0)
                    throw new ApplicationException("Failed adding frame");
 
                position++;
            }
        }
    }
}
эмммм.........а как теперь воспользоваться им?(я же в танке)............то есть каким образом уже имеющиеся картинки то погрузить в данный класс????

Добавлено через 5 часов 9 минут
неужели никто ничего не подскажет?
Блин, ну это же плохо.........хотя бы в каком месте искать и в каком направлении....
0
0 / 0 / 0
Регистрация: 27.02.2011
Сообщений: 38
05.05.2011, 18:00  [ТС]
неужели никто не знает? ну помогите люди добрые!!!!!!
0
145 / 145 / 26
Регистрация: 09.10.2009
Сообщений: 261
05.05.2011, 19:34
Скачиваете AForge.NET Framework и смотрите исходники Video.VFW. Обнаружите там выше описанный класс и пример работы. Если лень разбираться с исходниками, то скачиваете только готовые dll, подключаете в проект и пишите нечто вроде:
C#
1
2
3
4
5
AVIWriter aw = new AVIWriter();
Bitmap image = new Bitmap(imagePath);
aw.Open(aviPath, image.Width, image.Height);
aw.AddFrame(image);
aw.Close();
Получаете готовенький avi с вашей картинкой. Я надеюсь вопросов - как добавить много картинок - не возникнет.
1
0 / 0 / 0
Регистрация: 27.02.2011
Сообщений: 38
07.05.2011, 19:01  [ТС]
Цитата Сообщение от ArtOfLife Посмотреть сообщение
Скачиваете AForge.NET Framework и смотрите исходники Video.VFW. Обнаружите там выше описанный класс и пример работы. Если лень разбираться с исходниками, то скачиваете только готовые dll, подключаете в проект и пишите нечто вроде:
C#
1
2
3
4
5
AVIWriter aw = new AVIWriter();
Bitmap image = new Bitmap(imagePath);
aw.Open(aviPath, image.Width, image.Height);
aw.AddFrame(image);
aw.Close();
Получаете готовенький avi с вашей картинкой. Я надеюсь вопросов - как добавить много картинок - не возникнет.
а если такой вопрос возник?.....то как мне быть?
0
начал понимать msdn
57 / 57 / 6
Регистрация: 11.03.2010
Сообщений: 232
07.05.2011, 19:31
kill_s, Используй циклы, например for или foreach.
0
0 / 0 / 0
Регистрация: 27.02.2011
Сообщений: 38
08.05.2011, 17:18  [ТС]
что-то я не совсем понял.....мне использовать класс описанный выше(если его, то там возникает такая вот ошибка "Имя типа или пространства имен "AVIFileInit" отсутствует в пространстве имен "Microsoft.Win32" (пропущена ссылка на сборку?)" или же просто подключить библиотеки из AForge(тогда в какой из dll находится этот AVIwriter).....

Добавлено через 21 час 21 минуту
всем спасибо! решил проблему сам....оказывается, всего-то надо было создать еще один класс win32(есть в примерах вместе с библиотекой AForge)...ну а как загрузить несколько картинок, тоже решил вот так вот:
C#
1
2
3
4
5
6
7
8
  AVIWriter writer = new AVIWriter();
            Bitmap image = new Bitmap("image1.jpg");
            writer.Open("1.avi", image.Width, image.Height);
            for (int i = 0; i < 5; i++)
            {
            writer.AddFrame(image);
            }
            writer.Close();
еще раз всем спасибо!!!!!!!!
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
08.05.2011, 17:18
Помогаю со студенческими работами здесь

Части avi в один файл
Добрый день! У меня есть четыре части видео в формате avi. Как мне их соединить в один файл? А то чем не пробовал (VirtualDub и Vegas)...

Нужно из кусков разных фильмов (avi, mpg) создать один avi
Такая задача. Нужно из кусков разных фильмов (avi, mpg) создать один avi. Помогите кто чем может.

Как склеить два файла формата ".AVI" ?!
Существует ли простой метод для склеивания 2-х файлов типа &quot;.avi&quot;, где 2-й является продолжением 1-го ?! Либо необходимо использовать...

Склеить AVI из кадров и WAV с микрофона
Тут такое дело. Получаю кадры изображения с камеры и заношу их в AVI файл. Параллельно получаю звук с микрофона (в буффер и в wav файл)....

Как склеить 30 csv в один
Всем привет как склеить 30 csv файлов в один? При условии что в каждом файле есть шапка занимает 1 строчку и начиная со 2 файла эту...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
8
Ответ Создать тему
Новые блоги и статьи
Советы по крайней бережливости. Внимание, это ОЧЕНЬ длинный пост.
Programma_Boinc 28.12.2025
Советы по крайней бережливости. Внимание, это ОЧЕНЬ длинный пост. Налог на собак: https:/ / **********/ gallery/ V06K53e Финансовый отчет в Excel: https:/ / **********/ gallery/ bKBkQFf Пост отсюда. . .
Кто-нибудь знает, где можно бесплатно получить настольный компьютер или ноутбук? США.
Programma_Boinc 26.12.2025
Нашел на реддите интересную статью под названием Anyone know where to get a free Desktop or Laptop? Ниже её машинный перевод. После долгих разбирательств я наконец-то вернула себе. . .
Thinkpad X220 Tablet — это лучший бюджетный ноутбук для учёбы, точка.
Programma_Boinc 23.12.2025
Рецензия / Мнение/ Перевод Нашел на реддите интересную статью под названием The Thinkpad X220 Tablet is the best budget school laptop period . Ниже её машинный перевод. Thinkpad X220 Tablet —. . .
PhpStorm 2025.3: WSL Terminal всегда стартует в ~
and_y87 14.12.2025
PhpStorm 2025. 3: WSL Terminal всегда стартует в ~ (home), игнорируя директорию проекта Симптом: После обновления до PhpStorm 2025. 3 встроенный терминал WSL открывается в домашней директории. . .
Как объединить две одинаковые БД Access с разными данными
VikBal 11.12.2025
Помогите пожалуйста !! Как объединить 2 одинаковые БД Access с разными данными.
Новый ноутбук
volvo 07.12.2025
Всем привет. По скидке в "черную пятницу" взял себе новый ноутбук Lenovo ThinkBook 16 G7 на Амазоне: Ryzen 5 7533HS 64 Gb DDR5 1Tb NVMe 16" Full HD Display Win11 Pro
Музыка, написанная Искусственным Интеллектом
volvo 04.12.2025
Всем привет. Некоторое время назад меня заинтересовало, что уже умеет ИИ в плане написания музыки для песен, и, собственно, исполнения этих самых песен. Стихов у нас много, уже вышли 4 книги, еще 3. . .
От async/await к виртуальным потокам в Python
IndentationError 23.11.2025
Армин Ронахер поставил под сомнение async/ await. Создатель Flask заявляет: цветные функции - провал, виртуальные потоки - решение. Не threading-динозавры, а новое поколение лёгких потоков. Откат?. . .
Поиск "дружественных имён" СОМ портов
Argus19 22.11.2025
Поиск "дружественных имён" СОМ портов На странице: https:/ / norseev. ru/ 2018/ 01/ 04/ comportlist_windows/ нашёл схожую тему. Там приведён код на С++, который показывает только имена СОМ портов, типа,. . .
Сколько Государство потратило денег на меня, обеспечивая инсулином.
Programma_Boinc 20.11.2025
Сколько Государство потратило денег на меня, обеспечивая инсулином. Вот решила сделать интересный приблизительный подсчет, сколько государство потратило на меня денег на покупку инсулинов. . . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2025, CyberForum.ru