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