I have huge bitmap inmemory (about 4K x 6K 300dpi) and I want to quick
resize it so old fasion way:
Bitmap result = new Bitmap( nSize.Width, nSize.Height);
using(
Graphics g1 = Graphics.FromImage( (Image) result ) )
{
g1.DrawImage( b, 0, 0, nSize.Width, nSize.Height );
}
working rather fine the first (and even second time), but each time it used
the process takes x2 time (no difference between make the bitmap bigger or
smaller)
so the fifth time application crashed with no memory
Anyone can advice WHY and maybe better way to do this. I have concurrent one
image in application.
I do not want to go unmanaged this time.
thx
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us " 5 2364
Tamir,
Are you disposing of the Bitmap image correctly? You should be calling
Dispose on the images when done. Images of that size take quite a bit of
memory, and not disposing of them could cause performance degredation pretty
quickly.
Also, are you using them just as-needed, or caching them in memory? You
might want to reconsider caching them in memory if this is the case.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:Or*************@TK2MSFTNGP12.phx.gbl... I have huge bitmap inmemory (about 4K x 6K 300dpi) and I want to quick resize it so old fasion way: Bitmap result = new Bitmap( nSize.Width, nSize.Height); using( Graphics g1 = Graphics.FromImage( (Image) result ) ) { g1.DrawImage( b, 0, 0, nSize.Width, nSize.Height ); }
working rather fine the first (and even second time), but each time it used the process takes x2 time (no difference between make the bitmap bigger or smaller) so the fifth time application crashed with no memory
Anyone can advice WHY and maybe better way to do this. I have concurrent one image in application.
I do not want to go unmanaged this time.
thx
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
Hi, Nicholas and thank you for response,
as you can see I'm using following method for disposing:
using(
Graphics g1 = Graphics.FromImage( (Image) result ) )
because if I'll dispose the graphics before return the resized image will be
lost.
How can I cache the image within C#? are there any methods you know to do
this?
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OY*************@TK2MSFTNGP14.phx.gbl... Tamir,
Are you disposing of the Bitmap image correctly? You should be calling Dispose on the images when done. Images of that size take quite a bit of memory, and not disposing of them could cause performance degredation pretty quickly.
Also, are you using them just as-needed, or caching them in memory? You might want to reconsider caching them in memory if this is the case.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message news:Or*************@TK2MSFTNGP12.phx.gbl...I have huge bitmap inmemory (about 4K x 6K 300dpi) and I want to quick resize it so old fasion way: Bitmap result = new Bitmap( nSize.Width, nSize.Height); using( Graphics g1 = Graphics.FromImage( (Image) result ) ) { g1.DrawImage( b, 0, 0, nSize.Width, nSize.Height ); }
working rather fine the first (and even second time), but each time it used the process takes x2 time (no difference between make the bitmap bigger or smaller) so the fifth time application crashed with no memory
Anyone can advice WHY and maybe better way to do this. I have concurrent one image in application.
I do not want to go unmanaged this time.
thx
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
Tamir,
You are disposing of the Graphics context, but you are not disposing of
the image. When you are done with it, are you disposing of it? How are you
using it (the Bitmap variable).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:eQ**************@TK2MSFTNGP12.phx.gbl... Hi, Nicholas and thank you for response, as you can see I'm using following method for disposing: using( Graphics g1 = Graphics.FromImage( (Image) result ) ) because if I'll dispose the graphics before return the resized image will be lost. How can I cache the image within C#? are there any methods you know to do this?
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:OY*************@TK2MSFTNGP14.phx.gbl... Tamir,
Are you disposing of the Bitmap image correctly? You should be calling Dispose on the images when done. Images of that size take quite a bit of memory, and not disposing of them could cause performance degredation pretty quickly.
Also, are you using them just as-needed, or caching them in memory? You might want to reconsider caching them in memory if this is the case.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message news:Or*************@TK2MSFTNGP12.phx.gbl...I have huge bitmap inmemory (about 4K x 6K 300dpi) and I want to quick resize it so old fasion way: Bitmap result = new Bitmap( nSize.Width, nSize.Height); using( Graphics g1 = Graphics.FromImage( (Image) result ) ) { g1.DrawImage( b, 0, 0, nSize.Width, nSize.Height ); }
working rather fine the first (and even second time), but each time it used the process takes x2 time (no difference between make the bitmap bigger or smaller) so the fifth time application crashed with no memory
Anyone can advice WHY and maybe better way to do this. I have concurrent one image in application.
I do not want to go unmanaged this time.
thx
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
Bitmap m_bitmap;
//Loaded
m_bitmap = ResizeBitmap(m_bitmap,myNewSize);
it should be reused, no?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O2*************@tk2msftngp13.phx.gbl... Tamir,
You are disposing of the Graphics context, but you are not disposing of the image. When you are done with it, are you disposing of it? How are you using it (the Bitmap variable).
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message news:eQ**************@TK2MSFTNGP12.phx.gbl... Hi, Nicholas and thank you for response, as you can see I'm using following method for disposing: using( Graphics g1 = Graphics.FromImage( (Image) result ) ) because if I'll dispose the graphics before return the resized image will be lost. How can I cache the image within C#? are there any methods you know to do this?
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:OY*************@TK2MSFTNGP14.phx.gbl... Tamir,
Are you disposing of the Bitmap image correctly? You should be calling Dispose on the images when done. Images of that size take quite a bit of memory, and not disposing of them could cause performance degredation pretty quickly.
Also, are you using them just as-needed, or caching them in memory? You might want to reconsider caching them in memory if this is the case.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message news:Or*************@TK2MSFTNGP12.phx.gbl... I have huge bitmap inmemory (about 4K x 6K 300dpi) and I want to quick resize it so old fasion way: Bitmap result = new Bitmap( nSize.Width, nSize.Height); using( Graphics g1 = Graphics.FromImage( (Image) result ) ) { g1.DrawImage( b, 0, 0, nSize.Width, nSize.Height ); }
working rather fine the first (and even second time), but each time it used the process takes x2 time (no difference between make the bitmap bigger or smaller) so the fifth time application crashed with no memory
Anyone can advice WHY and maybe better way to do this. I have concurrent one image in application.
I do not want to go unmanaged this time.
thx
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
Tamir,
I'm going to assumpe that m_bitmap is a field in a class. Does this
class implement IDisposable? If so, is it being called correctly when done?
The bitmap is never being GCed as soon as it can be if it is not being
disposed (not to mention the unmanaged resources that are waiting to be
disposed of).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:e$**************@TK2MSFTNGP15.phx.gbl... Bitmap m_bitmap; //Loaded m_bitmap = ResizeBitmap(m_bitmap,myNewSize); it should be reused, no?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:O2*************@tk2msftngp13.phx.gbl... Tamir,
You are disposing of the Graphics context, but you are not disposing of the image. When you are done with it, are you disposing of it? How are you using it (the Bitmap variable).
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message news:eQ**************@TK2MSFTNGP12.phx.gbl... Hi, Nicholas and thank you for response, as you can see I'm using following method for disposing: using( Graphics g1 = Graphics.FromImage( (Image) result ) ) because if I'll dispose the graphics before return the resized image will be lost. How can I cache the image within C#? are there any methods you know to do this?
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:OY*************@TK2MSFTNGP14.phx.gbl... Tamir,
Are you disposing of the Bitmap image correctly? You should be calling Dispose on the images when done. Images of that size take quite a bit of memory, and not disposing of them could cause performance degredation pretty quickly.
Also, are you using them just as-needed, or caching them in memory? You might want to reconsider caching them in memory if this is the case.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message news:Or*************@TK2MSFTNGP12.phx.gbl... >I have huge bitmap inmemory (about 4K x 6K 300dpi) and I want to quick >resize it so old fasion way: > Bitmap result = new Bitmap( nSize.Width, nSize.Height); > using( > Graphics g1 = Graphics.FromImage( (Image) result ) ) > { > g1.DrawImage( b, 0, 0, nSize.Width, nSize.Height ); > } > > working rather fine the first (and even second time), but each time it > used the process takes x2 time (no difference between make the bitmap > bigger or smaller) > so the fifth time application crashed with no memory > > Anyone can advice WHY and maybe better way to do this. I have > concurrent one image in application. > > I do not want to go unmanaged this time. > > thx > > -- > Tamir Khason > You want dot.NET? Just ask: > "Please, www.dotnet.us " > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris Dewin |
last post by:
Hi. I run a website for my band, and the other guys want an image gallery.
I'm thinking it would be nice and easy, if we could just upload a jpg into
a dir called "gallery/". When the client...
|
by: Carl Gilbert |
last post by:
Hi
I am looking for either a component or technique to allow me to do the
following:
* Provide a panel with a background image
* Resize the image to best fit the panel to maintain aspect...
|
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...
|
by: Arjen |
last post by:
Hi,
I want to resize an image on my server.
I tried a lot of samples... but all the time it does resize and saves the
images but I can not view the image insize a webbrowser.
With an...
|
by: Tim Arnold |
last post by:
Hi, I'm using the Image module to resize PNG images from 300 to 100dpi for
use in HTML pages, but I'm losing some vertical and horizontal lines in the
images (usually images of x-y plots).
...
|
by: Dominic Vella |
last post by:
Hi, I know I seem to have the really complicated questions, but I guess
that's why I'm here. This is a little verbose, only because I've been
trying to crack this for a week now.
Your help...
|
by: danielatdaveschool |
last post by:
Hi, noob here
Im using mod_python and apache2 using psp for output of page, i open a
file and resize it with the following code
<%
import Image, util
fields = util.FieldStorage(req)...
|
by: infoseekar |
last post by:
Image Resize & Rotation
Hi
I have 2 scripts, one for Image rotation and other image resize and they both are working.
Image resize scripts load the picture and resize it and Image rotation...
|
by: anfetienne |
last post by:
hi.....i have this script (below #1) that is linked to another php file SimpleImage.php (#2) im trying to get it to work on my uploaded images but it keeps coming up errors.....i haven't altered...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |