Inspired by bug #44958 - Record level support for Data Tables. (No formula parser...
[poi.git] / src / java / org / apache / poi / hssf / usermodel / HSSFPictureData.java
blob487c277f3913f78e14a79b2049ca4f108c6463fd
1 /* ====================================================================
2 Copyright 2002-2004 Apache Software Foundation
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 ==================================================================== */
18 package org.apache.poi.hssf.usermodel;
20 import org.apache.poi.ddf.EscherBitmapBlip;
21 import org.apache.poi.ddf.EscherBlipRecord;
22 import org.apache.poi.ddf.EscherMetafileBlip;
24 /**
25 * Represents binary data stored in the file. Eg. A GIF, JPEG etc...
27 * @author Daniel Noll
29 public class HSSFPictureData
31 // MSOBI constants for various formats.
32 public static final short MSOBI_WMF = 0x2160;
33 public static final short MSOBI_EMF = 0x3D40;
34 public static final short MSOBI_PICT = 0x5420;
35 public static final short MSOBI_PNG = 0x6E00;
36 public static final short MSOBI_JPEG = 0x46A0;
37 public static final short MSOBI_DIB = 0x7A80;
38 // Mask of the bits in the options used to store the image format.
39 public static final short FORMAT_MASK = (short) 0xFFF0;
41 /**
42 * Underlying escher blip record containing the bitmap data.
44 private EscherBlipRecord blip;
46 /**
47 * Constructs a picture object.
49 * @param blip the underlying blip record containing the bitmap data.
51 HSSFPictureData( EscherBlipRecord blip )
53 this.blip = blip;
56 /**
57 * Gets the picture data.
59 * @return the picture data.
61 public byte[] getData()
63 return blip.getPicturedata();
66 /**
67 * Suggests a file extension for this image.
69 * @return the file extension.
71 public String suggestFileExtension()
73 switch (blip.getRecordId())
75 case EscherMetafileBlip.RECORD_ID_WMF:
76 return "wmf";
77 case EscherMetafileBlip.RECORD_ID_EMF:
78 return "emf";
79 case EscherMetafileBlip.RECORD_ID_PICT:
80 return "pict";
81 case EscherBitmapBlip.RECORD_ID_PNG:
82 return "png";
83 case EscherBitmapBlip.RECORD_ID_JPEG:
84 return "jpeg";
85 case EscherBitmapBlip.RECORD_ID_DIB:
86 return "dib";
87 default:
88 return "";