954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Bitmap File

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

koliva
Newbie Poster
2 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

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).

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

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.

koliva
Newbie Poster
2 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

> 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.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You