ns27
ns27

Reputation: 3

create too big BMP file in Ram produce argument exception

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?

Upvotes: 0

Views: 423

Answers (1)

ryan0
ryan0

Reputation: 1525

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

Upvotes: 1

Related Questions