public void generateThumbnail(File input, File output) throws IOException, de.uni_siegen.wineme.come_in.thumbnailer.ThumbnailerException {
//GENERATE FROM EXISTING BITMAP IN DWG
byte[] outputByte = new byte[4096];
FileInputStream fis = new FileInputStream(input);
fis.skip(0x0D);
fis.read(outputByte, 0, 4);
int PosSentinel = (((outputByte[3])&0xFF)*256*256*256)+(((outputByte[2])&0xFF)*256*256)+(((outputByte[1])&0xFF)*256)+((outputByte[0])&0xFF);
fis.skip(PosSentinel-0x0D-4+30);
outputByte[1]=0;
fis.read(outputByte, 0, 1);
int TypePreview = ((outputByte[0])&0xFF);
if (TypePreview==2) {
fis.read(outputByte, 0, 4);
int PosBMP = (((outputByte[3])&0xFF)*256*256*256)+(((outputByte[2])&0xFF)*256*256)+(((outputByte[1])&0xFF)*256)+((outputByte[0])&0xFF);
fis.read(outputByte, 0, 4);
int LenBMP = (((outputByte[3])&0xFF)*256*256*256)+(((outputByte[2])&0xFF)*256*256)+(((outputByte[1])&0xFF)*256)+((outputByte[0])&0xFF);
fis.skip(PosBMP-(PosSentinel+30)-1-4-4+14);
fis.read(outputByte, 0, 2);
int biBitCount = (((outputByte[1])&0xFF)*256)+((outputByte[0])&0xFF);
fis.skip(-16);
int bisSize=0;
int bfSize = 0;
if (biBitCount<9)
bfSize = 54 + 4 * ((int) (Math.pow(2,biBitCount))) + LenBMP ;
else bfSize = 54 + LenBMP ;
//WORD "BM"
outputByte[0]=0x42;outputByte[1]=0x4D;
//DWORD bfSize
outputByte[2]=(byte)(bfSize&0xff);outputByte[3]=(byte)(bfSize>>8&0xff);
outputByte[4]=(byte)(bfSize>>16&0xff);outputByte[5]=(byte)(bfSize>>>24);
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载
- 1
- 2
前往页