Once again, you won't be able to handle such huge images (1GB) on Windows
32bit, whatever you try - managed code and GDI+, unmanaged code and GDI+ or
DirectX ... you name it - it will fail sooner than later, there is simply no
space in a process to accommodate such huge arrays, note I said arrays,
using System.Drawing(GDI+) you need memory space for the compressed raw
image (unmanaged heap), you need space in the managed heap for the image
data and you need space for the uncompressed image. Probably you want to
handle multiple images, so, even if it works for the first couple of images
(size dependent) if will certainly fail for one the following due to memory
fragmentation.
What I would suggest is that you write a very basic console application that
handles one image, run this in an unmanaged debugger like windbg.exe and
issue the !address -summary command. You will see that the largest free
region is ~1.1GB even before a single image is loaded.
Another point you seem to ignore, is the fact that this all doesn't work in
asp.net, you can't use GDI+ (System.Drawing) or DirectX in a web
application.
Willy.
| But I'm not able to handle a jpeg image (for example) in parts. If I
| would do so, I would have load the whole image into memory to get parts
| of it (because of compression)
|
| I've decided to take a look on DirectX. Perhaps it has a method that
| can handle jpeg images. If I use unmanaged code, I would have to write
| the jpeg decompression algorithm on my own :-( This would be too hard
| for me and too time intensive...
|
| Thanks for all your help!
|
| --
| Gerrit Horeis
|
| Software Developer
| CI-Gate Development & Consulting GmbH
|
http://www.ci-gate.de
|
http://www.xira.de
|
http://www.bitbauer.de
|
| Ignacio Machin ( .NET/ C# MVP ) schrieb:
|
| > Hi,
| >
| > You will not be able to handle such a big image in memory. You would
have to
| > devise a way to use it in parts.
| > Also select carefully your tools, I don't think System.Drawing can
handle
| > such a big image, you would be better using DirectX or even better image
| > manipulation code written in unmanaged code.
| >
| >
| > --
| > --
| > Ignacio Machin,
| > ignacio.machin AT dot.state.fl.us
| > Florida Department Of Transportation
| >
| > | > > Hi Jon,
| > >
| > > yes this pictures are really up to 1GB. My method to shrink the images
| > > works fine until a (decompressed) FileSize of 350 MB is reached.
| > >
| > > If I do it in pieces, I also need to decompress the Picture on
harddisk
| > > as a bmp file and then read it into memory in small pieces. But to
| > > decompress such a large picture with an .Net service or something i
| > > will have to load it into memory anyway, which would cause a OOM
| > > exception.
| > >
| > > Do I have to use unmanaged code? Or is there a Windows API or anything
| > > else I could use?
| > >
| > > --
| > > Gerrit Horeis
| > >
| > > Software Developer
| > > CI-Gate Development & Consulting GmbH
| > >
http://www.ci-gate.de
| > >
http://www.xira.de
| > >
http://www.bitbauer.de
| > >
| > >
| > > Jon schrieb:
| > >
| > >> > I want to upload an image to a web application and therefore i need
to
| > >> > allocate this memory to fill the byte array with image data. Then I
| > >> > need to do a resizing operation.
| > >>
| > >> Is your image really 420MB large? That's really pretty massive. Can
you
| > >> not do it in pieces? If not, perhaps you could launch a different
| > >> process to do the loading and resizing. That process could write the
| > >> result to disk, and then you could stream it to the web application.
| > >>
| > >> --
| > >> Jon Skeet - <
[email protected]>
| > >>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
| > >> If replying to the group, please do not mail me too
| > >
|