# HG changeset patch # User Alessio Caiazza # Date 1243891681 -7200 # Node ID 4675e4dab7c1ac1a5a5b430f64ab36f14003d792 # Parent 4ddd1bb9cdffa629fe56403df1ad7da65f720862 CaptureMJPEG: wrapper around passing ByteArrayInputStream into processing.core.PImage. Now really works on Processing > 1.0 ! fixes #4 I'll hope in a better solution in future. Fixed copyright statements diff -r 4ddd1bb9cdffa629fe56403df1ad7da65f720862 -r 4675e4dab7c1ac1a5a5b430f64ab36f14003d792 build.xml --- a/build.xml Sun May 03 17:26:26 2009 +0200 +++ b/build.xml Mon Jun 01 23:28:01 2009 +0200 @@ -1,6 +1,6 @@ - + @@ -172,7 +172,7 @@ CaptureMJPEG]]> - Copyright © 2008 Alessio Caiazza, Cosimo Cecchi All Rights Reserved.]]> + Copyright © 2008-09 Alessio Caiazza, Cosimo Cecchi All Rights Reserved.]]> diff -r 4ddd1bb9cdffa629fe56403df1ad7da65f720862 -r 4675e4dab7c1ac1a5a5b430f64ab36f14003d792 src/it/lilik/capturemjpeg/AxisURL.java --- a/src/it/lilik/capturemjpeg/AxisURL.java Sun May 03 17:26:26 2009 +0200 +++ b/src/it/lilik/capturemjpeg/AxisURL.java Mon Jun 01 23:28:01 2009 +0200 @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser Public License along with CaptureMJPEG. If not, see . - Copyright (c) 2008 - Alessio Caiazza, Cosimo Cecchi + Copyright (c) 2008-09 - Alessio Caiazza, Cosimo Cecchi */ package it.lilik.capturemjpeg; diff -r 4ddd1bb9cdffa629fe56403df1ad7da65f720862 -r 4675e4dab7c1ac1a5a5b430f64ab36f14003d792 src/it/lilik/capturemjpeg/CaptureMJPEG.java --- a/src/it/lilik/capturemjpeg/CaptureMJPEG.java Sun May 03 17:26:26 2009 +0200 +++ b/src/it/lilik/capturemjpeg/CaptureMJPEG.java Mon Jun 01 23:28:01 2009 +0200 @@ -14,11 +14,12 @@ You should have received a copy of the GNU Lesser Public License along with CaptureMJPEG. If not, see . - Copyright (c) 2008 - Alessio Caiazza, Cosimo Cecchi + Copyright (c) 2008-09 - Alessio Caiazza, Cosimo Cecchi */ package it.lilik.capturemjpeg; import java.awt.image.BufferedImage; +import java.awt.image.PixelGrabber; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -313,9 +314,7 @@ synchronized (lastImage) { if (captureEventMethod != null) { try { - PImage tmp = null; - tmp = new PImage((BufferedImage)ImageIO.read( - new ByteArrayInputStream(img))); + PImage tmp = getPImage(new ByteArrayInputStream(img)); captureEventMethod.invoke(parent, new Object[] { this.assign(tmp) }); } catch (Exception e) { @@ -345,6 +344,34 @@ } + /* + * Bypass Default PImage costructur forcing + * a load like in Processing < 1.0 + * + */ + private PImage getPImage(ByteArrayInputStream bais) throws IOException { + PImage tmp = null; + BufferedImage bi = (BufferedImage)ImageIO.read(bais); + + int width = bi.getWidth(null); + int height = bi.getHeight(null); + int[] pixels = new int[width * height]; + PixelGrabber pg = + new PixelGrabber(bi, 0, 0, width, height, pixels, 0, width); + try { + pg.grabPixels(); + } catch (InterruptedException e) { } + + tmp = new PImage(width,height); + tmp.loadPixels(); + for (int i = 0; i < width * height; i++) { + tmp.pixels[i] = pixels[i]; + } + tmp.updatePixels(); + + return tmp; + } + private void setErrorImage(ErrorImage error) { if (captureEventMethod != null) { try { @@ -381,7 +408,7 @@ if (!isImageAvailable()) return lastImage; try { - PImage tmp = new PImage(ImageIO.read(buffer.pop())); + PImage tmp = getPImage(buffer.pop()); return assign(tmp); } catch (IOException e1) { e1.printStackTrace(); diff -r 4ddd1bb9cdffa629fe56403df1ad7da65f720862 -r 4675e4dab7c1ac1a5a5b430f64ab36f14003d792 src/it/lilik/capturemjpeg/CircularBuffer.java --- a/src/it/lilik/capturemjpeg/CircularBuffer.java Sun May 03 17:26:26 2009 +0200 +++ b/src/it/lilik/capturemjpeg/CircularBuffer.java Mon Jun 01 23:28:01 2009 +0200 @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser Public License along with CaptureMJPEG. If not, see . - Copyright (c) 2008 - Alessio Caiazza, Cosimo Cecchi + Copyright (c) 2008-09 - Alessio Caiazza, Cosimo Cecchi */ package it.lilik.capturemjpeg; diff -r 4ddd1bb9cdffa629fe56403df1ad7da65f720862 -r 4675e4dab7c1ac1a5a5b430f64ab36f14003d792 src/it/lilik/capturemjpeg/ErrorImage.java --- a/src/it/lilik/capturemjpeg/ErrorImage.java Sun May 03 17:26:26 2009 +0200 +++ b/src/it/lilik/capturemjpeg/ErrorImage.java Mon Jun 01 23:28:01 2009 +0200 @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser Public License along with CaptureMJPEG. If not, see . - Copyright (c) 2008 - Alessio Caiazza, Cosimo Cecchi + Copyright (c) 2008-09 - Alessio Caiazza, Cosimo Cecchi */ package it.lilik.capturemjpeg; diff -r 4ddd1bb9cdffa629fe56403df1ad7da65f720862 -r 4675e4dab7c1ac1a5a5b430f64ab36f14003d792 src/it/lilik/capturemjpeg/MJPEGInputStream.java --- a/src/it/lilik/capturemjpeg/MJPEGInputStream.java Sun May 03 17:26:26 2009 +0200 +++ b/src/it/lilik/capturemjpeg/MJPEGInputStream.java Mon Jun 01 23:28:01 2009 +0200 @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser Public License along with CaptureMJPEG. If not, see . - Copyright (c) 2008 - Alessio Caiazza, Cosimo Cecchi + Copyright (c) 2008-09 - Alessio Caiazza, Cosimo Cecchi */ package it.lilik.capturemjpeg; diff -r 4ddd1bb9cdffa629fe56403df1ad7da65f720862 -r 4675e4dab7c1ac1a5a5b430f64ab36f14003d792 src/it/lilik/capturemjpeg/SonyURL.java --- a/src/it/lilik/capturemjpeg/SonyURL.java Sun May 03 17:26:26 2009 +0200 +++ b/src/it/lilik/capturemjpeg/SonyURL.java Mon Jun 01 23:28:01 2009 +0200 @@ -14,7 +14,7 @@ You should have received a copy of the GNU Lesser Public License along with CaptureMJPEG. If not, see . - Copyright (c) 2008 - Alessio Caiazza, Cosimo Cecchi + Copyright (c) 2008-09 - Alessio Caiazza, Cosimo Cecchi */ package it.lilik.capturemjpeg;