Picture scaling - memory issues

Discussion in 'Java' started by jonck, May 11, 2005.

  1. jonck

    jonck Guest

    Hi,
    In my app people can load a picture, which I then show in a scaled down
    version. To do the scaling I follow the sample code as shown here:
    http://javaalmanac.com/egs/java.awt.image/CreateTxImage.html

    All this works fine, though sometimes if a user loads in a very large
    pictuer I get an OutOfMemory error. Now ideally what I would like to do
    is test before the picture is loaded whether there is enough memory
    available to do the operation. In order to do that I would need to get
    an idea of how much memory will be needed to do the scaling.
    Does anyone know what (roughly) the proportion is of memory used to the
    size and depth of the picture?

    Thanks, Jonck
     
    jonck, May 11, 2005
    #1
    1. Advertising

  2. jonck wrote:
    > All this works fine, though sometimes if a user loads in a very large
    > pictuer I get an OutOfMemory error. Now ideally what I would like to do
    > is test before the picture is loaded whether there is enough memory
    > available to do the operation.


    This is in general unpredictable. During the (small) time between your
    test for memory and the loading of the image some other process might
    have gotten the memory. So even if your test tells you that there is
    enough memory, you application might fail later.

    /Thomas
     
    Thomas Weidenfeller, May 11, 2005
    #2
    1. Advertising

  3. "jonck" <> schreef in bericht
    news:...
    > Hi,
    > In my app people can load a picture, which I then show in a scaled down
    > version. To do the scaling I follow the sample code as shown here:
    > http://javaalmanac.com/egs/java.awt.image/CreateTxImage.html
    >
    > All this works fine, though sometimes if a user loads in a very large
    > pictuer I get an OutOfMemory error.


    There are algorithms that don't have to load the entire image before scaling
    begins.

    > Now ideally what I would like to do
    > is test before the picture is loaded whether there is enough memory
    > available to do the operation. In order to do that I would need to get
    > an idea of how much memory will be needed to do the scaling.
    > Does anyone know what (roughly) the proportion is of memory used to the
    > size and depth of the picture?


    1
     
    Boudewijn Dijkstra, May 11, 2005
    #3
  4. "Boudewijn Dijkstra" <> schreef in bericht
    news:428251bc$0$1340$...
    > "jonck" <> schreef in bericht
    > news:...
    >> Hi,
    >> In my app people can load a picture, which I then show in a scaled down
    >> version. To do the scaling I follow the sample code as shown here:
    >> http://javaalmanac.com/egs/java.awt.image/CreateTxImage.html
    >>
    >> All this works fine, though sometimes if a user loads in a very large
    >> pictuer I get an OutOfMemory error.

    >
    > There are algorithms that don't have to load the entire image before scaling
    > begins.
    >
    >> Now ideally what I would like to do
    >> is test before the picture is loaded whether there is enough memory
    >> available to do the operation. In order to do that I would need to get
    >> an idea of how much memory will be needed to do the scaling.
    >> Does anyone know what (roughly) the proportion is of memory used to the
    >> size and depth of the picture?

    >
    > 1


    Unless of course you have the image in video memory, in which case the rough
    proportion is 0.
     
    Boudewijn Dijkstra, May 14, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?REVXcmlnaHRfQ0E=?=

    Control Scaling???

    =?Utf-8?B?REVXcmlnaHRfQ0E=?=, Apr 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    340
    Steven Cheng[MSFT]
    Apr 27, 2005
  2. =?Utf-8?B?REVXcmlnaHRfQ0E=?=

    Control Scaling???

    =?Utf-8?B?REVXcmlnaHRfQ0E=?=, Apr 26, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    418
    Steven Cheng[MSFT]
    Apr 28, 2005
  3. Erick Crouse
    Replies:
    2
    Views:
    420
    Nigel Wade
    Oct 3, 2006
  4. greg
    Replies:
    0
    Views:
    139
  5. Replies:
    8
    Views:
    1,324
    Mick White
    Apr 19, 2005
Loading...

Share This Page