Png supports how many colors




















The choice of using which type of PNG would rather depend on your specific needs. In terms of color detail, PNG-8 can only hold colors max while the other can support bit color or approximately 16 million colors.

With this, PNG-8 is best used for small graphics that require less detail and color detail like simple graphic images and computer icons. The use of PNG is, therefore, best for more detailed images and web photos.

When you want to store image data more efficiently, you will immediately consider compressing them. In this regard, you are torn between two choices: lossless compression and lossy compression. Lossless compression is compressing the image devoid of significant alterations in overall appearance. Lossy compression is compression that produces some artifacts or image distortions.

The former is used in medical imaging, highly technical drawings, and comics to name a few while the latter is applicable to any natural image like your typical photographs.

It is commonly used on the Web and is also a popular choice for application graphics. Therefore, PNG includes many of the benefits of both formats. The alpha channel is added to the three standard color channels red, green, and blue, or RGB and provides levels of transparency.

JPEG images do not support transparent pixels and GIF images only support completely transparent not partially opaque pixels. Therefore, the PNG format allows Web developers and icon designers to fade an image to a transparent background rather than a specific color.

A PNG with an alpha channel can be placed on any color background and maintain its original appearance, even around the edges. In case you want to store your image data efficiently, you might consider compressing them.

Due to its broad color accessibility, PNG 24 has a Lossless compression capability. It compresses an image without significantly altering its overall appearance. On the other hand, PNG 8 supports lossy compression, which involves producing some image distortions or artifacts.

You can use the former on any natural image, such as typical photos, and the latter is highly technical drawings, comics, and medical imaging, among others.

In terms of PNG 8 vs. The result will be opaque and transparent area edges that are somewhat rigid and free from translucent effects. PNG 24 supports the transition from opaque to completely transparent; therefore, it is the real deal if you desire an alpha translucent transition effect. The upshot is that the human visual system is relatively poor at analyzing colors, so feeding it different combinations of red, green, and blue light suffices to fool it into thinking it is seeing an entire spectrum.

Keep in mind, however, that while true yellow and a combination of red and green may look identical to us, to spectrometers or nonhuman eyes they are quite different. Since they employ pigments, which absorb light rather than emit it, the RGB color space that works so well for computer monitors is inappropriate. All of these color spaces are beyond the scope of this book, but note that every single one of them has its basis in human physiology. Indeed, if YUV and its brethren sound quite a lot like the set of three signals going into the brain that I just discussed, rest assured that it's not coincidence.

Not a single color space in common use today truly represents the full continuum of physical color. Since black is the preferred color for a huge class of printed material, including text, it is more efficient and considerably cheaper to use a single pigment for it than always to be mixing the other three. Some printing systems actually use five, six, or even seven distinct pigments. Finally, note that image files may represent the appearance of a scene not only as a self-contained item, but also in reference to a background or to other images or text.

In particular, transparency information is often desirable. The simplest approach to transparency in computer graphics is to mark a particular color as transparent, but more complex applications will generally require a completely separate channel of information. This is known as an alpha channel or sometimes an alpha mask and enables the use of partial transparency, such as is often used in television overlays.

PNG adheres to the usual convention that alpha represents opacity; that is, an alpha value of 0 is fully transparent, and the maximum value for the pixel depth is completely opaque. PNG also uses only unassociated alpha, wherein the actual gray or color values are stored unchanged and are only affected by the alpha channel at display time.

The alternative is associated or premultiplied alpha, in which the pixel values are effectively precomposited against a black background; although this allows slightly faster software compositing, it amounts to a lossy transformation of the image data and was therefore rejected in the design of PNG.

IHDR must be the first chunk in a PNG image, and it includes all of the details about the type of the image: its height and width, pixel depth, compression and filtering methods, interlacing method, whether it has an alpha transparency channel, and whether it's a truecolor, grayscale, or colormapped palette image.

Not all combinations of image types are valid, however, and much of the remainder of this chapter will be devoted to a discussion of what is allowed. Figure Layout of the simplest PNG. IDAT contains all of the image's compressed pixel data. Although single IDATs are perfectly valid as long as they contain no more than 2 gigabytes of compressed data, in most images the compressed data is split into several IDAT chunks for greater robustness.

Since the chunk's CRC is at the end, a streaming application that encounters a large IDAT can either force the user to wait until the complete chunk arrives before displaying anything, or it can begin displaying the image without knowing if it's valid.

In the latter case, if the IDAT happens to be damaged, the user will see garbage on the display. Since the image dimensions were already read from a previously CRC-checked chunk, in theory the garbage will be restricted to the region belonging to the image.

Fortunately, small IDAT chunks are by far the most common, particularly in sizes of 8 or 32 kilobytes. IEND is the simplest chunk of all; it contains no data, just indicates that there are no more chunks in the image. And it serves as one more check that the PNG file is complete and internally self-consistent.

These three chunk types are sufficient to build truecolor and grayscale PNG files, with or without an alpha channel, but palette-based images require one more: PLTE, the palette chunk.

PLTE simply contains a sequence of red, green, and blue values, where a value of 0 is black and is full intensity; anywhere from 1 to RGB triplets are allowed, depending on the pixel depth of the image. That is, for a 4-bit image, no more than 16 palette entries are allowed. Figure Layout of the second-simplest PNG. I noted earlier that not all possible combinations of PNG image types and features are allowed by the specification.

Let's take a closer look at the basic types and their features. Palette-based images, also known as colormapped or index-color images, use the PLTE chunk and are supported in four pixel depths: 1, 2, 4, and 8 bits, corresponding to a maximum of 2, 4, 16, or palette entries. Unlike GIF images, however, fewer than the maximum number of entries may be present. On the other hand, GIF does support pixel depths of 3, 5, 6, and 7 bits; 6-bit color images, in particular, are common on the World Wide Web.

Perhaps a more useful comparison is with the superset of baseline TIFF that is supported by Sam Leffler's free libtiff, which has become the software industry's unofficial standard for TIFF decoding. Nor is there any provision for compression of the palette data--so a bit TIFF palette would require KB all by itself.

As its name implies--the first letter is lowercase--tRNS is an ancillary chunk, which means the image is still viewable even if the decoder somehow fails to recognize the chunk. It may contain as many transparency entries as there are palette entries more than that would not make any sense or as few as one, and it must come after PLTE and before the first IDAT. But even the names of standard chunks were chosen in accordance with the rules, as if they might be encountered by a particularly simple-minded PNG decoder.

In fact, this was done in order to test the chunk-naming rules themselves: would a decoder that relied only on them behave sensibly?

By comparison, GIF supports only binary transparency, wherein a single palette color is marked as completely transparent, while all others are fully opaque. GIF has a tiny advantage in that the transparent entry can live anywhere in the palette, whereas a single PNG transparency entry should come first--all tRNS entries before the transparent one must exist and must have the value fully opaque , which would be redundant and therefore a waste of space. But the code necessary to rearrange the palette so that all non-opaque entries come before any opaque ones is simple to write, and the benefits of PNG's more flexible transparency scheme far outweigh this minor drawback.

The TIFF format supports at least three kinds of transparency information, two involving an interleaved alpha channel extra samples and the third involving a completely separate subimage or subfile that is used as a bilevel transparency mask. PNG grayscale images support the widest range of pixel depths of any image type. Depths of 1, 2, 4, 8, and 16 bits are supported, covering everything from simple black-and-white scans to full-depth medical and raw astronomical images. Neither format is directly supported by PNG, although one could, in principle, design an ancillary chunk to hold the proper conversion information.



0コメント

  • 1000 / 1000