PixelGrabber fails for large images?

PixelGrabber fails for large images?

Post by Mark Dob » Thu, 28 Mar 1996 04:00:00


Hello,

I'm fairly new to java (who isn't?) and I'm having a problem using a
PixelGrabber in an application.

It works for smaller images, but fails for larger images. The status
code is ABORT | ERROR, not very helpful. This error actually comes from
the ImageProducer sun.awt.image.FileImageSource. I've boiled the problem
down to the code below, which is basically the same as the example in
the PixelGrabber docs.

384x384 pixels is OK, 450x450 is not. I'm guessing its a memory thing
which I think could be fixed with these options of the java interpreter,
but when I try them it says illegal option.

    -ss<number>       set the C stack size of a process
    -oss<number>      set the JAVA stack size of a process
    -ms<number>       set the initial Java heap size
    -mx<number>       set the maximum Java heap size

I get the same problems using Linux and Solaris and a different problem
altogether on IRIX (there it refuses to run as an application at all,
Null pointer in getImage).

So,

 - is the PixelGrabber (or the ImageProducer actually) failing because
   the heap or stack is too small? Or is it a bug somewhere?

 - how do I invoke these options to java? Or is that another bug?

Thanks for any help and advice,

                                Mark

Here's the code... with lots of debugging output :)

import java.awt.* ;
import java.awt.image.* ;
import java.applet.Applet ;

public class PGTestApp extends Applet
{
  String image_filename ;

  /**************************************************************/

  /**
        Create a PGTestApp that tests PixelGrabber
  */
  public PGTestApp(String filename)
  {
        image_filename = filename ;
  }

  /**************************************************************/

  /**
        Get an image and try and get its pixels using a PixelGrabber
  */
  public void init()
  {
        Image           image ;
        int             width, height ;
        int[]           pixels ;
        PixelGrabber    pg ;

        /* get the images to display */
        image = getToolkit().getImage(image_filename) ;

        /* get the dimensions of the image */
        width  = image.getWidth(this) ;
        height = image.getHeight(this) ;

        /* is the image here yet? */
        if ((width == -1) || (height == -1))
        {
                /* use a MediaTracker to wait for the image to load */
                MediaTracker track = new MediaTracker(this) ;
                track.addImage(image, 0) ;
                try { track.waitForAll() ; }
                catch (InterruptedException e)
                {
                        System.err.println("PGTestApp : interrupted while waitin
                        return ;
                }

                /* get the real width and height */
                width  = image.getWidth(this) ;
                height = image.getHeight(this) ;
System.err.println("image is " + width + "x" + height + "(" + image.getSource()
        }
System.err.println("image is " + width + "x" + height + "(" + image.getSource()

        /* create an array to store the pixels in */
        pixels = new int[width * height] ;

        /* get the pixels from the image */
        pg = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width) ;
        try
        {
                if (!pg.grabPixels())
                {
                        System.err.println("PGTestApp: error grabbing pixels");
System.err.println("status is " + pg.status()) ;
                        return ;
                }
        }
        catch (InterruptedException e)
        {
                System.err.println("PGTestApp : interrupted while waiting for pi
                return ;
        }
        if ((pg.status() & ImageObserver.ABORT) != 0)
        {
                System.err.println("PGTestApp : error with pixels");
System.err.println("image is " + width + "x" + height + "(" + image.getSource()
                        return ;
        }

System.err.println("PGTestApp : we have the pixels") ;
  }

  /**************************************************************/

  /**
         Main method for running as an application
  */
  public static void main(String args[])
  {
        Frame           main_window ;
        PGTestApp       app ;

System.out.println("version " +
                   System.getProperty("java.version") +
                   "classes " +
                   System.getProperty("java.class.version")) ;

        /* check args */
        if (args.length != 1)
        {
                System.out.println("usage : PGTestApp image_file") ;
                return ;
        }

        /* create a window */
        main_window = new Frame("PixelGrabber Test") ;

        /* and the app */
        app = new PGTestApp(args[0]) ;
        app.init() ;

        /* add it to the window */
        main_window.add("Center", app) ;
        main_window.resize(100,100) ;
        main_window.show() ;
  }

Quote:}

  /**************************************************************/

--
Mark Dobie                                      University of Southampton

http://www.ecs.soton.ac.uk/~mrd/cv.html     <------ Queen discographies from here

 
 
 

1. Booting "large" images from network

Hi,

Currently I'm doing some stuff with booting over LAN. I've set up a
bootp and tftp server and have tested with 88k large image of memtest86
(How small can a OS be ;-). Ok, that worked fine. But Now i got 1.5mb
linux kernel. It says it is too large (client side). Are there any ways
to work around this problem? I've also got clumpos in the planning for
testing na dit got 3mb image. It would be ideal to get those at least
those 2 booting from the network. If plan to create a cluster I won't
even need a CDrom ;-)

Thanks in advanced,

Frank de Bot

2. Drivers wanted for Specialix serial boards

3. X-windows problem with large images

4. Does a Panasonic CR-563-B CD-ROM drive act like a CR-562?

5. Batch crop a single large image to many smaller ones?

6. switching default editor

7. How large a CD image can I burn?

8. Connecting to TP stream module ?

9. Need a program in Linux to resize a large amount of images/icons with one shot.

10. Telent & ssh: Form Image Too Large

11. Large Mac Image

12. image size too large

13. Failed to fetch large files from Canon A70 via USB: 'Corrupted data'