Hello everyone,

I have a ray-tracing code and I can successfully generate images taken from different view points. My generated image has 802x802 resolution. I am applying the same procedures for every different point of view. However, my generated .bmp files always have different file size. I wonder why? They should be the same, should not they?

Example
First image has:
Width: 802
Height: 802
Horizontal Resolution: 96 dpi
Vertical Resolution: 96 dpi
Bit Depth : 32
File Size : 1.493.909 bytes
File Size on Disk: 1.495.040 bytes

Second image has:
Width: 802
Height: 802
Horizontal Resolution: 96 dpi
Vertical Resolution: 96 dpi
Bit Depth : 32
File Size
File Size : 1.504.630 bytes
File Size on Disk: 1.507.328 bytes

802 * 802 * 4 = 2,572,816
Your files are less than that.

Most likely, your bitmaps are RLE encoded (a simple compression scheme which works well for large amounts of solid colour).

802 * 802 * 4 = 2,572,816
Your files are less than that.

Most likely, your bitmaps are RLE encoded (a simple compression scheme which works well for large amounts of solid colour).

Why did you multiply it by 4?

In my code,

Color[,] arr = new Color[802, 802];
Bitmap mybmp = new Bitmap(802, 802);

            for (int i = 0; i < 800; i++)
            {
                for (int j = 0; j < 800; j++)
                {
                    mybmp.SetPixel(i, j, buffer[i, j].ToArgb());
                }
            }
            mybmp.Save(yer);

This is how I save images. I didnt use any compressing method. Do you have any idea why I am always getting images which have different file sizes? Thank you.

> Bit Depth : 32
This is why

> mybmp.Save(yer);
Did you write the Save() method yourself?
Do you know how it works?
Sure, you store 800x800 pixels into the object, but that says nothing about how they're "encoded" for saving to disk.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.