473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C# Image

I am developing an application that possibly opens very large images - bmp,
jpeg, tiff. I have 2 questions:

Language: C#, VS .NET 2003.

1. When the program opens a BMP image, the amount of memory used seems to be
larger for BMP files than JPEGs with the same pixel dimensions. For example,
5200 x 5000 pixels image -- increase in Mem Usage is about 80MB for JPEG, but
200MB for BMP (with Task Manager). The Mem Usage is noted before and after
the following command:
Image image = new Bitmap(filename);
Is there something going on here? While this does not really matter
normally, it leads to the second question below.

2. I am getting "Out of Memory" exceptions if I open a large enough image or
a few large images. (I notice that this happens when the Mem Usage exceeds
1GB for the process when checked with Task Manager - the PC used has 2.5GB
RAM). Is there any setting that is needed to enable the application to deal
with such large images (assuming that the RAM can be increased if required)?
Sep 6 '06 #1
4 3427
Do you really need the whole of that image? If the image is that large,
maybe it suffices to work with parts of the image.

/ Rickard

LT.Ang wrote:
I am developing an application that possibly opens very large images - bmp,
jpeg, tiff. I have 2 questions:

Language: C#, VS .NET 2003.

1. When the program opens a BMP image, the amount of memory used seems to be
larger for BMP files than JPEGs with the same pixel dimensions. For example,
5200 x 5000 pixels image -- increase in Mem Usage is about 80MB for JPEG, but
200MB for BMP (with Task Manager). The Mem Usage is noted before and after
the following command:
Image image = new Bitmap(filename);
Is there something going on here? While this does not really matter
normally, it leads to the second question below.

2. I am getting "Out of Memory" exceptions if I open a large enough image or
a few large images. (I notice that this happens when the Mem Usage exceeds
1GB for the process when checked with Task Manager - the PC used has 2.5GB
RAM). Is there any setting that is needed to enable the application to deal
with such large images (assuming that the RAM can be increased if required)?
Sep 6 '06 #2
1. When the program opens a BMP image, the amount of memory used seems to
be
larger for BMP files than JPEGs with the same pixel dimensions. For
example,
5200 x 5000 pixels image -- increase in Mem Usage is about 80MB for JPEG,
but
200MB for BMP (with Task Manager). The Mem Usage is noted before and after
the following command:
Image image = new Bitmap(filename);
Is there something going on here? While this does not really matter
normally, it leads to the second question below.
Yes, there's something going on. JPG format supports compression, while BMP
does not.
2. I am getting "Out of Memory" exceptions if I open a large enough image
or
a few large images. (I notice that this happens when the Mem Usage exceeds
1GB for the process when checked with Task Manager - the PC used has 2.5GB
RAM). Is there any setting that is needed to enable the application to
deal
with such large images (assuming that the RAM can be increased if
required)?
It may be necessary to process the image in chunks. That is, open the image
file, using a stream, and read part of the image file into memory prior to
working with it.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"LT.Ang" <LT****@discussions.microsoft.comwrote in message
news:82**********************************@microsof t.com...
>I am developing an application that possibly opens very large images - bmp,
jpeg, tiff. I have 2 questions:

Language: C#, VS .NET 2003.

1. When the program opens a BMP image, the amount of memory used seems to
be
larger for BMP files than JPEGs with the same pixel dimensions. For
example,
5200 x 5000 pixels image -- increase in Mem Usage is about 80MB for JPEG,
but
200MB for BMP (with Task Manager). The Mem Usage is noted before and after
the following command:
Image image = new Bitmap(filename);
Is there something going on here? While this does not really matter
normally, it leads to the second question below.

2. I am getting "Out of Memory" exceptions if I open a large enough image
or
a few large images. (I notice that this happens when the Mem Usage exceeds
1GB for the process when checked with Task Manager - the PC used has 2.5GB
RAM). Is there any setting that is needed to enable the application to
deal
with such large images (assuming that the RAM can be increased if
required)?

Sep 6 '06 #3
Thanks for the response.

1. Sorry the question was not too clear. It's true JPEG is compressed while
on disk. The JPEG file size was only about 1.5MB. But once it is opened as a
Bitmap, the expected memory usage should be width x height x 4 bytes - the
size noted for the bitmap loaded from JPEG was quite close [slightly smaller]
to the expected but the BMP is almost double (and that is the puzzle). The
current workaround used is...

Image image1 = new Bitmap("sample.bmp"); //use ~200MB
Image image2 = new Bitmap(image1); //use ~100MB
image1.Dispose();
// use image2 from this point onwards.

Having to use this method has its drawback - more memory is used while both
image1 and image2 are opened so this decreases the largest image size
possible. This is the reason why I am trying to understand what is happening
with line 1.

2. The user is allowed to draw on or edit the image just like a picture
editor. Is there any way to avoid dealing with chunks of the image even if
that is possible in this application? Like -- probably a way to maximize the
memory usage. A 32 bit machine should allow up to 4GB memory usage but the
current ceiling seems to be around 1GB.

LTAng
"Kevin Spencer" wrote:
1. When the program opens a BMP image, the amount of memory used seems to
be
larger for BMP files than JPEGs with the same pixel dimensions. For
example,
5200 x 5000 pixels image -- increase in Mem Usage is about 80MB for JPEG,
but
200MB for BMP (with Task Manager). The Mem Usage is noted before and after
the following command:
Image image = new Bitmap(filename);
Is there something going on here? While this does not really matter
normally, it leads to the second question below.

