0

I have a jpeg image 10,000px by 10,000px in Format24bppArgb 11MB, but after I clone it and save it as bmp in Format32bppArgb, it goes up to 500MB, any reason why?

let file = new Bitmap("planet.jpg")
let rect = new Rectangle(0, 0, file.Width, file.Height)
let img = file.Clone(rect, PixelFormat.Format32bppArgb)
img.Save("copy.bmp", ImageFormat.Bmp)
Dakaa
  • 199
  • 9
  • 10
    Yes, BMPs have no data compression. – Paul Abbott Apr 18 '14 at 00:11
  • 2
    @paul.abbot.wa.us Yes bitmaps have no compression, but 10000 pixels * 10000 pixels * 32 bits-per-pixel = 320,000,000 bits = 40,000,000 bytes = roughly 40MB. That's what the raw data adds up to - so where does the extra 460MB come from? – Joel Mueller Apr 21 '14 at 20:45
  • possible duplicate of [Converting Bitmap PixelFormats in C#](http://stackoverflow.com/questions/2016406/converting-bitmap-pixelformats-in-c-sharp) – Paul Sweatte Jan 26 '15 at 05:05
  • 1
    @JoelMueller 10,000 * 10,000 * 32 is actually 3,200,000,000, which ends up being about 400 MB. There's still a bit missing, but at least it's a lot closer. – Roujo Feb 17 '16 at 19:38

1 Answers1

0

I went ahead an ran the following in FSI:

open System.Drawing
open System.Drawing.Imaging

let file = new Bitmap("planet.jpg")
let rect = new Rectangle(0, 0, file.Width, file.Height)
let img = file.Clone(rect, PixelFormat.Format32bppArgb)
img.Save("copy.bmp", ImageFormat.Bmp)

I used a blank 10,000px by 10,000px JPG file clocking in at 1,563,127 bytes according to Windows Explorer. The resulting copy.bmp is 400,000,054 bytes, which is indeed a lot bigger than the input.

As @PaulAbbott said, this is because there's no compression in bitmap files. A 10,000 by 10,000 image at 32 bits per pixel will end up being stored as 3,200,000,000 bits, which is exactly 400,000,000 bytes or roughly 400 MB - which is around the size you posted.

If the file you got really was 500 MB and not around 400 MB, could you try hosting it somewhere? I'd like to take a look at it and see if I'm missing something here.

Roujo
  • 503
  • 4
  • 12