Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Picture scaling - memory issues

Reply
Thread Tools

Picture scaling - memory issues

 
 
jonck
Guest
Posts: n/a
 
      05-11-2005
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....teTxImage.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

 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      05-11-2005
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
 
Reply With Quote
 
 
 
 
Boudewijn Dijkstra
Guest
Posts: n/a
 
      05-11-2005
"jonck" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) oups.com...
> 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....teTxImage.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


 
Reply With Quote
 
Boudewijn Dijkstra
Guest
Posts: n/a
 
      05-14-2005
"Boudewijn Dijkstra" <(E-Mail Removed)> schreef in bericht
news:428251bc$0$1340$(E-Mail Removed) .nl...
> "jonck" <(E-Mail Removed)> schreef in bericht
> news:(E-Mail Removed) oups.com...
>> 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....teTxImage.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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affine Transform - Negative Scaling Issues Erick Crouse Java 2 10-03-2006 09:29 AM
Scaling with ASP and Server Memory Issues greg ASP General 0 01-31-2006 11:06 AM
Page & Control Scaling? =?Utf-8?B?REVXcmlnaHRfQ0E=?= ASP .Net 1 05-26-2005 05:57 AM
Control Scaling??? =?Utf-8?B?REVXcmlnaHRfQ0E=?= ASP .Net 3 04-28-2005 07:54 AM
Control Scaling??? =?Utf-8?B?REVXcmlnaHRfQ0E=?= ASP .Net 1 04-27-2005 03:19 AM



Advertisments