■前言
BufferedImage image = ImageIO.read(bin);
的返回值为NULL,所以想要查看图片文件真实的类型。
/**
* tif合并
**/
public static byte[] margerTif(List<byte[]> bytes){
ByteArrayInputStream bin = null;
List<BufferedImage> images = new ArrayList<BufferedImage> ();
for(byte[] b : bytes) {
try {
bin = new ByteArrayInputStream(b);
BufferedImage image = ImageIO.read(bin);
images.add(image);
bin.close();
}catch (Exception e) {
e.printStackTrace();
}
}
代码:TIF合并Java代码_com.sun.media.jai.codec-优快云博客
■例子
tif
- 文件头标识 (2 bytes) 4D 4D 或 49 49
・画图软件,以TIF形式保存文件
Java代码,合并生成的TIF (代码:TIF合并Java代码_com.sun.media.jai.codec-优快云博客)
=====
Get-Content ./1.tif | Format-Hex -Raw | Select-Object -First 1
===
■标头
========
(1)JPEG
- 文件头标识 (2 bytes): 0xff, 0xd8 (SOI) (JPEG 文件标识)
- 文件结束标识 (2 bytes): 0xff, 0xd9 (EOI)
(2)TGA
- 未压缩的前5字节 00 00 02 00 00
- RLE压缩的前5字节 00 00 10 00 00
(3)PNG
- 文件头标识 (8 bytes) 89 50 4E 47 0D 0A 1A 0A 字符包含:P NG
P(50) N(4E) G(47)
(4)GIF
- 文件头标识 (6 bytes) 47 49 46 38 39(37) 61,字符即: G I F 8 9 (7) a
(5)BMP
- 文件头标识 (2 bytes) 42 4D,字符即: B M
注意:有四种格式的 BMP
(通常使用第一个,【单色位图】)
===
图片
===
四种形式文件大小
Get-Content .\type1.bmp | Format-Hex -Raw | Select-Object -First 1 | findstr "000000"
Get-Content .\type2.bmp | Format-Hex -Raw | Select-Object -First 2 | findstr "000000"
Get-Content .\type3.bmp | Format-Hex -Raw | Select-Object -First 2 | findstr "000000"
Get-Content .\type4.bmp | Format-Hex -Raw | Select-Object -First 2 | findstr "000000"
四种形式文件16进制显示
===
(6)TIFF
- 文件头标识 (2 bytes) 4D 4D 或 49 49
(7)ICO
- 文件头标识 (8 bytes) 00 00 01 00 01 00 20 20
(8)CUR
- 文件头标识 (8 bytes) 00 00 02 00 01 00 20 20
■判断方法,16进制形式查看文件
win10 以 十六进制 形式(方式) 查看文件 内容_怎么用win10自带的format-hex工具-优快云博客
・TIF
---
・PNG