Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6022873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:55:18+00:00 2026-05-23T03:55:18+00:00

I have a large swing component to write to TIFF. The component is too

  • 0

I have a large swing component to write to TIFF. The component is too large to load the TIFF in memory, so I either need to make a big BufferedImage which is backed by a disk-based WritableRaster (as mentioned here) or use JAI.

JAI seems like the better answer, aside from the utter confusion of the project.

Given that, can someone outline steps for writing my swing component to a tiled TIFF without running out of Memory?

Image size will be maybe 10000×700

Ideally I would create some sort of disk-based image, and write parts of the component to it, each write being flushed to disk.

EDIT

I think I could do this with an ImageWriter, however I’m getting a NoSuchElementException when I call:

ImageWriter imageWriter = ImageIO.getImageWritersByFormatName("tif").next();

I have the jai_code.jar and jai_core.jar jars on my classpath, is there something else I need to do?

EDIT
I can create a very large TIFF using JAI, but JAI doesn’t support TIFF compression, so the file is 92 MB.

If I install JAI-ImageIO, I can create a compressed TIFF Using an ImageWriter, but only from a Raster or BufferedImage, which I don’t have enough memory for.

Is there some way to do a two-step approach, use JAI to create the large TIFF, then compress the large TIFF without loading the whole thing into memory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:55:18+00:00Added an answer on May 23, 2026 at 3:55 am

    I had to load and store a large tiff (59392x40192px) with JAI. My solution is: TiledImages.

    I have used a TiledImage because I need tiles and subimages.
    To use the TiledImage efficient you should construct it with your prefered tile size. JAI uses a TileCache so not the whole Image will be in memory, when it’s not needed.

    To write the TiledImage in a File use the option “writeTiled” (avoid OutOfMemory because it writes tile by tile):

    public void storeImage(TiledImage img, String filepath) {
        TIFFEncodeParam tep = new TIFFEncodeParam();
        //important to avoid OutOfMemory
        tep.setTileSize(256, 256);
        tep.setWriteTiled(true);
        //fast compression
        tep.setCompression(TIFFEncodeParam.COMPRESSION_PACKBITS);
        //write file
        JAI.create("filestore", img, filepath, "TIFF", tep);
    }
    

    It works fine with images up to 690mb (compressed), for larger images i haven’t tested yet.

    But if you are working on WinXP 32-bit you may not able to have more as 1280m HeapSpace size, this is still a limit of Java VM.

    My TiledImage is build with a IndexedColorModel from my image-source data:

    //here you create a ColorModel for your Image
    ColorModel cm = source.createColorModel();
    //then create a compatible SampleModel, with the tilesize
    SampleModel sm = cm.createCompatibleSampleModel(tileWidth,tileHeight);
    
    TiledImage image = new TiledImage(0, 0, imageWidth, imageHeight, 0, 0, sm, cm);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a swing component which draws a fixed large (but fixed) vector image
I have a Swing app with a large panel which is wrapped in a
I have large text files upon which all kinds of operations need to be
Swing newbie question... I have a system where there is a large number of
We have a very large Java Swing desktop application comprising of a great deal
I have an array of entities that need to be replaced in a large
I have a large file, with 1.8 million rows of data, that I need
Till now, I have developed simple swing applications so there was no need to
We have a Swing app that processes relatively large amounts of data. For instance
I have large data sets (10 Hz data, so 864k points per 24 Hours)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.