點陣圖類型Types of Bitmaps

點陣圖會指定每個像素色彩的像素矩形陣列中的位元陣列。A bitmap is an array of bits that specify the color of each pixel in a rectangular array of pixels. 組成個別像素的位元數目會決定可以指派給該像素的色彩數目。The number of bits devoted to an individual pixel determines the number of colors that can be assigned to that pixel. 比方說,如果每個像素 4 個位元來表示,然後指定像素可以指派其中一個 16 不同的色彩 (2 ^4 = 16 個)。For example, if each pixel is represented by 4 bits, then a given pixel can be assigned one of 16 different colors (2^4 = 16). 下表顯示一些範例可以指派給像素,以表示指定之位元數的色彩數目。The following table shows a few examples of the number of colors that can be assigned to a pixel represented by a given number of bits.

每個像素的位元Bits per pixel 可以指派給像素的色彩數目Number of colors that can be assigned to a pixel
11 2^1 = 22^1 = 2
22 2^2 = 42^2 = 4
44 2^4 = 162^4 = 16
88 2^8 = 2562^8 = 256
1616 2^16 = 65,5362^16 = 65,536
2424 2^24 = 16,777,2162^24 = 16,777,216

通常儲存點陣圖的磁碟檔案包含一或多個資訊區塊儲存在陣列中的資訊,例如每個像素、 像素的每個資料列,以及資料列數目的位元數。Disk files that store bitmaps usually contain one or more information blocks that store information such as the number of bits per pixel, number of pixels in each row, and number of rows in the array. 這類檔案可能也會包含色彩表 (有時稱為調色盤)。Such a file might also contain a color table (sometimes called a color palette). 色彩表會將點陣圖中的數字對應到特定的色彩。A color table maps numbers in the bitmap to specific colors. 下圖顯示放大的影像,以及其點陣圖和色彩的資料表。The following illustration shows an enlarged image along with its bitmap and color table. 每個像素以 4 位元數字,因此會有 2 ^4 = 16 個色彩,色彩表中。Each pixel is represented by a 4-bit number, so there are 2^4 = 16 colors in the color table. 在資料表中的每一種色彩被以 24 位元數字:8 位元用於紅色、 綠色的 8 位元和 8 位元用於藍色。Each color in the table is represented by a 24-bit number: 8 bits for red, 8 bits for green, and 8 bits for blue. 數字是以十六進位 (基底 16) 格式所示:A = 10,B = 11,C = 12,D = 13,E = 14、 F = 15。The numbers are shown in hexadecimal (base 16) form: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.

點陣圖範例Bitmap sample

看看第 3 欄 5 的映像的資料列中的像素。Look at the pixel in row 3, column 5 of the image. 點陣圖中對應的數字為 1。The corresponding number in the bitmap is 1. 色彩表將告訴我們,1 代表紅色的色彩,因此像素都是紅色。The color table tells us that 1 represents the color red so the pixel is red. 在頂端列中的所有項目都是點陣圖的 3。All the entries in the top row of the bitmap are 3. 色彩表會告訴我們 3 代表藍色,因此會以藍色顯示之影像的頂端列中的所有像素。The color table tells us that 3 represents blue, so all the pixels in the top row of the image are blue.

注意

某些點陣圖格式儲存在由下往上;點陣圖的第一個資料列中的數字對應到影像的下方資料列中的像素。Some bitmaps are stored in bottom-up format; the numbers in the first row of the bitmap correspond to the pixels in the bottom row of the image.

將索引儲存到色彩表的點陣圖稱為調色盤編製索引的點陣圖。A bitmap that stores indexes into a color table is called a palette-indexed bitmap. 有些點陣圖並不需要色彩表。Some bitmaps have no need for a color table. 比方說,如果點陣圖使用每像素 24 位元,該點陣圖可以儲存自己的色彩,而不是索引色彩表中。For example, if a bitmap uses 24 bits per pixel, that bitmap can store the colors themselves rather than indexes into a color table. 下圖顯示儲存直接 (24 位元 / 像素) 色彩的點陣圖,而不是使用色彩表。The following illustration shows a bitmap that stores colors directly (24 bits per pixel) rather than using a color table. 此圖解同時顯示對應的影像的放大的檢視。The illustration also shows an enlarged view of the corresponding image. 在點陣圖,FFFFFF 表示白色、 FF0000 代表紅色、 00FF00 代表綠色,而 0000ff> 中代表藍色。In the bitmap, FFFFFF represents white, FF0000 represents red, 00FF00 represents green, and 0000FF represents blue.

點陣圖範例Bitmap sample

圖形檔格式Graphics File Formats

有許多標準格式,將點陣圖儲存在磁碟檔案。There are many standard formats for saving bitmaps in disk files. GDI+GDI+ 支援的圖形檔案下列段落中所述的格式。supports the graphics file formats described in the following paragraphs.

BMPBMP

BMP 是使用 Windows 儲存裝置和應用程式無關的映像的標準格式。BMP is a standard format used by Windows to store device-independent and application-independent images. 檔案標頭中指定的每個像素 (1、 4、 8、 15、 24、 32 或 64) 指定 BMP 檔案的位元數。The number of bits per pixel (1, 4, 8, 15, 24, 32, or 64) for a given BMP file is specified in a file header. 每個像素 24 位元的 BMP 檔案很常見。BMP files with 24 bits per pixel are common. BMP 檔案通常不會壓縮,因此,不適合用來傳輸在網際網路上。BMP files are usually not compressed and, therefore, are not well suited for transfer across the Internet.

圖形交換格式 (GIF)Graphics Interchange Format (GIF)

GIF 是出現在網頁的映像的一般格式。GIF is a common format for images that appear on Web pages. Gif 適用於線條繪圖、 使用的純色,區塊的圖片和圖片與銳利色彩之間的界限。GIFs work well for line drawings, pictures with blocks of solid color, and pictures with sharp boundaries between colors. Gif 被壓縮,而且壓縮程序; 不會損失任何資訊解壓縮後的映像正是與原來相同。GIFs are compressed, but no information is lost in the compression process; a decompressed image is exactly the same as the original. Gif 的一種色彩可以指定為透明的如此將會有顯示它的任何網頁上的背景色彩的影像。One color in a GIF can be designated as transparent, so that the image will have the background color of any Web page that displays it. 一連串的 GIF 影像可以儲存在單一檔案,以形成的動畫的 GIF。A sequence of GIF images can be stored in a single file to form an animated GIF. Gif 會儲存最多每像素 8 位元,所以它們被限制為 256 種色彩。GIFs store at most 8 bits per pixel, so they are limited to 256 colors.

Joint Photographic Experts Group (JPEG)Joint Photographic Experts Group (JPEG)

JPEG 非常適用於自然的場景,例如掃描照片的壓縮配置。JPEG is a compression scheme that works well for natural scenes such as scanned photographs. 在壓縮過程中,會遺失一些資訊,但通常是無法察覺到人們的眼睛遺失。Some information is lost in the compression process, but often the loss is imperceptible to the human eye. Jpeg 會儲存 24 個位元 / 像素,因此它們可以顯示多個 16 萬種色彩。JPEGs store 24 bits per pixel, so they are capable of displaying more than 16 million colors. Jpeg 不支援透明度或動畫。JPEGs do not support transparency or animation.

JPEG 影像壓縮層級設定,但較高的壓縮層級 (較小的檔案) 會造成多個遺失的資訊。The level of compression in JPEG images is configurable, but higher compression levels (smaller files) result in more loss of information. 20:1 的壓縮比率通常會產生肉眼難以區別從原始的映像。A 20:1 compression ratio often produces an image that the human eye finds difficult to distinguish from the original. 下圖顯示 BMP 影像和兩個從該 BMP 影像已壓縮的 JPEG 影像。The following illustration shows a BMP image and two JPEG images that were compressed from that BMP image. 第一個 JPEG 壓縮比率為 4:1,第二個 JPEG 大約 8:1 壓縮率。The first JPEG has a compression ratio of 4:1 and the second JPEG has a compression ratio of about 8:1.

檔案類型範例Filetype samples

JPEG 壓縮不會適用於線條繪圖,區塊的單色,並明確的界限。JPEG compression does not work well for line drawings, blocks of solid color, and sharp boundaries. 下圖顯示兩個 Jpeg GIF 及 BMP。The following illustration shows a BMP along with two JPEGs and a GIF. BMP 從壓縮的 Jpeg 和 GIF。The JPEGs and the GIF were compressed from the BMP. 壓縮比率為 4:1 GIF、 4:1,較小的 jpeg,和 8:3 的較大的 JPEG。The compression ratio is 4:1 for the GIF, 4:1 for the smaller JPEG, and 8:3 for the larger JPEG. 請注意 GIF 維護程式碼行,以及明確的界限,但 Jpeg 似乎比較模糊的界限。Note that the GIF maintains the sharp boundaries along the lines, but the JPEGs tend to blur the boundaries.

FiletypesFiletypes

JPEG 是一種壓縮配置,不是檔案格式。JPEG is a compression scheme, not a file format. JPEG 檔案交換格式 (JFIF) 是常用於儲存和轉送已根據 JPEG 配置壓縮的影像檔案格式。JPEG File Interchange Format (JFIF) is a file format commonly used for storing and transferring images that have been compressed according to the JPEG scheme. 網頁瀏覽器所顯示的 JFIF 檔案使用.jpg 副檔名。JFIF files displayed by Web browsers use the .jpg extension.

可交換影像檔案 (EXIF)Exchangeable Image File (EXIF)

EXIF 是用數位相機所擷取的相片的檔案格式。EXIF is a file format used for photographs captured by digital cameras. EXIF 檔案包含壓縮的 JPEG 規格根據映像。An EXIF file contains an image that is compressed according to the JPEG specification. EXIF 檔案也包含相片的相關資訊 (拍攝日期、 快門速度、 曝光時間等等) 以及相機 (製造商、 型號及等等) 的相關資訊。An EXIF file also contains information about the photograph (date taken, shutter speed, exposure time, and so on) and information about the camera (manufacturer, model, and so on).

Portable Network Graphics (PNG)Portable Network Graphics (PNG)

PNG 格式會保留眾多的 GIF 格式的優點,但也提供功能的 GIF。The PNG format retains many of the advantages of the GIF format but also provides capabilities beyond those of GIF. GIF 檔,像是 PNG 檔案會壓縮不會遺失的資訊。Like GIF files, PNG files are compressed with no loss of information. PNG 檔案可以儲存 8、 24 日或每個像素和灰階 1、 2、 4、 8、 48 位元或每像素 16 位元的色彩。PNG files can store colors with 8, 24, or 48 bits per pixel and grayscales with 1, 2, 4, 8, or 16 bits per pixel. 相反地,只有 1、 2、 4 或 8 位元 / 像素,可以使用 GIF 檔案。In contrast, GIF files can use only 1, 2, 4, or 8 bits per pixel. PNG 檔案也可以儲存每個像素指定的程度該像素的色彩混合使用的背景色彩的 alpha 值。A PNG file can also store an alpha value for each pixel, which specifies the degree to which the color of that pixel is blended with the background color.

GIF PNG 改進,以漸進方式顯示影像的能力 (也就是要顯示映像的更好和更好的近似值,因為它抵達網路連接)。PNG improves on GIF in its ability to progressively display an image (that is, to display better and better approximations of the image as it arrives over a network connection). PNG 檔案可以包含 gamma 修正和色彩修正的資訊,讓映像可以在各種不同的顯示裝置上正確轉譯。PNG files can contain gamma correction and color correction information so that the images can be accurately rendered on a variety of display devices.

標記的影像檔案格式 (TIFF)Tag Image File Format (TIFF)

TIFF 是富彈性且可擴充的格式支援的各種不同的平台和映像處理的應用程式。TIFF is a flexible and extendable format that is supported by a wide variety of platforms and image-processing applications. TIFF 檔案可以儲存任意數目的每個像素的位元映像,而且可以利用各種不同的壓縮演算法。TIFF files can store images with an arbitrary number of bits per pixel and can employ a variety of compression algorithms. 數個映像可以儲存在單一、 多頁的 TIFF 檔中。Several images can be stored in a single, multiple-page TIFF file. 映像 (掃描器製作,主機電腦,類型壓縮、 方向、 每像素,並依此類推樣本) 相關的資訊可以儲存在檔案中,並透過標記使用排列。Information related to the image (scanner make, host computer, type of compression, orientation, samples per pixel, and so on) can be stored in the file and arranged through the use of tags. 可以擴充 TIFF 格式,視需要加入新的標記與核准。The TIFF format can be extended as needed by the approval and addition of new tags.

另請參閱See also