• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Caching BufferedImages from byte[]

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a file containing serialized objects containing a byte[] representing a JPEG image.

What I need to do is read through the file via ObjectInputStream to deserialize the object so that I can get the byte[] and then convert it to BufferedImage.

The reason for doing this is due to the fact the a BufferedImage is not serializable so the JPEG image is serialized as byte[].

The reason for serializing the JPEG images into objects via OjectOutputStream is so that I can store some metadata for a particular frame and then display it as I am playing the sequence of images. (movie)

The issue is converting a byte[] to BufferedImage costs time to process. For example: a 5000 by 5000 JPG image in byte[] to BufferedImage takes 0.3 seconds. This will results in a 2 frame by second play back. if I want to play it as 10 frames per second, I would need to get the byte[] to BufferedImage conversion down to at a minimum 0.1 seconds.

If I was to process this at first or through some Thread, then I would need to store all of these processed images (BufferedImage) into memory. This would result in a JVM memory leak (OutOfMemory).

The next option where I am stuck on is caching these BufferedImages. (approx 50,000 frames at 200k per frames)

Is the a optimal caching soltion of these BufferedImages or is there a more optimal approach to serializing an object containing memtadata and byte[] (JPG image) and then streaming then as we read the file with a byte[] to BufferedImage conversion?

I am in need for some guidance or advice.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic