本文整理汇总了Java中com.lowagie.text.Image.ORIGINAL_BMP属性的典型用法代码示例。如果您正苦于以下问题:Java Image.ORIGINAL_BMP属性的具体用法?Java Image.ORIGINAL_BMP怎么用?Java Image.ORIGINAL_BMP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.lowagie.text.Image
的用法示例。
在下文中一共展示了Image.ORIGINAL_BMP属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RtfImage
/**
* Constructs a RtfImage for an Image.
*
* @param doc The RtfDocument this RtfImage belongs to
* @param image The Image that this RtfImage wraps
* @throws DocumentException If an error occurred accessing the image content
*/
public RtfImage(RtfDocument doc, Image image) throws DocumentException
{
super(doc);
imageType = image.getOriginalType();
if (!(imageType == Image.ORIGINAL_JPEG || imageType == Image.ORIGINAL_BMP
|| imageType == Image.ORIGINAL_PNG || imageType == Image.ORIGINAL_WMF || imageType == Image.ORIGINAL_GIF)) {
throw new DocumentException("Only BMP, PNG, WMF, GIF and JPEG images are supported by the RTF Writer");
}
alignment = image.getAlignment();
width = image.getWidth();
height = image.getHeight();
plainWidth = image.getPlainWidth();
plainHeight = image.getPlainHeight();
this.imageData = getImageData(image);
}
示例2: getImageData
/**
* Extracts the image data from the Image.
*
* @param image The image for which to extract the content
* @return The raw image data, not formated
* @throws DocumentException If an error occurs accessing the image content
*/
private byte[][] getImageData(Image image) throws DocumentException
{
final int WMF_PLACEABLE_HEADER_SIZE = 22;
final RtfByteArrayBuffer bab = new RtfByteArrayBuffer();
try {
if(imageType == Image.ORIGINAL_BMP) {
bab.append(MetaDo.wrapBMP(image));
} else {
final byte[] iod = image.getOriginalData();
if(iod == null) {
final InputStream imageIn = image.getUrl().openStream();
if(imageType == Image.ORIGINAL_WMF) { //remove the placeable header first
for(int k = 0; k < WMF_PLACEABLE_HEADER_SIZE; k++) {
if(imageIn.read() < 0) throw new EOFException("while removing wmf placeable header");
}
}
bab.write(imageIn);
imageIn.close();
} else {
if(imageType == Image.ORIGINAL_WMF) {
//remove the placeable header
bab.write(iod, WMF_PLACEABLE_HEADER_SIZE, iod.length - WMF_PLACEABLE_HEADER_SIZE);
} else {
bab.append(iod);
}
}
}
return bab.toByteArrayArray();
} catch(IOException ioe) {
throw new DocumentException(ioe.getMessage());
}
}
示例3: wrapBMP
public static byte[] wrapBMP(Image image) throws IOException {
if (image.getOriginalType() != Image.ORIGINAL_BMP)
throw new IOException("Only BMP can be wrapped in WMF.");
InputStream imgIn;
byte data[] = null;
if (image.getOriginalData() == null) {
imgIn = image.getUrl().openStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
int b = 0;
while ((b = imgIn.read()) != -1)
out.write(b);
imgIn.close();
data = out.toByteArray();
}
else
data = image.getOriginalData();
int sizeBmpWords = (data.length - 14 + 1) >>> 1;
ByteArrayOutputStream os = new ByteArrayOutputStream();
// write metafile header
writeWord(os, 1);
writeWord(os, 9);
writeWord(os, 0x0300);
writeDWord(os, 9 + 4 + 5 + 5 + (13 + sizeBmpWords) + 3); // total metafile size
writeWord(os, 1);
writeDWord(os, 14 + sizeBmpWords); // max record size
writeWord(os, 0);
// write records
writeDWord(os, 4);
writeWord(os, META_SETMAPMODE);
writeWord(os, 8);
writeDWord(os, 5);
writeWord(os, META_SETWINDOWORG);
writeWord(os, 0);
writeWord(os, 0);
writeDWord(os, 5);
writeWord(os, META_SETWINDOWEXT);
writeWord(os, (int)image.getHeight());
writeWord(os, (int)image.getWidth());
writeDWord(os, 13 + sizeBmpWords);
writeWord(os, META_DIBSTRETCHBLT);
writeDWord(os, 0x00cc0020);
writeWord(os, (int)image.getHeight());
writeWord(os, (int)image.getWidth());
writeWord(os, 0);
writeWord(os, 0);
writeWord(os, (int)image.getHeight());
writeWord(os, (int)image.getWidth());
writeWord(os, 0);
writeWord(os, 0);
os.write(data, 14, data.length - 14);
if ((data.length & 1) == 1)
os.write(0);
// writeDWord(os, 14 + sizeBmpWords);
// writeWord(os, META_STRETCHDIB);
// writeDWord(os, 0x00cc0020);
// writeWord(os, 0);
// writeWord(os, (int)image.height());
// writeWord(os, (int)image.width());
// writeWord(os, 0);
// writeWord(os, 0);
// writeWord(os, (int)image.height());
// writeWord(os, (int)image.width());
// writeWord(os, 0);
// writeWord(os, 0);
// os.write(data, 14, data.length - 14);
// if ((data.length & 1) == 1)
// os.write(0);
writeDWord(os, 3);
writeWord(os, 0);
os.close();
return os.toByteArray();
}