/**
* 获取 Jpg图片的像素数
* @param is
* @return
*/
private static long getJpgPixes(InputStream is)
{
int w = 0;
int h = 0;
int b = 0;
try
{
while ( (b = is.read()) != -1)
{
if (b == 0xff)
{
b = is.read();
if (b >= 0xc0 && b <= 0xc3)
{
is.skip(3);//跳过3字节
h = (is.read() << 8) | (is.read());
w = (is.read() << 8) | (is.read());
return w * h;
}
else if (b != 0 && b != 0xd9 && b !=0xd8)
{
int length = (is.read() << 8) | (is.read());
is.skip(length - 2);
}
else if (b == -1)
{
break;
}
}
}
return -1;
}
catch (Exception e)
{
e.printStackTrace();
}
return -1;
}
获取 Jpg图片的像素数
原创
©著作权归作者所有:来自51CTO博客作者TechOnly的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Python绘制多时相栅格图像的像素数值折线图
本文介绍基于Python中的gdal模块,对大量长时间序列的栅格遥感影像文件,绘制其每一个波段中、若干随机指定的像元的时间序列曲线图的方法~
Python GDAL 栅格文件 像素数值 遥感影像 -
JS选择图片获取base64编码预览图片
通过将图片转为data url的base64格式编码,实现直接预览图片
图片预览 base64 dataurl 图片转base64 -
opencv读取图片获取像素数据 opencv获取图像像素
o
opencv读取图片获取像素数据 迭代器 数组 i++