1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.utils.ui.gfx.clipboard.streams;
\r
14 import java.io.IOException;
\r
15 import java.io.InputStream;
\r
17 import org.simantics.utils.ui.gfx.clipboard.headers.BitmapFileHeader;
\r
21 * Adds WIN32 API BITMAPFILEHEADER into the beginning of stream
\r
23 * @author Marko Luukkainen
\r
26 public class AddBitmapHeaderInputStream extends InputStream{
\r
27 private InputStream iStream;
\r
28 private int readBytes = 0;
\r
29 private byte[] header;
\r
31 public AddBitmapHeaderInputStream(InputStream iStream) {
\r
32 this.iStream = iStream;
\r
33 BitmapFileHeader bfHeader = new BitmapFileHeader();
\r
34 header = bfHeader.getBytes();
\r
38 public int read() throws IOException {
\r
39 if (readBytes < header.length) {
\r
40 return 0xff & header[readBytes++];
\r
42 return iStream.read();
\r