X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.utils.ui%2Fsrc%2Forg%2Fsimantics%2Futils%2Fui%2Fgfx%2Fclipboard%2Fstreams%2FUncompressedDIBInputStream.java;fp=bundles%2Forg.simantics.utils.ui%2Fsrc%2Forg%2Fsimantics%2Futils%2Fui%2Fgfx%2Fclipboard%2Fstreams%2FUncompressedDIBInputStream.java;h=7d036b1543e99b6f5f1499904fd137f33a171492;hp=c90f45b74cf38420ffa062273378bd416107384d;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/clipboard/streams/UncompressedDIBInputStream.java b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/clipboard/streams/UncompressedDIBInputStream.java index c90f45b74..7d036b154 100644 --- a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/clipboard/streams/UncompressedDIBInputStream.java +++ b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/clipboard/streams/UncompressedDIBInputStream.java @@ -1,71 +1,71 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.utils.ui.gfx.clipboard.streams; - -import java.io.IOException; -import java.io.InputStream; - -import org.simantics.utils.ui.gfx.clipboard.headers.BitmapInfoHeader; -import org.simantics.utils.ui.gfx.clipboard.headers.Win32Constants; - - -/** - *

- * Intended to uncompress compressed image streams so that - * SWT can use images sent to clipboard (native WIN32) - *

- *

- * Currently no uncompression methods are implemented, so - * stream throws IOException if its used to - * stream compressed images. - *

- * - * @author Marko Luukkainen - * - */ -public class UncompressedDIBInputStream extends InputStream { - private InputStream iStream; - private int readBytes = 0; - private byte [] header; - - public UncompressedDIBInputStream(InputStream iStream) throws IOException{ - this.iStream = iStream; - header = new byte[BitmapInfoHeader.sizeof]; - iStream.read(header, 0, BitmapInfoHeader.sizeof); - - BitmapInfoHeader infoHeader = new BitmapInfoHeader(); - infoHeader.setBytes(header); - if (infoHeader.biCompression == Win32Constants.BI_BITFIELDS) { - throw new IOException("BI_BITFIELDS stream not supported"); - } - if (infoHeader.biCompression == Win32Constants.BI_JPEG) { - throw new IOException("BI_JPEG stream not supported"); - } - if (infoHeader.biCompression == Win32Constants.BI_PNG) { - throw new IOException("BI_PNG stream not supported"); - } - if (infoHeader.biCompression == Win32Constants.BI_RLE8) { - throw new IOException("BI_RLE8 stream not supported"); - } - if (infoHeader.biCompression == Win32Constants.BI_RLE24) { - throw new IOException("BI_RLE24 stream not supported"); - } - } - - @Override - public int read() throws IOException { - if (readBytes < header.length) { - return 0xff & header[readBytes++]; - } - return iStream.read(); - } -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.utils.ui.gfx.clipboard.streams; + +import java.io.IOException; +import java.io.InputStream; + +import org.simantics.utils.ui.gfx.clipboard.headers.BitmapInfoHeader; +import org.simantics.utils.ui.gfx.clipboard.headers.Win32Constants; + + +/** + *

+ * Intended to uncompress compressed image streams so that + * SWT can use images sent to clipboard (native WIN32) + *

+ *

+ * Currently no uncompression methods are implemented, so + * stream throws IOException if its used to + * stream compressed images. + *

+ * + * @author Marko Luukkainen + * + */ +public class UncompressedDIBInputStream extends InputStream { + private InputStream iStream; + private int readBytes = 0; + private byte [] header; + + public UncompressedDIBInputStream(InputStream iStream) throws IOException{ + this.iStream = iStream; + header = new byte[BitmapInfoHeader.sizeof]; + iStream.read(header, 0, BitmapInfoHeader.sizeof); + + BitmapInfoHeader infoHeader = new BitmapInfoHeader(); + infoHeader.setBytes(header); + if (infoHeader.biCompression == Win32Constants.BI_BITFIELDS) { + throw new IOException("BI_BITFIELDS stream not supported"); + } + if (infoHeader.biCompression == Win32Constants.BI_JPEG) { + throw new IOException("BI_JPEG stream not supported"); + } + if (infoHeader.biCompression == Win32Constants.BI_PNG) { + throw new IOException("BI_PNG stream not supported"); + } + if (infoHeader.biCompression == Win32Constants.BI_RLE8) { + throw new IOException("BI_RLE8 stream not supported"); + } + if (infoHeader.biCompression == Win32Constants.BI_RLE24) { + throw new IOException("BI_RLE24 stream not supported"); + } + } + + @Override + public int read() throws IOException { + if (readBytes < header.length) { + return 0xff & header[readBytes++]; + } + return iStream.read(); + } +}