01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: http://www.apache.org/licenses/LICENSE-2.0
10:
11: Unless required by applicable law or agreed to in writing, software
12: distributed under the License is distributed on an "AS IS" BASIS,
13: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: See the License for the specific language governing permissions and
15: limitations under the License.
16: ==================================================================== */
17: package org.apache.poi.hslf.blip;
18:
19: import org.apache.poi.hslf.usermodel.PictureData;
20:
21: import java.io.IOException;
22: import java.io.ByteArrayOutputStream;
23:
24: /**
25: * Represents a bitmap picture data: JPEG or PNG.
26: * The data is not compressed and the exact file content is written in the stream.
27: *
28: * @author Yegor Kozlov
29: */
30: public abstract class Bitmap extends PictureData {
31:
32: public byte[] getData() {
33: byte[] rawdata = getRawData();
34: byte[] imgdata = new byte[rawdata.length - 17];
35: System.arraycopy(rawdata, 17, imgdata, 0, imgdata.length);
36: return imgdata;
37: }
38:
39: public void setData(byte[] data) throws IOException {
40: ByteArrayOutputStream out = new ByteArrayOutputStream();
41: byte[] checksum = getChecksum(data);
42: out.write(checksum);
43: out.write(0);
44: out.write(data);
45:
46: setRawData(out.toByteArray());
47: }
48: }
|