png

常见图片格式了解

依然范特西╮ 提交于 2019-12-31 04:48:37
前言 作为一个客户端开发,对于图片格式一直没有一个清晰的了解,这里简单的罗列出各种图片格式的区别,文章中有部分是他人的引用,会在底部放上链接,望轻喷。 概念了解 有损压缩 & 无损压缩 有损压缩(lossy compression) : 有损压缩算法是一种数据压缩方法,经过此方法压缩、解压的数据会 与原始数据不同但是非常接近。它是与无损数据压缩相对的压缩方法。有损数据压缩又称破坏性资料压缩、有损压缩、有损压缩、不可逆压缩 。其原理是借由将次要的信息数据舍弃,牺牲一些质量来减少数据量、提高压缩比。这种方法经常用于压缩多媒体数据(音频、视频、图片)。根据各种格式设计的不同,有损数据压缩都会有代间损失——每次压缩与解压文件都会带来渐进的质量下降。 无损压缩(Lossless Compression) : 指数据经过压缩后,信息不受损失,还能完全恢复到压缩前的原样 。无损压缩通常用于严格要求“经过压缩、解压缩的数据必须与原始数据一致”的场合。典型的例子包括文字文件、程序可执行文件、程序源代码。有些图片文件格式,例如PNG和GIF,使用的是无损压缩。 索引色 & 直接色 索引色 : 索引颜色是一种以有限的方式管理数字图像颜色的技术,以节省计算机内存和文件存储,同时加速显示刷新和文件传输。即 用一个数字来代表(索引)一种颜色,在存储图片的时候,存储一个数字的组合,同时存储数字到图片颜色的映射

常见图片格式详解

依然范特西╮ 提交于 2019-12-31 04:48:16
标明原作者信息 http://www.cnblogs.com/xiangism 做了几年有关图形、图像的工作,对图片格式算是小有经验,在此写成一文章总结下。虽然一开始并不想讲很理论的东西,但写完后发现几乎全是理论,细想一下关于图片格式的知识本身就是理论的东西,囧~~ 那就力求用最简单的方式将这些“理论”讲清楚吧。 常见的图片格式有bmp, jpg(jpeg), png, gif, webp等。 图像基本数据结构 要讲图片格式还先得从图像的基本数据结构说起。在计算机中, 图像是由一个个像素点组成,像素点就是颜色点,而颜色最简单的方式就是用RGB或RGBA表示, 如图所示 (图1) (图2) 如果有A通道就表明这个图像可以有透明效果。 R,G,B每个分量一般是用一个字节(8位)来表示,所以图(1)中每个像素大小就是3*8=24位图, 而图(2)中每个像素大小是4*8=32位。 这里有三点需要说明: 一、图像y方向正立或倒立 图像是二维数据,数据在内存中只能一维存储,二维转一维有不同的对应方式。比较常见的只有两种方式: 按像素“行排列”从上往下或者从下往上。 如图所示的图像有9个像素点,如果从上往下排列成一维数据是(123456789), 如果是从下往上排列则为(789456123)。 只所以会有这种区别是因为,前一种是以计算机图形学的屏幕坐标系为参考(右上为原点,y轴向下 )

图片格式 WebP APNG

孤街浪徒 提交于 2019-12-31 04:47:39
WebP 是一种支持有损压缩和无损压缩的图片文件格式,派生自图像编码格式 VP8。根据 Google 的测试,无损压缩后的 WebP 比 PNG 文件少了 45% 的文件大小,即使这些 PNG 文件经过其他压缩工具压缩之后,WebP 还是可以减少 28% 的文件大小。 PNG 转 WebP 的压缩率要高于 PNG 原图压缩率,同样支持有损与无损压缩 转换后的 WebP 体积大幅减少,图片质量也得到保障(同时肉眼几乎无法看出差异) 转换后的 WebP 支持 Alpha 透明和 24-bit 颜色数,不存在 PNG8 色彩不够丰富和在浏览器中可能会出现毛边的问题 WebP 的优势体现在它具有更优的图像数据压缩算法,能带来更小的图片体积,而且拥有肉眼识别无差异的图像质量;同时具备了无损和有损的压缩模式、Alpha 透明以及动画的特性,在 JPEG 和 PNG 上的转化效果都非常优秀、稳定和统一。 如果网站以图片为主,或者你的产品基于 Chromium 内核,建议体验尝试。假如你打算在 App 中使用 WebP,除了 Android4.0 以上提供的原生支持外,其他版本以及 iOS 都可以直接使用官方提供的解析库 WebP 使用的是 Fancy 采样算法,既然是采样算法必然有采样区块,而 JPEG 的采样区块是 8*8,对于原始图片的长宽不是 8 的倍数,都需要先补成 8 的倍数

常见图片格式PNG,JPEG,BMP,GIF区别总结

左心房为你撑大大i 提交于 2019-12-31 04:47:08
在前端工作久了经常会遇到各种格式的图片文件,现文做一些区别总结,帮助理解但不深入。 【PNG】(Portable Network Graphics) PNG是一种无损压缩的位图图形格式,主要有PNG8、PNG24、PNG32三种格式,主要区别如下: PNG8)8位PNG,最大支持2的8次方=256色,支持256阶alpha透明,支持索引色透明 PNG24)24位PNG,最大支持2的24次方>1600万色,不支持256阶alpha透明和索引色透明 PNG32)32位PNG,最大支持2的24次方>1600万色,在PNG24的基础上补了8位,用于支持256阶alpha透明,不支持索引色透明 【JPEG】(Joint Photographic Experts Group) JPG的文件格式是JPEG,由于早期系统文件扩展名只支持3个字符,所以简写成了JPG,由于养成了习惯,JPG比JPEG更流行,本质没有区别。 JPEG不能存储透明信息。 JPEG的压缩标准可分为标准JPEG、渐进式JPEG及JPEG2000三种,主要区别如下: 标准JPEG)以24位存储颜色的格式。展现方式为由上而下依次加载图片,直到图片全部加载完成,才能看到完整的图片。支持压缩,但可能有损耗。 渐进式JPEG)标准JPEG的改良格式。展现方式为交错加载图片,先呈现模糊外观,等到全部加载完再显示完整的原图。

Why is Slick giving me this warning regarding PNG data?

落花浮王杯 提交于 2019-12-31 04:37:12
问题 I'm getting this warning in the console: WARN:class org.newdawn.slick.opengl.PNGImageData failed to read the data After switching between png files, it seems the warning is appearing because I was using a 16 bit PNG image. Why is this? Should I ignore it and stick with 16 bit or use 8 bit? 回答1: For those that are Googling this error (like I did), my answer was that my PNGs were interlaced. They would still load, but display the above error. Short answer, switch interlacing to none when you

Save 1 bit deep binary image in Python

谁说我不能喝 提交于 2019-12-30 11:37:37
问题 I have a binary image in Python and I want to save it in my pc. I need it to be a 1 bit deep png image once stored in my computer. How can I do that? I tried with both PIL and cv2 but I'm not able to save it with 1 bit depth. 回答1: Use: cv2.imwrite(<image_name>, img, [cv2.IMWRITE_PNG_BILEVEL, 1]) (this will still use compression, so in practice it will most likely have less than 1 bit per pixel) 回答2: If you're not loading pngs or anything the format does behave pretty reasonably to just write

Is it possible to check for PNG support with jQuery.Support?

女生的网名这么多〃 提交于 2019-12-30 11:11:12
问题 My question is regarding the jQuery Support system. I'd like to know if it is possible to tell whether or not the browser will support semi-transparent background PNG images using this method. Edit: I am not interested in CSS solutions to a specific problem. I'd like to know if the jQuery support checking system can check this . I appreciate the advice but I'm trying to find out a specific bit of information about the support feature of jQuery. 回答1: I think that is simply not possible, after

Is it possible to check for PNG support with jQuery.Support?

为君一笑 提交于 2019-12-30 11:10:54
问题 My question is regarding the jQuery Support system. I'd like to know if it is possible to tell whether or not the browser will support semi-transparent background PNG images using this method. Edit: I am not interested in CSS solutions to a specific problem. I'd like to know if the jQuery support checking system can check this . I appreciate the advice but I'm trying to find out a specific bit of information about the support feature of jQuery. 回答1: I think that is simply not possible, after

How to determine png dimensions based on file size limit?

寵の児 提交于 2019-12-30 10:28:24
问题 If an app has business logic that says a 24-bit PNG can never exceed 250KB, is it possible to predict what the largest width & height that the image could be and still fit under the 250KB requirement? Since there are a lot of variables with color-depth, alpha channels, etc... is it possible to know this? Or to get even close? 回答1: It is possible, but it probably isn't useful. PNG's zlib compression has a maximum compression ratio of 1032:1 (for a long sequence of the same byte value). So 250

How to add a PNG image as background in Android with no alteration (banding)?

寵の児 提交于 2019-12-30 10:10:10
问题 I'm trying to add a background that includes a gradient (I do want to use an image, not an android xml declared gradient effect). This image is remarkably ruined by Android, it add some crappy banding whatever I try the result is the same (two capture of approximately the same region the distorted/normal images) : My image is used as a layout background inside my layout XML : android:background="@drawable/background_gradient_dithered" I've tried to used an intermediate drawable to force