0

My code:

Dim bmp_ As New Bitmap(width, height)


' here is for-loop to fill up bitmap   ( bmp_.SetPixel(x, y, Color.White) )


bmp_.Save("D:\test.bmp", ImageFormat.Bmp)

That is working correctly for small files, but if i try this:

Dim bmp_ As New Bitmap(30000, 30000)

..then, i got ArgumentException on that line.

Question: Is there any way, how to create so big bmp file ?

thanks

EDIT: What if bitmap is 1000000 x 1000000 ? Is possible to create BMP file on harddisk and append data sequentially?

ns27
  • 3
  • 3
  • Just curious: What would you like to do with such a bitmap file? – ppeterka Oct 18 '12 at 13:48
  • this program just _display the files_ (which are output from my other programs) in binary form (0=black, 1=white) – ns27 Oct 18 '12 at 14:11
  • Ok, but what are on those files? What is a content that is so big? – ppeterka Oct 18 '12 at 14:13
  • See first comment: just curious. You know there are programmers, who like their jobs. – ppeterka Oct 18 '12 at 14:37
  • it is output from computations – ns27 Oct 18 '12 at 14:41
  • What is the format of your .bmp? Are you using 1 bpp? IIRC, a .bmp file is not compressed in memory so a 30000 x 30000 .bmp at 24 bpp takes more than 2.7 Gib of memory. Since you say it is only a BW image, can you try specifying it as 1 bpp when you create it? Another possibility is a memory mapped file. – Chris Dunaway Oct 18 '12 at 14:55
  • it say: PixelFormat = Format32bppArgb , yes i should use 1bpp, but problem remains (i updated question) – ns27 Oct 18 '12 at 15:05
  • You may want to compress it before displaying it. As you said, this is B&W so the is a lot of good algorithms that will allow you to decrease the size of the image. This will allow you to manipulate your image and not to worry about size... (it would be about ko). – Minus Oct 18 '12 at 20:23

1 Answers1

1

If you are using VS 2010, you can try increasing the amount of memory available to VB by adding these lines to the "Post Build Events" section in visual studio:

call "$(DevEnvDir)..\..\vc\vcvarsall.bat" x86
"$(DevEnvDir)..\..\vc\bin\EditBin.exe" "$(TargetPath)"  /LARGEADDRESSAWARE

This process is explained in further detail here:

http://blogs.msdn.com/b/calvin_hsia/archive/2010/09/27/10068359.aspx

ryan0
  • 1,482
  • 16
  • 21