0

I'm creating an avi file out of bitmaps using C#.

I'm able to create the avi file if I use the stored .bmp files captured using a webcamera:

Bitmap bitmap = (Bitmap)Image.FromFile("abc.bmp");

But if I try to store the captured bitmaps in an array or arraylist, then the avi does not create correctly - says corrupted:

Bitmap bitmap = (Bitmap)BitMapList[0];

Note: BitMapList is a Bitmap array.

Can someone pls let me know what's the conflict out there?

2
  • There's probably something wrong in the way you store your bitmaps in memory. Could you provide a code snippet for that? Commented Apr 27, 2011 at 5:59
  • capturedImage.Save("abc.bmp", ImageFormat.Bmp); and capturedImage is System.Drawing.Image Commented Apr 27, 2011 at 6:06

1 Answer 1

1

Although the Bitmap class and the bitmap file format have similar names, they are not directly related.

The bitmap file format is one of the file formats for storing an image as a file. The Bitmap class is used to hold an image in memory. When you load any image format from a file it's decoded and you get a Bitmap object containing the image data, regardless of the file format. It's not specific to the bitmap file format.

There is nothing special in putting Bitmap objects in an array. If you see any difference, there has to be something wrong with how you put the objects in the array.

Sign up to request clarification or add additional context in comments.

2 Comments

From your answer, I feel the bitmap objects from the bitmap file and the bitmap object itself are different. The avi seems to accept only the bitmap objects from bitmap files, but since it is also a bitmap object, i would like to store them in an array other than saving all the bitmap files in the secondary storage. Can you pls give my any opinion on that?
@dia: If you are creating Bitmap object some other way than loading them from file, they may be different. Make sure that you use a PixelFormat value that is appropriate. The default is Format32bbpArgb, but when you load them from file it might be using Format24bbpRgb. You have to check what format the code that creates the avi is expecting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.