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.FromIm age( (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 2379
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.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:Or******** *****@TK2MSFTNG P12.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.FromIm age( (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.FromIm age( (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.c om> wrote in
message news:OY******** *****@TK2MSFTNG P14.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.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message news:Or******** *****@TK2MSFTNG P12.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.FromIm age( (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.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:eQ******** ******@TK2MSFTN GP12.phx.gbl... Hi, Nicholas and thank you for response, as you can see I'm using following method for disposing: using( Graphics g1 = Graphics.FromIm age( (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.c om> wrote in message news:OY******** *****@TK2MSFTNG P14.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.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message news:Or******** *****@TK2MSFTNG P12.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.FromIm age( (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,myNewSiz e);
it should be reused, no?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:O2******** *****@tk2msftng p13.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.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message news:eQ******** ******@TK2MSFTN GP12.phx.gbl... Hi, Nicholas and thank you for response, as you can see I'm using following method for disposing: using( Graphics g1 = Graphics.FromIm age( (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.c om> wrote in message news:OY******** *****@TK2MSFTNG P14.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.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message news:Or******** *****@TK2MSFTNG P12.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.FromIm age( (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.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:e$******** ******@TK2MSFTN GP15.phx.gbl... Bitmap m_bitmap; //Loaded m_bitmap = ResizeBitmap(m_ bitmap,myNewSiz e); it should be reused, no?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:O2******** *****@tk2msftng p13.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.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message news:eQ******** ******@TK2MSFTN GP12.phx.gbl... Hi, Nicholas and thank you for response, as you can see I'm using following method for disposing: using( Graphics g1 = Graphics.FromIm age( (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.c om> wrote in message news:OY******** *****@TK2MSFTNG P14.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.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message news:Or******** *****@TK2MSFTNG P12.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.FromIm age( (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 clicks the "gallery" link, a
cgi script could search the gallery/ dir, and create thumbnails of any
jpeg images that don't already have a thumbnail...
|
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 ratio
* Provide white (or other color) borders at the sides or the top/bottom
The last point would be used to allow users to resize the panel to any...
|
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 path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run...
|
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 imageviewer (desktop application) I can view the image. I believe
there is something wrong with the maximum colors...
This is what I have now...
Image...
|
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).
Here's what I do:
import Image
def imgResize(self,filename):
img = Image.open(filename)
dpi = img.info.get('dpi')
if dpi and 295 < int(dpi) < 305:
| |
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 would be appreciated.
I've been trying numerous ways to resize images, as I want to make store
thumbnails, not full images in my database.
...
|
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)
filename = fields.getlist('src')
|
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 rotate the image by 90 deg. They are two differennt files i.e. resize.php and rotate.php.
What I want to do is to combine both rotate.php &...
|
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 anything except for:
$image->load('picture.jpg');
$image->resize(546,403);
$image->save('picture2.jpg');
I put the variables i need in...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |