It all works

This commit is contained in:
Erlend Hamnaberg
2009-11-08 19:52:30 +01:00
parent b8faa6e36f
commit 0786949c1c
319 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* BMPImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: BMPImageReader.java,v 1.0 Dec 2, 2007 9:03:37 PM haraldk Exp$
*/
public final class BMPImageReader extends JMagickReader {
public BMPImageReader(final BMPImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* BMPImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: BMPImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class BMPImageReaderSpi extends JMagickImageReaderSpiSupport {
public BMPImageReaderSpi() {
super(
new String[]{"bmp", "BMP"},
new String[]{"bmp", "rle", "dib"},
new String[]{"image/bmp", "image/x-bmp", "image/x-windows-bmp", "image/x-ms-bmp"}, // http://en.wikipedia.org/wiki/Windows_Bitmap
BMPImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.BMPImageWriterSpi"}
);
}
@Override
public BMPImageReader createReaderImpl(Object pExtension) throws IOException {
return new BMPImageReader(this);
}
@Override
public boolean canDecode(ImageInputStream pSource) throws IOException {
//new byte[][] {new byte[] {'B', 'M'}, new byte[] {'M', 'B'}, }, // BMP
//new byte[][] {new byte[] {0x00, 0x00, 0x02, 0x00,
// 0x01, 0x00, 0x20, 0x20}}, // CUR
//new byte[][] {new byte[] {0x0, 0x0, 0x1, 0x0}}, // ICO (best guess)
byte[] magic = new byte[2];
pSource.readFully(magic);
return (magic[0] == 'B' && magic[1] == 'M') || (magic[0] == 'M' && magic[1] == 'B');
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* BMPImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: BMPImageWriter.java,v 1.0 Dec 3, 2007 12:04:10 PM haraldk Exp$
*/
public final class BMPImageWriter extends JMagickWriter {
protected BMPImageWriter(final BMPImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale()) {
@Override
public boolean canWriteCompressed() {
return true;
}
@Override
public boolean isCompressionLossless() {
return true;
}
};
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* BMPImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: BMPImageWriterSpi.java,v 1.0 30.jul.2004 18:32:40 haku Exp $
*/
public class BMPImageWriterSpi extends JMagickImageWriterSpiSupport {
public BMPImageWriterSpi() {
super(
new String[]{"bmp", "BMP"},
new String[]{"bmp"},
new String[]{"image/bmp", "image/x-bmp", "image/x-windows-bmp", "image/x-ms-bmp"}, // http://en.wikipedia.org/wiki/Windows_Bitmap
BMPImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmageick.BMPImageReaderSpi"}
);
}
@Override
public BMPImageWriter createWriterImpl(Object pExtension) throws IOException {
return new BMPImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* GIFImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: GIFImageReader.java,v 1.0 Dec 3, 2007 12:53:44 PM haraldk Exp$
*/
public class GIFImageReader extends JMagickReader {
protected GIFImageReader(final GIFImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* GIFImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: GIFImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class GIFImageReaderSpi extends JMagickImageReaderSpiSupport {
public GIFImageReaderSpi() {
super(
new String[]{"gif", "GIF"},
new String[]{"gif"},
new String[]{"image/gif", "image/x-gif"},
GIFImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.GIFImageWriterSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {'G', 'I', 'F', '8', '7'}, // GIF
// new byte[] {'G', 'I', 'F', '8', '9'}},
byte[] magic = new byte[6];
pSource.readFully(magic);
return magic[0] == 'G' && magic[1] == 'I' && magic[2] == 'F' &&
magic[3] == '8' && (magic[4] == '7' || magic[4] == '9');
}
protected GIFImageReader createReaderImpl(final Object pExtension) throws IOException {
return new GIFImageReader(this);
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* GIFImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: GIFImageWriter.java,v 1.0 Dec 3, 2007 1:55:34 PM haraldk Exp$
*/
public class GIFImageWriter extends JMagickWriter {
protected GIFImageWriter(final GIFImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale()) {
@Override
public boolean canWriteCompressed() {
return true;
}
@Override
public boolean canWriteProgressive() {
return true;
}
@Override
public boolean isCompressionLossless() {
return true;
}
};
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* GIFImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: GIFImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class GIFImageWriterSpi extends JMagickImageWriterSpiSupport {
public GIFImageWriterSpi() {
super(
new String[]{"gif", "GIF"},
new String[]{"gif"},
new String[]{"image/gif", "image/x-gif"},
GIFImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.GIFImageReaderSpi"}
);
}
protected GIFImageWriter createWriterImpl(final Object pExtension) throws IOException {
return new GIFImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* ICOImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: ICOImageReader.java,v 1.0 Dec 3, 2007 2:01:52 PM haraldk Exp$
*/
public class ICOImageReader extends JMagickReader {
public ICOImageReader(final ICOImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* ICOImageReaderSpi class description.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: ICOImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class ICOImageReaderSpi extends JMagickImageReaderSpiSupport {
// TODO: Handle CUR
public ICOImageReaderSpi() {
super(
new String[]{"ico", "ICO"},
new String[]{"ico"},
new String[]{"image/x-icon", "image/ico"},
ICOImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.ICOImageWriterSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {0x0, 0x0, 0x1, 0x0}}, // ICO (best guess)
// new byte[][] {new byte[] {0x00, 0x00, 0x02, 0x00,
// 0x01, 0x00, 0x20, 0x20}}, // CUR
byte[] magic = new byte[4];
pSource.readFully(magic);
return magic[0] == 0x0 && magic[1] == 0x0 && magic[2] == 0x1 && magic[3] == 0x0;
}
protected ICOImageReader createReaderImpl(final Object pExtension) throws IOException {
return new ICOImageReader(this);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* ICOImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: ICOImageWriter.java,v 1.0 Dec 3, 2007 2:21:07 PM haraldk Exp$
*/
public class ICOImageWriter extends JMagickWriter {
public ICOImageWriter(final ICOImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale());
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* ICOImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: ICOImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class ICOImageWriterSpi extends JMagickImageWriterSpiSupport {
public ICOImageWriterSpi() {
super(
new String[]{"ico", "ICO"},
new String[]{"ico"},
new String[]{"image/x-icon", "image/ico"},
ICOImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.ICOImageReaderSpi"}
);
}
protected ICOImageWriter createWriterImpl(final Object pExtension) throws IOException {
return new ICOImageWriter(this);
}
}

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import com.twelvemonkeys.lang.SystemUtil;
import magick.MagickImage;
import java.io.IOException;
import java.util.Properties;
/**
* JMagick helper class, to iron out a few wrinkles.
* <p/>
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @version $Id: JMagick.java,v 1.0 16.jan.2006 14:20:30 haku Exp$
*/
class JMagick {
static Properties sProperties;
static {
// NOTE: Workaround for strange defaults in JMagick:
// Makes JMagick load dll's using the context classloader, rather than
// the system classloader as default...
if (System.getProperty("jmagick.systemclassloader") == null) {
System.setProperty("jmagick.systemclassloader", "no");
}
// Makes this class fail on init, if JMagick is unavailable
try {
MagickImage.class.getClass();
new MagickImage(); // Loads the JNI lib, if needed
}
catch (Error e) {
System.err.print("JMagick not available: ");
System.err.println(e);
System.err.println("Make sure JMagick libraries are available in java.library.path. Current value: ");
System.err.println("\"" + System.getProperty("java.library.path") + "\"");
throw e;
}
// Load custom properties for the JMagickReader
try {
sProperties = SystemUtil.loadProperties(JMagickReader.class);
}
catch (IOException e) {
System.err.println("Could not read properties for JMagickReader: " + e.getMessage());
e.printStackTrace();
}
}
static void init() {
// No-op.
}
}

View File

@@ -0,0 +1,148 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import com.twelvemonkeys.lang.SystemUtil;
import javax.imageio.ImageReader;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.spi.ServiceRegistry;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
import java.util.Locale;
/**
* JMagickImageReaderSpiSupport
* <p/>
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @version $Id: JimiImageReaderSpiSupport.java,v 1.1 2003/12/02 16:45:00 wmhakur Exp $
*/
abstract class JMagickImageReaderSpiSupport extends ImageReaderSpi {
final static boolean AVAILABLE = SystemUtil.isClassAvailable("com.twelvemonkeys.imageio.plugins.jmagick.JMagick");
/**
* Creates a JMagickImageReaderSpiSupport
*
* @param pFormatNames format names
* @param pSuffixes format suffixes
* @param pMimeTypes format MIME types
* @param pReaderClassName format reader class name
* @param pWriterSpiNames format writer service provider namses
*/
protected JMagickImageReaderSpiSupport(final String[] pFormatNames,
final String[] pSuffixes,
final String[] pMimeTypes,
final String pReaderClassName,
final String[] pWriterSpiNames) {
super(
"TwelveMonkeys", // Vendor name
"2.0", // Version
AVAILABLE ? pFormatNames : new String[]{""}, // Names
AVAILABLE ? pSuffixes : null, // Suffixes
AVAILABLE ? pMimeTypes : null, // Mime-types
pReaderClassName, // Reader class name
ImageReaderSpi.STANDARD_INPUT_TYPE, // Output types
pWriterSpiNames, // Writer SPI names
true, // Supports standard stream metadata format
null, // Native stream metadata format name
null, // Native stream metadata format class name
null, // Extra stream metadata format names
null, // Extra stream metadata format class names
true, // Supports standard image metadata format
null, // Native image metadata format name
null, // Native image metadata format class name
null, // Extra image metadata format names
null// Extra image metadata format class names
);
}
public boolean canDecodeInput(Object pSource) throws IOException {
return pSource instanceof ImageInputStream && AVAILABLE && canDecode0((ImageInputStream) pSource);
}
private boolean canDecode0(ImageInputStream pSource) throws IOException {
pSource.mark();
try {
return canDecode(pSource);
}
finally {
pSource.reset();
}
}
/**
* Specifies if this provider's reader may decode the provided input.
* Stream mark/reset is handled, and need not be taken care of.
*
* @param pSource the source image input stream
* @return {@code true} if the inout can be decoded
* @throws IOException if an I/O exception occurs during the process
*/
abstract boolean canDecode(ImageInputStream pSource) throws IOException;
public final ImageReader createReaderInstance(Object pExtension) throws IOException {
try {
return createReaderImpl(pExtension);
}
catch (Throwable t) {
// Wrap in IOException if the reader can't be instantiated.
// This makes the IIORegistry deregister this service provider
IOException exception = new IOException(t.getMessage());
exception.initCause(t);
throw exception;
}
}
protected abstract JMagickReader createReaderImpl(Object pExtension) throws IOException;
public String getDescription(Locale pLocale) {
return "JMagick " + getFormatNames()[0].toUpperCase() + " image reader";
}
@Override
@SuppressWarnings({"unchecked"})
public void onRegistration(ServiceRegistry pRegistry, Class pCategory) {
if (!AVAILABLE) {
pRegistry.deregisterServiceProvider(this, pCategory);
}
}
/**
* Specifies if the reader created by this provider should use temporary
* file, instead of passing the data in-memory to the native reader.
*
* @return {@code true} if the reader should use a temporary file
*/
public boolean useTempFile() {
return "TRUE".equalsIgnoreCase(JMagick.sProperties.getProperty(getFormatNames()[0] + ".useTempFile"));
}
}

View File

@@ -0,0 +1,122 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriter;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.spi.ImageWriterSpi;
import javax.imageio.spi.ServiceRegistry;
import java.io.IOException;
import java.util.Locale;
/**
* JMagickImageWriterSpiSupport
* <p/>
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @version $Id: JMagickImageWriterSpiSupport.java,v 1.0 17.jan.2006 00:04:32 haku Exp$
*/
abstract class JMagickImageWriterSpiSupport extends ImageWriterSpi {
private final static boolean AVAILABLE = JMagickImageReaderSpiSupport.AVAILABLE;
/**
* Creates a JMagickImageReaderSpiSupport
*
* @param pFormatNames format names
* @param pSuffixes format suffixes
* @param pMimeTypes format MIME types
* @param pWriterClassName format writer class name
* @param pReaderSpiNames format reader service provider namses
*/
protected JMagickImageWriterSpiSupport(final String[] pFormatNames,
final String[] pSuffixes,
final String[] pMimeTypes,
final String pWriterClassName,
final String[] pReaderSpiNames) {
super(
"TwelveMonkeys", // Vendor name
"2.0", // Version
AVAILABLE ? pFormatNames : new String[]{""}, // Names
AVAILABLE ? pSuffixes : null, // Suffixes
AVAILABLE ? pMimeTypes : null, // Mime-types
pWriterClassName, // Writer class name
ImageReaderSpi.STANDARD_INPUT_TYPE, // Output types
pReaderSpiNames, // Reader SPI names
true, // Supports standard stream metadata format
null, // Native stream metadata format name
null, // Native stream metadata format class name
null, // Extra stream metadata format names
null, // Extra stream metadata format class names
true, // Supports standard image metadata format
null, // Native image metadata format name
null, // Native image metadata format class name
null, // Extra image metadata format names
null// Extra image metadata format class names
);
}
/**
* This implementations simply returns {@code true}.
*
* @param pType ignored
* @return {@code true} unless overriden
*/
public boolean canEncodeImage(ImageTypeSpecifier pType) {
return true;
}
public final ImageWriter createWriterInstance(Object pExtension) throws IOException {
try {
return createWriterImpl(pExtension);
}
catch (Throwable t) {
// Wrap in IOException if the writer can't be instantiated.
// This makes the IIORegistry deregister this service provider
IOException exception = new IOException(t.getMessage());
exception.initCause(t);
throw exception;
}
}
protected abstract JMagickWriter createWriterImpl(final Object pExtension) throws IOException;
public String getDescription(Locale pLocale) {
return "JMagick " + getFormatNames()[0].toUpperCase() + " image writer";
}
@Override
@SuppressWarnings({"unchecked"})
public void onRegistration(ServiceRegistry pRegistry, Class pCategory) {
if (!AVAILABLE) {
pRegistry.deregisterServiceProvider(this, pCategory);
}
}
}

View File

@@ -0,0 +1,335 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import com.twelvemonkeys.image.ImageUtil;
import com.twelvemonkeys.image.MagickUtil;
import com.twelvemonkeys.image.MonochromeColorModel;
import com.twelvemonkeys.imageio.ImageReaderBase;
import com.twelvemonkeys.imageio.util.IndexedImageTypeSpecifier;
import com.twelvemonkeys.io.FileUtil;
import magick.ImageInfo;
import magick.ImageType;
import magick.MagickException;
import magick.MagickImage;
import javax.imageio.IIOException;
import javax.imageio.ImageReadParam;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.spi.ImageReaderSpi;
import java.awt.*;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.ComponentColorModel;
import java.awt.image.DataBuffer;
import java.io.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* JMagickReader, uses JMagick, an open source Java interface of ImageMagick to
* read images. This {@code ImageReader} has certain limitations (see below),
* but the number of formats supported should by far outweigh these
* limitatations.
* <p/>
* Limitations: JMagick is <em>not</em> stream-based, meaning image (file) data
* must be read into a temporary byte array, potentially causing performance
* penalties.
* ImageMagick itself might even use the file extension to determine file
* format, in such cases a temporary file must be written to disk before
* the image data can be read. While this is perfomed transparently to the user
* there are still performance penalties related to the extra disk I/O.
* <p/>
* <small>
* Note: This class relies on JMagick, which ues JNI and native code. You need
* to have the JMagick and ImageMagick shared libraries (or DLLs) in Java's
* {@code java.library.path} for this class to work.
* </small>
*
* @see <a href="http://www.imagemagick.org/">ImageMagick homepage</a>
* @see <a href="http://www.yeo.id.au/jmagick/">JMagick homepage</a>
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @version $Id: JMagickReader.java,v 1.0 24.jan.2005 10:33:05 haku Exp$
*
* @todo System property to allow all images be read using temp file (reducing
* memory consumption): "com.twelvemonkeys.imageio.plugins.jmagick.useTempFile"
*/
abstract class JMagickReader extends ImageReaderBase {
// Make sure the JMagick init is run, or class init will fail
static {
JMagick.init();
}
private static final ColorModel CM_GRAY_ALPHA =
new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), true, true, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
private final boolean mUseTempFile;
private File mTempFile;
private MagickImage mImage;
private Dimension mSize;
protected JMagickReader(final JMagickImageReaderSpiSupport pProvider) {
this(pProvider, pProvider.useTempFile());
}
protected JMagickReader(final ImageReaderSpi pProvider, final boolean pUseTemp) {
super(pProvider);
mUseTempFile = pUseTemp;
}
@Override
protected void resetMembers() {
if (mTempFile != null) {
mTempFile.delete();
}
mTempFile = null;
if (mImage != null) {
mImage.destroyImages();
}
mImage = null;
mSize = null;
}
// TODO: Handle multi-image formats
// if (mImage.hasFrames()) {
// int count = mImage.getNumFrames();
// MagickImage[] images = mImage.breakFrames();
// }
public Iterator<ImageTypeSpecifier> getImageTypes(int pIndex) throws IOException {
checkBounds(pIndex);
init(pIndex);
// TODO: FIX ME!
// - Use factory methods for ImageTypeSpecifier, create factory methods if necessary
List<ImageTypeSpecifier> specs = new ArrayList<ImageTypeSpecifier>();
try {
ColorModel cm;
// NOTE: These are all fall-through by intention
switch (mImage.getImageType()) {
case ImageType.BilevelType:
specs.add(IndexedImageTypeSpecifier.createFromIndexColorModel(MonochromeColorModel.getInstance()));
case ImageType.GrayscaleType:
// cm = MagickUtil.CM_GRAY_OPAQUE;
// specs.add(new ImageTypeSpecifier(
// cm,
// cm.createCompatibleSampleModel(1, 1)
// ));
specs.add(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_BYTE_GRAY));
case ImageType.GrayscaleMatteType:
cm = CM_GRAY_ALPHA;
specs.add(new ImageTypeSpecifier(
cm,
cm.createCompatibleSampleModel(1, 1)
));
case ImageType.PaletteType:
specs.add(IndexedImageTypeSpecifier.createFromIndexColorModel(
MagickUtil.createIndexColorModel(mImage.getColormap(), false)
));
case ImageType.PaletteMatteType:
specs.add(IndexedImageTypeSpecifier.createFromIndexColorModel(
MagickUtil.createIndexColorModel(mImage.getColormap(), true)
));
case ImageType.TrueColorType:
// cm = MagickUtil.CM_COLOR_OPAQUE;
// specs.add(new ImageTypeSpecifier(
// cm,
// cm.createCompatibleSampleModel(1, 1)
// ));
specs.add(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_3BYTE_BGR));
case ImageType.TrueColorMatteType:
// cm = MagickUtil.CM_COLOR_ALPHA;
// specs.add(new ImageTypeSpecifier(
// cm,
// cm.createCompatibleSampleModel(1, 1)
// ));
specs.add(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_4BYTE_ABGR_PRE));
break;
case ImageType.ColorSeparationType:
case ImageType.ColorSeparationMatteType:
case ImageType.OptimizeType:
default:
throw new MagickException("Unknown JMagick image type: " + mImage.getImageType());
}
}
catch (MagickException e) {
throw new IIOException(e.getMessage(), e);
}
return specs.iterator();
}
public int getWidth(int pIndex) throws IOException {
checkBounds(pIndex);
if (mSize == null) {
init(0);
}
return mSize != null ? mSize.width : -1;
}
public int getHeight(int pIndex) throws IOException {
checkBounds(pIndex);
if (mSize == null) {
init(0);
}
return mSize != null ? mSize.height : -1;
}
public BufferedImage read(int pIndex, ImageReadParam pParam) throws IOException {
try {
init(pIndex);
processImageStarted(pIndex);
// Some more waste of time and space...
Dimension size = mSize;
if (pParam != null) {
// Source region
// TODO: Maybe have to do some tests, to check if we are within bounds...
Rectangle sourceRegion = pParam.getSourceRegion();
if (sourceRegion != null) {
mImage = mImage.cropImage(sourceRegion);
size = sourceRegion.getSize();
}
// Subsampling
if (pParam.getSourceXSubsampling() > 1 || pParam.getSourceYSubsampling() > 1) {
int w = size.width / pParam.getSourceXSubsampling();
int h = size.height / pParam.getSourceYSubsampling();
mImage = mImage.sampleImage(w, h);
size = new Dimension(w, h);
}
}
if (abortRequested()) {
processReadAborted();
return ImageUtil.createClear(size.width, size.height, null);
}
processImageProgress(10f);
BufferedImage buffered = MagickUtil.toBuffered(mImage);
processImageProgress(100f);
/**/
//System.out.println("Created image: " + buffered);
//System.out.println("ColorModel: " + buffered.getColorModel().getClass().getName());
//if (buffered.getColorModel() instanceof java.awt.image.IndexColorModel) {
// java.awt.image.IndexColorModel cm = (java.awt.image.IndexColorModel) buffered.getColorModel();
// for (int i = 0; i < cm.getMapSize(); i++) {
// System.out.println("0x" + Integer.toHexString(cm.getRGB(i)));
// }
//}
//*/
/**
System.out.println("Colorspace: " + mImage.getColorspace());
System.out.println("Depth: " + mImage.getDepth());
System.out.println("Format: " + mImage.getImageFormat());
System.out.println("Type: " + mImage.getImageType());
System.out.println("IPTCProfile: " + StringUtil.deepToString(mImage.getIptcProfile()));
System.out.println("StorageClass: " + mImage.getStorageClass());
//*/
processImageComplete();
return buffered;
}
catch (MagickException e) {
// Wrap in IIOException
throw new IIOException(e.getMessage(), e);
}
}
private synchronized void init(int pIndex) throws IOException {
checkBounds(pIndex);
try {
if (mImage == null) {
// TODO: If ImageInputStream is already file-backed, maybe we can peek into that file?
// At the moment, the cache/file is not accessible, but we could create our own
// FileImageInputStream provider that gives us this access.
if (!mUseTempFile && mImageInput.length() >= 0 && mImageInput.length() <= Integer.MAX_VALUE) {
// This works for most file formats, as long as ImageMagick
// uses the file magic to decide file format
byte[] bytes = new byte[(int) mImageInput.length()];
mImageInput.readFully(bytes);
// Unfortunately, this is a waste of space & time...
ImageInfo info = new ImageInfo();
mImage = new MagickImage(info);
mImage.blobToImage(info, bytes);
}
else {
// Quirks mode: Use temp file to get correct file extension
// (which is even more waste of space & time, but might save memory)
String ext = getFormatName().toLowerCase();
mTempFile = File.createTempFile("jmagickreader", "." + ext);
mTempFile.deleteOnExit();
OutputStream out = new BufferedOutputStream(new FileOutputStream(mTempFile));
try {
byte[] buffer = new byte[FileUtil.BUF_SIZE];
int count;
while ((count = mImageInput.read(buffer)) != -1) {
out.write(buffer, 0, count);
}
// Flush out stream, to write any remaining buffered data
out.flush();
}
finally {
out.close();
}
ImageInfo info = new ImageInfo(mTempFile.getAbsolutePath());
mImage = new MagickImage(info);
}
mSize = mImage.getDimension();
}
}
catch (MagickException e) {
// Wrap in IIOException
throw new IIOException(e.getMessage(), e);
}
}
}

View File

@@ -0,0 +1,143 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import com.twelvemonkeys.image.ImageUtil;
import com.twelvemonkeys.image.MagickUtil;
import com.twelvemonkeys.imageio.ImageWriterBase;
import magick.ImageInfo;
import magick.MagickException;
import magick.MagickImage;
import javax.imageio.IIOException;
import javax.imageio.IIOImage;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriteParam;
import javax.imageio.metadata.IIOMetadata;
import java.awt.image.BufferedImage;
import java.io.IOException;
/**
* JMagickWriter
* <p/>
* <em>NOTE: This ImageWriter is probably a waste of time and space, as
* all images are converted from the given Rendered/BufferedImage,
* first to 16bit raw ARGB samples, and then to the requested output format.
* This is due to a limitation in the current JMagick API.</em>
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @version $Id: JMagickWriter.java,v 1.0 16.jan.2006 13:34:46 haku Exp$
*/
abstract class JMagickWriter extends ImageWriterBase {
static {
// Make sure the JMagick init is run...
JMagick.init();
}
protected JMagickWriter(final JMagickImageWriterSpiSupport pProvider) {
super(pProvider);
}
public IIOMetadata convertImageMetadata(IIOMetadata inData, ImageTypeSpecifier imageType, ImageWriteParam param) {
throw new UnsupportedOperationException("Method convertImageMetadata not implemented");// TODO: Implement
}
public IIOMetadata getDefaultImageMetadata(ImageTypeSpecifier imageType, ImageWriteParam param) {
throw new UnsupportedOperationException("Method getDefaultImageMetadata not implemented");// TODO: Implement
}
public void write(IIOMetadata pStreamMetadata, IIOImage pImage, ImageWriteParam pParam) throws IOException {
assertOutput();
if (pImage.hasRaster()) {
throw new UnsupportedOperationException("Cannot write raster");
}
processImageStarted(0);
MagickImage image = null;
try {
// AOI & subsampling
BufferedImage buffered = fakeAOI(ImageUtil.toBuffered(pImage.getRenderedImage()), pParam);
buffered = ImageUtil.toBuffered(fakeSubsampling(buffered, pParam));
// Convert to MagickImage
image = MagickUtil.toMagick(buffered);
processImageProgress(33f);
// Get bytes blob from MagickImage
String format = getFormatName().toLowerCase();
image.setImageFormat(format);
ImageInfo info = new ImageInfo();
if (pParam != null && pParam.getCompressionMode() == ImageWriteParam.MODE_EXPLICIT) {
int quality = (int) (pParam.getCompressionQuality() * 100);
//System.out.println("pParam.getCompressionQuality() = " + pParam.getCompressionQuality());
//System.out.println("quality = " + quality);
//info.setCompression(CompressionType.JPEGCompression);
//image.setCompression(CompressionType.JPEGCompression);
// TODO: Is quality really correct in all cases?
// TODO: This does not seem to do the trick..
info.setQuality(quality);
}
byte[] bytes = image.imageToBlob(info);
if (bytes == null) {
throw new IIOException("Could not write image data in " + format + " format.");
}
processImageProgress(67);
// Write blob to output
mImageOutput.write(bytes);
mImageOutput.flush();
processImageProgress(100);
}
catch (MagickException e) {
throw new IIOException(e.getMessage(), e);
}
finally {
if (image != null) {
image.destroyImages();// Dispose native memory
}
}
processImageComplete();
}
public ImageWriteParam getDefaultWriteParam() {
return createDefaultWriteParam();
}
protected abstract ImageWriteParam createDefaultWriteParam();
@Override
public void dispose() {
// Clean up!
super.dispose();
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* JPEG2KImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: JPEG2KImageReader.java,v 1.0 Dec 3, 2007 2:56:30 PM haraldk Exp$
*/
public class JPEG2KImageReader extends JMagickReader {
public JPEG2KImageReader(final JPEG2KImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* JPEG2KImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: JPEG2KImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class JPEG2KImageReaderSpi extends JMagickImageReaderSpiSupport {
public JPEG2KImageReaderSpi() {
super(
new String[]{"jpeg2000", "jpeg 2000"},
new String[]{"jp2"},
new String[]{"image/jp2", "image/jpeg2000"},
JPEG2KImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.JPEG2KImageWriterSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {0x00, 0x00, 0x00, 0x0C, 'j', 'P', ' ', ' ', 0x0D, 0x0A, (byte) 0x87, 0x0A}, // JPEG 2000 JP2 format
// new byte[] {(byte) 0xff, 0x4f}}, // JPEG 2000 codestream format
byte[] magic = new byte[12];
pSource.readFully(magic);
return (magic[0] == 0x00 && magic[1] == 0x00 && magic[2] == 0x00 &&
magic[3] == 0x0C && magic[4] == 'j' && magic[5] == 'P' &&
magic[6] == ' ' && magic[7] == ' ' && magic[8] == 0x0D &&
magic[9] == 0x0A && magic[10] == (byte) 0x87 && magic[11] == 0x0A) ||
(magic[0] == (byte) 0xFF && magic[1] == 0x4F);
}
protected JPEG2KImageReader createReaderImpl(final Object pExtension) throws IOException {
return new JPEG2KImageReader(this);
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* JPEG2KImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: JPEG2KImageWriter.java,v 1.0 Dec 3, 2007 6:22:46 PM haraldk Exp$
*/
public class JPEG2KImageWriter extends JMagickWriter {
public JPEG2KImageWriter(final JPEG2KImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale()) {
@Override
public boolean canWriteCompressed() {
return true;
}
@Override
public boolean canWriteProgressive() {
return true;
}
@Override
public boolean isCompressionLossless() {
// TODO: This depends on the algorithm, JPEG 2000 supports lossless...
return false;
}
};
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* JPEG2KImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: JPEG2KImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class JPEG2KImageWriterSpi extends JMagickImageWriterSpiSupport {
public JPEG2KImageWriterSpi() {
super(
new String[]{"jpeg2000", "jpeg 2000"},
new String[]{"jp2"},
new String[]{"image/jp2", "image/jpeg2000"},
JPEG2KImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.JPEG2KImageReaderSpi"}
);
}
protected JMagickWriter createWriterImpl(final Object pExtension) throws IOException {
return new JPEG2KImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* JPEGImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: JPEGImageReader.java,v 1.0 Dec 3, 2007 6:28:10 PM haraldk Exp$
*/
public class JPEGImageReader extends JMagickReader {
public JPEGImageReader(final JPEGImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* JPEGImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: JPEGImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class JPEGImageReaderSpi extends JMagickImageReaderSpiSupport {
public JPEGImageReaderSpi() {
super(
new String[]{"jpeg", "JPEG", "exif", "EXIF", "jfif", "JFIF", "jpg", "JPG"},
new String[]{"jpg", "jpeg", "jpe"},
new String[]{"image/jpeg", "image/jfif", "image/x-exif"},
JPEGImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.JPEGImageWriterSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {(byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xe0},
// new byte[] {(byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xe1}}, // JPEG
// new byte[][] {new byte[] {(byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xee}}, // JPG
byte[] magic = new byte[4];
pSource.readFully(magic);
return magic[0] == (byte) 0xFF && magic[1] == (byte) 0xD8 && magic[2] == (byte) 0xFF &&
(magic[3] == (byte) 0xE0 || magic[0] == (byte) 0xE1 || magic[0] == (byte) 0xEE);
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new JPEGImageReader(this);
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* JPEGImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: JPEGImageWriter.java,v 1.0 Dec 3, 2007 6:40:10 PM haraldk Exp$
*/
public class JPEGImageWriter extends JMagickWriter {
public JPEGImageWriter(final JPEGImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale()) {
@Override
public boolean canWriteCompressed() {
return true;
}
@Override
public boolean canWriteProgressive() {
return true;
}
@Override
public boolean isCompressionLossless() {
return false;
}
};
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* BMPImageReaderSpi class description.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: BMPImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class JPEGImageWriterSpi extends JMagickImageWriterSpiSupport {
public JPEGImageWriterSpi() {
super(
new String[]{"jpeg", "JPEG", "exif", "EXIF", "jfif", "JFIF", "jpg", "JPG"},
new String[]{"jpg", "jpeg"},
new String[]{"image/jpeg", "image/jfif", "image/x-exif"},
JPEGImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.JPEGImageReaderSpi"});
}
protected JMagickWriter createWriterImpl(final Object pExtension) throws IOException {
return new JPEGImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* PCDImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PCDImageReader.java,v 1.0 Dec 3, 2007 6:53:05 PM haraldk Exp$
*/
public class PCDImageReader extends JMagickReader {
public PCDImageReader(final PCDImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* PCDImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @version $Id: PCDImageReaderSpi.java,v 1.1 2003/12/02 16:45:00 wmhakur Exp $
*/
public class PCDImageReaderSpi extends JMagickImageReaderSpiSupport {
public PCDImageReaderSpi() {
super(
new String[]{"pcd", "PCD"},
new String[]{"pcd", "PCD"},
new String[]{"image/pcd", "image/x-pcd"},
PCDImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.PCXImageWriterSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
//final static byte[] PCD_MAGIC = new byte[] {0x50, 0x43, 0x44, 0x5f, 0x49, 0x50, 0x49};
if (pSource.length() > 2055) {
pSource.seek(2048);
byte[] magic = new byte[7];
pSource.readFully(magic);
// Kodak PhotoCD PCD_IPI
return magic[0] == 'P' && magic[1] == 'C' && magic[2] == 'D'
&& magic[3] == '_' && magic[4] == 'I' && magic[5] == 'P'
&& magic[6] == 'I';
}
return false;
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new PCDImageReader(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* PCXImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PCXImageReader.java,v 1.0 Dec 3, 2007 7:06:06 PM haraldk Exp$
*/
public class PCXImageReader extends JMagickReader {
public PCXImageReader(final PCXImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* PCXImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: PCXImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class PCXImageReaderSpi extends JMagickImageReaderSpiSupport {
public PCXImageReaderSpi() {
super(
new String[]{"pcx", "PCX"},
new String[]{"pcx"},
new String[]{"image/pcx", "image/x-pcx"},
PCXImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.PCXImageReaderSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {0x0a, -1, 0x01}}, // PCX
byte[] magic = new byte[4];
pSource.readFully(magic);
return magic[0] == 0x0A &&
(magic[1] == 0x02 || magic[1] == 0x03 || magic[1] == 0x05) &&
magic[2] == 0x01 && magic[3] == 0x01;
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new PCXImageReader(this);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* PCXImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PCXImageWriter.java,v 1.0 Dec 3, 2007 7:12:58 PM haraldk Exp$
*/
public class PCXImageWriter extends JMagickWriter {
public PCXImageWriter(final PCXImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale());
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* PCXImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: PCXImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class PCXImageWriterSpi extends JMagickImageWriterSpiSupport {
public PCXImageWriterSpi() {
super(
new String[]{"pcx", "PCX"},
new String[]{"pcx"},
new String[]{"image/pcx", "image/x-pcx"},
PCXImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.PCXImageReaderSpi"}
);
}
protected JMagickWriter createWriterImpl(final Object pExtension) throws IOException {
return new PCXImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* PDBImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PDBImageReader.java,v 1.0 Dec 3, 2007 7:14:23 PM haraldk Exp$
*/
public class PDBImageReader extends JMagickReader {
public PDBImageReader(final PDBImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* PDBImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @version $Id: PDBImageReaderSpi.java,v 1.1 2003/12/02 16:45:00 wmhakur Exp $
*/
public class PDBImageReaderSpi extends JMagickImageReaderSpiSupport {
public PDBImageReaderSpi() {
super(
new String[]{"pdb", "PDB"},
new String[]{"pdb", "PDB"},
new String[]{"image/x-palm-db", "image/palm-db"},
PDBImageReader.class.getName(),
null
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
//'v', 'I', 'M', 'G', 'V', 'i', 'e', 'w'
// [11 byte offset]
//00 00 00 00 00 00 00 00
//00 00 00 00 00 00 00 00
//00 00 00 00 00 00 00 00 [11 byte offset]
//........
//........
//........
return false;
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new PDBImageReader(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* PNGImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PNGImageReader.java,v 1.0 Dec 3, 2007 8:18:28 PM haraldk Exp$
*/
public class PNGImageReader extends JMagickReader {
public PNGImageReader(final PNGImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* PNGImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: PNGImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class PNGImageReaderSpi extends JMagickImageReaderSpiSupport {
public PNGImageReaderSpi() {
super(
new String[]{"png", "PNG"},
new String[]{"png"},
new String[]{"image/png", "image/x-png"},
PNGImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.PNGImageWriterSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {(byte) 0x89, (byte) 'P', (byte) 'N', (byte) 'G', // PNG
// 0x0d, 0x0a, 0x1a, 0x0a,}},
byte[] magic = new byte[8];
pSource.readFully(magic);
return magic[0] == (byte) 0x89 &&
magic[1] == 'P' && magic[2] == 'N' && magic[3] == 'G' &&
magic[4] == 0x0d && magic[5] == 0x0a &&
magic[6] == 0x1a && magic[7] == 0x0a;
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new PNGImageReader(this);
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* PNGImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PNGImageWriter.java,v 1.0 Dec 3, 2007 8:25:14 PM haraldk Exp$
*/
public class PNGImageWriter extends JMagickWriter {
public PNGImageWriter(final PNGImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale()) {
@Override
public boolean canWriteCompressed() {
return true;
}
@Override
public boolean canWriteProgressive() {
return true;
}
@Override
public boolean isCompressionLossless() {
return true;
}
};
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* PNGImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: PNGImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class PNGImageWriterSpi extends JMagickImageWriterSpiSupport {
public PNGImageWriterSpi() {
super(
new String[]{"png", "PNG"},
new String[]{"png"},
new String[]{"image/png", "image/x-png"},
PNGImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.PNGImageReaderSpi"}
);
}
protected JMagickWriter createWriterImpl(final Object pExtension) throws IOException {
return new PNGImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* PNMImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PNMImageReader.java,v 1.0 Dec 3, 2007 8:27:31 PM haraldk Exp$
*/
public class PNMImageReader extends JMagickReader {
public PNMImageReader(final PNMImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* PNMImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: PNMImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class PNMImageReaderSpi extends JMagickImageReaderSpiSupport {
public PNMImageReaderSpi() {
super(
new String[]{
"pnm", "PNM", "pbm", "PBM", "pgm", "PGM", "ppm", "PPM"
},
new String[]{
"pbm", "PBM", "pgm", "PGM", "ppm", "PPM"
},
new String[]{
"image/portable-pixmap", "image/x-portable-pixmap",
"image/portable-bitmap", "image/x-portable-bitmap",
"image/portable-graymap", "image/x-portable-graymap", "image/x-portable-graymap",
"image/portable-anymap", "image/x-portable-anymap", "application/x-portable-anymap"
},
PNMImageReader.class.getName(),
null
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {'P', '1'}, new byte[] {'P', '4'}}, // PBM ascii & raw
// new byte[][] {new byte[] {'P', '2'}, new byte[] {'P', '5'}}, // PGM ascii & raw
// new byte[][] {new byte[] {'P', '3'}, new byte[] {'P', '6'}}, // PPM ascii & raw
byte[] magic = new byte[2];
pSource.readFully(magic);
return magic[0] == 'P' && magic[1] >= '1' && magic[1] <= '6';
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new PNMImageReader(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* PSDImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PSDImageReader.java,v 1.0 Dec 3, 2007 8:33:19 PM haraldk Exp$
*/
public class PSDImageReader extends JMagickReader {
public PSDImageReader(final PSDImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* PSDImageReaderSpi class description.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: PSDImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class PSDImageReaderSpi extends JMagickImageReaderSpiSupport {
public PSDImageReaderSpi() {
super(
new String[]{"psd", "PSD"},
new String[]{"psd"},
new String[]{"image/psd", "image/x-psd", "application/x-photoshop"},
PSDImageReader.class.getName(),
null
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {'8', 'B', 'P', 'S'}}, // PSD
byte[] magic = new byte[4];
pSource.readFully(magic);
return magic[0] == '8' && magic[1] == 'B' && magic[2] == 'P' && magic[3] == 'S';
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new PSDImageReader(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* SWFImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: SWFImageReader.java,v 1.0 Dec 3, 2007 8:36:59 PM haraldk Exp$
*/
public class SWFImageReader extends JMagickReader {
public SWFImageReader(final SWFImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* SWFImageReaderSpi class description.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: SWFImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class SWFImageReaderSpi extends JMagickImageReaderSpiSupport {
public SWFImageReaderSpi() {
super(
new String[]{"flash", "FLASH"},
new String[]{"swf"},
new String[]{"application/x-shockwave-flash"},
SWFImageReader.class.getName(),
null
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
byte[] magic = new byte[3];
pSource.readFully(magic);
// TODO: FLV?
return (magic[0] == 'C' || magic[0] == 'F') && magic[1] == 'W' && magic[2] == 'S';
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new SWFImageReader(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* TIFFImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: TIFFImageReader.java,v 1.0 Dec 3, 2007 11:33:48 PM haraldk Exp$
*/
public class TIFFImageReader extends JMagickReader {
public TIFFImageReader(final TIFFImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* TargaImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @version $Id: TargaImageReaderSpi.java,v 1.1 2003/12/02 16:45:00 wmhakur Exp $
*/
public class TIFFImageReaderSpi extends JMagickImageReaderSpiSupport {
public TIFFImageReaderSpi() {
super(
new String[]{"tiff", "TIFF"},
new String[]{"tif", "tiff"},
new String[]{"image/x-tiff", "image/tiff"},
TIFFImageReader.class.getName(),
new String[] {"com.twlevemonkeys.imageio.plugins.jmagick.TIFFImageWriterSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {'M', 'M', 0, 42}, // TIFF Motorola byte order
// new byte[] {'I', 'I', 42, 0}}, // TIFF Intel byte order
byte[] magic = new byte[4];
pSource.readFully(magic);
return (magic[0] == 'M' && magic[1] == 'M' && magic[2] == 0 && magic[3] == 42) ||
(magic[0] == 'I' && magic[1] == 'I' && magic[2] == 42 && magic[3] == 0);
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new TIFFImageReader(this);
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* TIFFImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: TIFFImageWriter.java,v 1.0 Dec 3, 2007 11:35:58 PM haraldk Exp$
*/
public class TIFFImageWriter extends JMagickWriter {
public TIFFImageWriter(final TIFFImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale()) {
@Override
public boolean canWriteCompressed() {
return true;
}
};
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* TargaImageWriterSpi class description.
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: TargaImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class TIFFImageWriterSpi extends JMagickImageWriterSpiSupport {
public TIFFImageWriterSpi() {
super(
new String[]{"tiff", "TIFF"},
new String[]{"tif", "tiff"},
new String[]{"image/x-tiff", "image/tiff"},
TIFFImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.TIFFImageReaderSpi"}
);
}
protected JMagickWriter createWriterImpl(final Object pExtension) throws IOException {
return new TIFFImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* TargaImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: TargaImageReader.java,v 1.0 Dec 3, 2007 10:23:06 PM haraldk Exp$
*/
public class TargaImageReader extends JMagickReader {
public TargaImageReader(final TargaImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* TargaImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @version $Id: TargaImageReaderSpi.java,v 1.1 2003/12/02 16:45:00 wmhakur Exp $
*/
public class TargaImageReaderSpi extends JMagickImageReaderSpiSupport {
public TargaImageReaderSpi() {
super(
new String[]{"tga", "targa", "TGA", "TARGA"},
new String[]{"tga"},
new String[]{"image/x-tga", "image/targa"},
TargaImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.TargaImageWriterSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// // TODO: Targa 1989 signature look like (bytes 8-23 of 26 LAST bytes):
// // 'T', 'R', 'U', 'E', 'V', 'I', 'S', 'I', 'O', 'N', '-', 'X', 'F', 'I', 'L', 'E'
// // Targa 1987:
// new byte[][] {new byte[] {-1, 0x01, 0x01}, // Type 1: CM
// /*
// TODO: Figure out how to not interfere with CUR: 0x00000200
// new byte[] {-1, 0x00, 0x02},*/ new byte[] {-1, 0x01, 0x02}, // T2: RGB w & w/o CM
// new byte[] {-1, 0x00, 0x03}, // Type 3: B/W
// new byte[] {-1, 0x01, 0x09}, // Type 9: RLE CM
// new byte[] {-1, 0x00, 0x0a}, new byte[] {-1, 0x01, 0x0a}, // T10: RLE RGB w & w/o CM
// new byte[] {-1, 0x00, 0x0b}, // Type 11: Compressed B/W
// new byte[] {-1, 0x01, 0x20}, // Type 31: Compressed CM
// new byte[] {-1, 0x01, 0x21}, // Type 32: Compressed CM, 4 pass
// },
pSource.seek(pSource.length() - 18);
byte[] magic = new byte[18];
pSource.readFully(magic);
return "TRUEVISIOM-XFILE".equals(new String(magic, 0, 16));
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new TargaImageReader(this);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* TargaImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: TargaImageWriter.java,v 1.0 Dec 3, 2007 11:29:43 PM haraldk Exp$
*/
public class TargaImageWriter extends JMagickWriter {
public TargaImageWriter(final TargaImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale());
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* TargaImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: TargaImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class TargaImageWriterSpi extends JMagickImageWriterSpiSupport {
public TargaImageWriterSpi() {
super(
new String[]{"tga", "targa", "TGA", "TARGA"},
new String[]{"tga"},
new String[]{"image/targa", "image/x-tga"},
TargaImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.TargaImageReaderSpi"}
);
}
protected JMagickWriter createWriterImpl(final Object pExtension) throws IOException {
return new TargaImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* WBMPImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: WBMPImageReader.java,v 1.0 Dec 3, 2007 11:44:51 PM haraldk Exp$
*/
public class WBMPImageReader extends JMagickReader {
public WBMPImageReader(final WBMPImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
import javax.imageio.stream.ImageInputStream;
/**
* WBMPImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: WBMPImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class WBMPImageReaderSpi extends JMagickImageReaderSpiSupport {
public WBMPImageReaderSpi() {
super(
new String[]{"wbmp", "WBMP"},
new String[]{"wbmp"},
new String[]{"image/vnd.wap.wbmp"},
WBMPImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.WBMPImageWriterSpi"});
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {0, 0}}, // WBMP
byte[] magic = new byte[2];
pSource.readFully(magic);
return magic[0] == 0x00 && magic[1] == 0x00 &&
readMultiByteInteger(pSource) > 0 && readMultiByteInteger(pSource) > 0;// Positive size
// TODO: Consider testin if the size of the stream after the header matches
// the dimensions: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6331418
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new WBMPImageReader(this);
}
private static int readMultiByteInteger(ImageInputStream pStream) throws IOException {
int value = 0;
int b;
// Read while continuation bit is set
while ((b = pStream.read()) >= 0) {
value = (value << 7) + (b & 0x7f);
// Test continuation bit, if not set, return value
if ((b & 0x80) == 0) {
return value;
}
}
// If we got here, value could not be read
return -1;
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* WBMPImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: WBMPImageWriter.java,v 1.0 Dec 4, 2007 12:04:50 AM haraldk Exp$
*/
public class WBMPImageWriter extends JMagickWriter {
public WBMPImageWriter(final WBMPImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale());
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* WBMPImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: WBMPImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class WBMPImageWriterSpi extends JMagickImageWriterSpiSupport {
public WBMPImageWriterSpi() {
super(
new String[]{"wbmp", "WBMP"},
new String[]{"wbmp"},
new String[]{"image/vnd.wap.wbmp"},
WBMPImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.WBMPImageReaderSpi"}
);
}
protected JMagickWriter createWriterImpl(final Object pExtension) throws IOException {
return new WBMPImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* WMFImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: WMFImageReader.java,v 1.0 Dec 4, 2007 12:07:53 AM haraldk Exp$
*/
public class WMFImageReader extends JMagickReader {
public WMFImageReader(final WMFImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* WMFImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: WMFImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class WMFImageReaderSpi extends JMagickImageReaderSpiSupport {
public WMFImageReaderSpi() {
super(
new String[]{"wmf", "WMF"},
new String[]{"wmf"},
new String[]{"image/x-windows-metafile"},
WMFImageReader.class.getName(),
null
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {(byte) 0xd7, (byte) 0xcd, (byte) 0xc6, // WMF
// (byte) 0x9a, (byte) 0x00, (byte) 0x00,}},
byte[] magic = new byte[6];
pSource.readFully(magic);
return magic[0] == (byte) 0xD7 && magic[2] == (byte) 0xCD &&
magic[2] == (byte) 0xC6 && magic[3] == (byte) 0x9A &&
magic[4] == (byte) 0x00 && magic[5] == (byte) 0x00;
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new WMFImageReader(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* XBMImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: XBMImageReader.java,v 1.0 Dec 4, 2007 12:14:03 AM haraldk Exp$
*/
public class XBMImageReader extends JMagickReader {
public XBMImageReader(final XBMImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* XBMImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: XBMImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class XBMImageReaderSpi extends JMagickImageReaderSpiSupport {
public XBMImageReaderSpi() {
super(
new String[]{"xbm", "XBM"},
new String[]{"xbm"},
new String[]{"image/xbm", "image/x-xbm"},
XBMImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.XBMImageWriterSpi"});
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {'/', '*', ' ', 'X', 'B', 'M'}}, // X BitMap
byte[] magic = new byte[6];
pSource.readFully(magic);
return magic[0] == '/' && magic[1] == '*' && magic[2] == ' ' &&
magic[3] == 'X' && magic[4] == 'B' && magic[5] == 'M';
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new XBMImageReader(this);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* XBMImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: XBMImageWriter.java,v 1.0 Dec 4, 2007 12:20:37 AM haraldk Exp$
*/
public class XBMImageWriter extends JMagickWriter {
public XBMImageWriter(final XBMImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale());
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* XBMImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: XBMImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class XBMImageWriterSpi extends JMagickImageWriterSpiSupport {
public XBMImageWriterSpi() {
super(
new String[]{"xbm", "XBM"},
new String[]{"xbm"},
new String[]{"image/xbm", "image/x-xbm"},
XBMImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.XBMImageReaderSpi"}
);
}
protected JMagickWriter createWriterImpl(final Object pExtension) throws IOException {
return new XBMImageWriter(this);
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
/**
* XPMImageReader
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: XPMImageReader.java,v 1.0 Dec 4, 2007 12:22:20 AM haraldk Exp$
*/
public class XPMImageReader extends JMagickReader {
public XPMImageReader(final XPMImageReaderSpi pProvider) {
super(pProvider);
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.stream.ImageInputStream;
import java.io.IOException;
/**
* XPMImageReaderSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: XPMImageReaderSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class XPMImageReaderSpi extends JMagickImageReaderSpiSupport {
public XPMImageReaderSpi() {
super(
new String[]{"xpm", "XPM"},
new String[]{"xpm"},
new String[]{"image/xpm", "image/x-xpm"},
XPMImageReader.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.XPMImageWriterSpi"}
);
}
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {'/', '*', ' ', 'X', 'P', 'M'}}, // X PixelMap
byte[] magic = new byte[6];
pSource.readFully(magic);
return magic[0] == '/' && magic[1] == '*' && magic[2] == ' ' &&
magic[3] == 'X' && magic[4] == 'P' && magic[5] == 'M';
}
protected JMagickReader createReaderImpl(final Object pExtension) throws IOException {
return new XPMImageReader(this);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.ImageWriteParam;
/**
* XPMImageWriter
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: XPMImageWriter.java,v 1.0 Dec 4, 2007 12:26:46 AM haraldk Exp$
*/
public class XPMImageWriter extends JMagickWriter {
public XPMImageWriter(final XPMImageWriterSpi pProvider) {
super(pProvider);
}
protected ImageWriteParam createDefaultWriteParam() {
return new ImageWriteParam(getLocale());
}
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import java.io.IOException;
/**
* XPMImageWriterSpi
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haku $
* @version $Id: XPMImageWriterSpi.java,v 1.0 30.jul.2004 20:39:48 haku Exp $
*/
public class XPMImageWriterSpi extends JMagickImageWriterSpiSupport {
public XPMImageWriterSpi() {
super(
new String[]{"xpm", "XPM"},
new String[]{"xpm"},
new String[]{"image/xpm", "image/x-xpm"},
XPMImageWriter.class.getName(),
new String[]{"com.twelvemonkeys.imageio.plugins.jmagick.XPMImageReaderSpi"}
);
}
protected JMagickWriter createWriterImpl(final Object pExtension) throws IOException {
return new XPMImageWriter(this);
}
}

View File

@@ -0,0 +1,15 @@
/**
* JMagick plugin for ImageIO that uses JMagick, an open source Java interface for
* ImageMagick to read and write images.
* <p/>
* <!-- TODO: Describe the formats available -->
* <small>
* Note: The plugin relies on JMagick, which ues JNI and native code. You need
* to have the JMagick and ImageMagick shared libraries (or DLLs) in Java's
* {@code java.library.path} for this plugin to work.
* </small>
* <p/>
* @see <a href="http://www.imagemagick.org/">ImageMagick homepage</a>
* @see <a href="http://www.yeo.id.au/jmagick/">JMagick homepage</a>
*/
package com.twelvemonkeys.imageio.plugins.jmagick;

View File

@@ -0,0 +1,18 @@
com.twelvemonkeys.imageio.plugins.jmagick.BMPImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.GIFImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.ICOImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.JPEG2KImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.JPEGImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.PCDImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.PCXImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.PDBImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.PNGImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.PNMImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.PSDImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.SWFImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.TIFFImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.TargaImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.WBMPImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.WMFImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.XBMImageReaderSpi
com.twelvemonkeys.imageio.plugins.jmagick.XPMImageReaderSpi

View File

@@ -0,0 +1,12 @@
com.twelvemonkeys.imageio.plugins.jmagick.BMPImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.GIFImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.ICOImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.JPEG2KImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.JPEGImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.PCXImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.PNGImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.TIFFImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.TargaImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.WBMPImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.XBMImageWriterSpi
com.twelvemonkeys.imageio.plugins.jmagick.XPMImageWriterSpi

View File

@@ -0,0 +1,6 @@
# JMagick quirks mode
# ImageMagick/JMagick seems to use fileextension to recognize these formats...
TGA.useTempFile=true
WBMP.useTempFile=true
ICO.useTempFile=true
ILBM.useTempFile=true

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import javax.imageio.spi.ImageReaderSpi;
import java.awt.*;
import java.util.Arrays;
import java.util.List;
public class BMPImageReaderTestCase extends JMagickImageReaderAbstractTestCase<BMPImageReader> {
private BMPImageReaderSpi mProvider = new BMPImageReaderSpi();
protected List<TestData> getTestData() {
return Arrays.asList(
new TestData(getClassLoaderResource("/bmp/Blue Lace 16.bmp"), new Dimension(48, 48)),
new TestData(getClassLoaderResource("/bmp/blauesglas_16.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_16_bitmask444.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_16_bitmask555.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_16_bitmask565.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_24.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_32.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_32_bitmask888.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_32_bitmask888_reversed.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_4-IM.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_4.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_4.rle"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_8-IM.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_8.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_8.rle"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_gray.bmp"), new Dimension(301, 331)),
new TestData(getClassLoaderResource("/bmp/blauesglas_mono.bmp"), new Dimension(301, 331))
);
}
protected Class<BMPImageReader> getReaderClass() {
return BMPImageReader.class;
}
protected BMPImageReader createReader() {
return new BMPImageReader(mProvider);
}
protected ImageReaderSpi createProvider() {
return new BMPImageReaderSpi();
}
protected List<String> getFormatNames() {
return Arrays.asList("bmp");
}
protected List<String> getSuffixes() {
return Arrays.asList("bmp", "rle", "dib");
}
protected List<String> getMIMETypes() {
return Arrays.asList("image/bmp", "image/x-bmp", "image/x-windows-bmp", "image/x-ms-bmp");
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2008, Harald Kuhr
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name "TwelveMonkeys" nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.twelvemonkeys.imageio.plugins.jmagick;
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
import javax.imageio.ImageReader;
/**
* JMagickImageReaderAbstractTestCase
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: JMagickImageReaderAbstractTestCase.java,v 1.0 Apr 1, 2008 2:59:05 PM haraldk Exp$
*/
public abstract class JMagickImageReaderAbstractTestCase<T extends ImageReader> extends ImageReaderAbstractTestCase<T> {
@Override
protected void runTest() throws Throwable {
if (JMagickImageReaderSpiSupport.AVAILABLE) {
super.runTest();
}
else {
System.err.println("WARNING: JMagick not installed. Skipping test " + getName());
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB