Hi@All, 

 This solution is ok if you want to determine the memory effort of your image data. 
But it does not include the overhead for the BufferedImage object at runtime. 

 As far as i know it is not possible to determine the size for a object at runtime. 
Please post that information if you know how to determine that size! I'm also 
interested in that subject. 

 Have a nice day 

 Joerg



-----Urspr�ngliche Nachricht-----
Von: Damian Dixon [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 24. Juli 2002 09:04
Betreff: Re: BufferedImage


Hi Ed,

Yes it is possible. The following is taken from 'Java 2D Graphics' by
Jonathon Knudsen, page 326:

public static long getImageSize(BufferedImage image) {
  DataBuffer db = image.getRaster().getDataBuffer();
  int dataType = db.getDataType();
  int elementSizeInBits = DataBuffer.getDataTypeSize(dataType);
  return db.getNumBanks() * db.getSize() * elementSizeInBits / 8;
}

According to the text in the book this calculates the full size of the
image's data buffers.

Hope this helps
Regards
Damian

> -----Original Message-----
> From: Ed Brown [mailto:[EMAIL PROTECTED]]
> Sent: 23 July 2002 18:28
> To: [EMAIL PROTECTED]
> Subject: [JAVA2D] BufferedImage
>
>
> Hi All
>
> Is it possible to get a measure of how much memory a
> BufferedImage object is taking up?
>
> Thanks
> Ed Brown
>
> ==============================================================
> =============
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body
> of the message "signoff JAVA2D-INTEREST".  For general help,
> send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

==========================================================================To 
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to