Yes, there's something going on. JPG format supports compression, while BMP
does not.
2. I am getting "Out of Memory" exceptions if I open a large enough image
or
a few large images. (I notice that this happens when the Mem Usage exceeds
1GB for the process when checked with Task Manager - the PC used has 2.5GB
RAM). Is there any setting that is needed to enable the application to
deal
with such large images (assuming that the RAM can be increased if
required)?

It may be necessary to process the image in chunks. That is, open the image
file, using a stream, and read part of the image file into memory prior to
working with it.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"LT.Ang" <LT****@discussions.microsoft.comwrote in message
news:82**********************************@microsof t.com...
I am developing an application that possibly opens very large images - bmp,
jpeg, tiff. I have 2 questions:

Language: C#, VS .NET 2003.

1. When the program opens a BMP image, the amount of memory used seems to
be
larger for BMP files than JPEGs with the same pixel dimensions. For
example,
5200 x 5000 pixels image -- increase in Mem Usage is about 80MB for JPEG,
but
200MB for BMP (with Task Manager). The Mem Usage is noted before and after
the following command:
Image image = new Bitmap(filename);
Is there something going on here? While this does not really matter
normally, it leads to the second question below.

2. I am getting "Out of Memory" exceptions if I open a large enough image
or
a few large images. (I notice that this happens when the Mem Usage exceeds
1GB for the process when checked with Task Manager - the PC used has 2.5GB
RAM). Is there any setting that is needed to enable the application to
deal
with such large images (assuming that the RAM can be increased if
required)?


Sep 6 '06 #4
Maybe this is similar to your problem?
http://groups.google.se/group/micros...9a5f29792d9534

LT.Ang wrote:
Thanks for the response.

1. Sorry the question was not too clear. It's true JPEG is compressed while
on disk. The JPEG file size was only about 1.5MB. But once it is opened as a
Bitmap, the expected memory usage should be width x height x 4 bytes - the
size noted for the bitmap loaded from JPEG was quite close [slightly smaller]
to the expected but the BMP is almost double (and that is the puzzle). The
current workaround used is...

Image image1 = new Bitmap("sample.bmp"); //use ~200MB
Image image2 = new Bitmap(image1); //use ~100MB
image1.Dispose();
// use image2 from this point onwards.

Having to use this method has its drawback - more memory is used while both
image1 and image2 are opened so this decreases the largest image size
possible. This is the reason why I am trying to understand what is happening
with line 1.

2. The user is allowed to draw on or edit the image just like a picture
editor. Is there any way to avoid dealing with chunks of the image even if
that is possible in this application? Like -- probably a way to maximize the
memory usage. A 32 bit machine should allow up to 4GB memory usage but the
current ceiling seems to be around 1GB.

LTAng
"Kevin Spencer" wrote:
>>1. When the program opens a BMP image, the amount of memory used seems to
be
larger for BMP files than JPEGs with the same pixel dimensions. For
example,
5200 x 5000 pixels image -- increase in Mem Usage is about 80MB for JPEG,
but
200MB for BMP (with Task Manager). The Mem Usage is noted before and after
the following command:
Image image = new Bitmap(filename);
Is there something going on here? While this does not really matter
normally, it leads to the second question below.
Yes, there's something going on. JPG format supports compression, while BMP
does not.
>>2. I am getting "Out of Memory" exceptions if I open a large enough image
or
a few large images. (I notice that this happens when the Mem Usage exceeds
1GB for the process when checked with Task Manager - the PC used has 2.5GB
RAM). Is there any setting that is needed to enable the application to
deal
with such large images (assuming that the RAM can be increased if
required)?
It may be necessary to process the image in chunks. That is, open the image
file, using a stream, and read part of the image file into memory prior to
working with it.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
"LT.Ang" <LT****@discussions.microsoft.comwrote in message
news:82**********************************@microso ft.com...
>>I am developing an application that possibly opens very large images - bmp,
jpeg, tiff. I have 2 questions:

Language: C#, VS .NET 2003.

1. When the program opens a BMP image, the amount of memory used seems to
be
larger for BMP files than JPEGs with the same pixel dimensions. For
example,
5200 x 5000 pixels image -- increase in Mem Usage is about 80MB for JPEG,
but
200MB for BMP (with Task Manager). The Mem Usage is noted before and after
the following command:
Image image = new Bitmap(filename);
Is there something going on here? While this does not really matter
normally, it leads to the second question below.

2. I am getting "Out of Memory" exceptions if I open a large enough image
or
a few large images. (I notice that this happens when the Mem Usage exceeds
1GB for the process when checked with Task Manager - the PC used has 2.5GB
RAM). Is there any setting that is needed to enable the application to
deal
with such large images (assuming that the RAM can be increased if
required)?

Sep 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Pierre Tremblay | last post by:
Hi! I am trying to display an image in my html document. The document contains the following line: <td class="Input"><img...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
8
by: Jef Driesen | last post by:
I'm implementing some image processing algorithms in C++. I created a class called 'image' (see declaration below), that will take care of the memory allocations and some basic (mathematical)...
6
by: QuasiChameleon | last post by:
Hi, I'm trying to create a grayscale image class that reads and writes grayscale Targa format. This works well with smaller images, but corrupts larger images and creates a "Segmentation fault...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
6
by: comp.lang.php | last post by:
/** * Generate the random security image * * @access public * @param $willUseFilePath (default false) boolean to determine if you will be using a file path * @param mixed $filePath (optional)...
1
by: bharathv6 | last post by:
i need to do is modify the image in memory like resizing the image in memory etc ... with out saving it disk as i have to return back the image with out saving it disk PIL supports the use of...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.