Alessio Caiazza is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

nolith / CaptureMJPEG http://capturemjpeg.lilik.it/

CaptureMJPEG, a processing library for Motion JPEG stream. CaptureMJPEG is released under the LGPLv3 license.

Clone this repository (size: 3.3 MB): HTTPS / SSH
hg clone https://bitbucket.org/nolith/capturemjpeg
hg clone ssh://hg@bitbucket.org/nolith/capturemjpeg

Issues

#4 failure as applet

Reported by Alessio Caiazza

from macno

ubuntu 9.04, firefox 3.0.10 e java 1.5

Disabling captureEvent() for panel0 because of an error.
java.lang.ClassCastException: [I
	at sun.awt.image.ByteInterleavedRaster.getDataElements(ByteInterleavedRaster.java:347)
	at processing.core.PImage.<init>(PImage.java:182)
	at it.lilik.capturemjpeg.CaptureMJPEG.run(CaptureMJPEG.java:317)
Status: resolved Responsible: Alessio Caiazza Type: bug Priority: major
Milestone: none Component: CaptureMJPEG Version: 1.0

Attachments

No attachments added for this issue yet.

Comments and changes

  1. #1 Alessio Caiazza

    written

    With Processing 1.0.3 CaptureMJPEG works ONLY on OSX 10.5 !!!!!!

    Seems due to some changes in processing.core.PImage.<init>

  2. #2 Alessio Caiazza

    written

    PImage now manage BufferedImage in a different way, this causes exception to raise.

    Index: core/src/processing/core/PImage.java
    ===================================================================
    --- core/src/processing/core/PImage.java    (revisione 3705)
    +++ core/src/processing/core/PImage.java    (copia locale)
    
       /**
        * Construct a new PImage from a java.awt.Image. This constructor assumes
        * that you've done the work of making sure a MediaTracker has been used
        * to fully download the data and that the img is valid.
        */
       public PImage(java.awt.Image img) {
    -    width = img.getWidth(null);
    -    height = img.getHeight(null);
    +    if (img instanceof BufferedImage) {
    +      BufferedImage bi = (BufferedImage) img;
    +      width = bi.getWidth();
    +      height = bi.getHeight();
    +      pixels = new int[width * height];
    +      WritableRaster raster = bi.getRaster();
    +      raster.getDataElements(0, 0, width, height, pixels);
     
    -    pixels = new int[width*height];
    -    PixelGrabber pg =
    -      new PixelGrabber(img, 0, 0, width, height, pixels, 0, width);
    -    try {
    -      pg.grabPixels();
    -    } catch (InterruptedException e) { }
    +    } else {  // go the old school java 1.0 route
    +      width = img.getWidth(null);
    +      height = img.getHeight(null);
    +      pixels = new int[width * height];
    +      PixelGrabber pg =
    +        new PixelGrabber(img, 0, 0, width, height, pixels, 0, width);
    +      try {
    +        pg.grabPixels();
    +      } catch (InterruptedException e) { }
    +    }
     
         format = RGB;
    -    cache = null;
    +//    cache = null;
       }
    
  3. #3 Alessio Caiazza

    written

    • Changed status from new to resolved.

    CaptureMJPEG: wrapper around passing ByteArrayInputStream into processing.core.PImage.<init> Now really works on Processing > 1.0 ! fixes #4

    I'll hope in a better solution in future. Fixed copyright statements

    4675e4dab7c1

  4. #4 Alessio Caiazza

    written

    Issue #6 was marked as a duplicate of this issue.

Add comment / attachment

Verification: Please write the text from the image in the box (letters only)

captcha

Is that you, Humanoid? Is this me?