BITMAPV5HEADER

The BITMAPV5HEADER structure is the bitmap information header file. It is an extended version of the BITMAPINFOHEADER structure.

typedef struct {
  DWORD        bV5Size;
  LONG         bV5Width;
  LONG         bV5Height;
  WORD         bV5Planes;
  WORD         bV5BitCount;
  DWORD        bV5Compression;
  DWORD        bV5SizeImage;
  LONG         bV5XPelsPerMeter;
  LONG         bV5YPelsPerMeter;
  DWORD        bV5ClrUsed;
  DWORD        bV5ClrImportant;
  DWORD        bV5RedMask;
  DWORD        bV5GreenMask;
  DWORD        bV5BlueMask;
  DWORD        bV5AlphaMask;
  DWORD        bV5CSType;
  CIEXYZTRIPLE bV5Endpoints;
  DWORD        bV5GammaRed;
  DWORD        bV5GammaGreen;
  DWORD        bV5GammaBlue;
  DWORD        bV5Intent;
  DWORD        bV5ProfileData;
  DWORD        bV5ProfileSize;
  DWORD        bV5Reserved;
} BITMAPV5HEADER, *PBITMAPV5HEADER;

Members

bV5Size
The number of bytes required by the structure. Applications should use this member to determine which bitmap information header structure is being used.

bV5Width
The width of the bitmap, in pixels.

If bV5Compression is BI_JPEG or BI_PNG, the bV5Width member specifies the width of the decompressed JPEG or PNG image in pixels.

bV5Height
The height of the bitmap, in pixels. If the value of bV5Height is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. If bV5Height value is negative, the bitmap is a top-down DIB and its origin is the upper-left corner.

If bV5Height is negative, indicating a top-down DIB, bV5Compression must be either BI_RGB or BI_BITFIELDS. Top-down DIBs cannot be compressed.

If bV5Compression is BI_JPEG or BI_PNG, the bV5Height member specifies the height of the decompressed JPEG or PNG image in pixels.

bV5Planes
The number of planes for the target device. This value must be set to 1.

bV5BitCount
The number of bits that define each pixel and the maximum number of colors in the bitmap.

This member can be one of the following values.

ValueMeaning
0The number of bits per pixel is specified or is implied by the JPEG or PNG file format.
1The bitmap is monochrome, and the bmiColors member of BITMAPINFO contains two entries. Each bit in the bitmap array represents a pixel. If the bit is clear, the pixel is displayed with the color of the first entry in the bmiColors color table. If the bit is set, the pixel has the color of the second entry in the table.
4The bitmap has a maximum of 16 colors, and the bmiColors member of BITMAPINFO contains up to 16 entries. Each pixel in the bitmap is represented by a 4-bit index into the color table. For example, if the first byte in the bitmap is 0x1F, the byte represents two pixels. The first pixel contains the color in the second table entry, and the second pixel contains the color in the sixteenth table entry.
8The bitmap has a maximum of 256 colors, and the bmiColors member of BITMAPINFO contains up to 256 entries. In this case, each byte in the array represents a single pixel.
16The bitmap has a maximum of 2^16 colors. If the bV5Compression member of the BITMAPV5HEADER structure is BI_RGB, the bmiColors member of BITMAPINFO is NULL. Each WORD in the bitmap array represents a single pixel. The relative intensities of red, green, and blue are represented with five bits for each color component. The value for blue is in the least significant five bits, followed by five bits each for green and red. The most significant bit is not used. The bmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by the bV5ClrUsed member of the BITMAPV5HEADER.If the bV5Compression member of the BITMAPV5HEADER is BI_BITFIELDS, the bmiColors member contains three DWORD color masks that specify the red, green, and blue components, respectively, of each pixel. Each WORD in the bitmap array represents a single pixel.When the bV5Compression member is BI_BITFIELDS, bits set in each DWORD mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not need to be used.
24The bitmap has a maximum of 2^24 colors, and the bmiColors member of BITMAPINFO is NULL. Each 3-byte triplet in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The bmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by the bV5ClrUsed member of the BITMAPV5HEADER structure.
32The bitmap has a maximum of 2^32 colors. If the bV5Compression member of the BITMAPV5HEADER is BI_RGB, the bmiColors member of BITMAPINFO is NULL. Each DWORD in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The high byte in each DWORD is not used. The bmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by the bV5ClrUsed member of the BITMAPV5HEADER.If the bV5Compression member of the BITMAPV5HEADER is BI_BITFIELDS, the bmiColors member contains three DWORD color masks that specify the red, green, and blue components of each pixel. Each DWORD in the bitmap array represents a single pixel.

bV5Compression
Specifies that the bitmap is not compressed. The bV5RedMask, bV5GreenMask, and bV5BlueMask members specify the red, green, and blue components of each pixel. This is valid when used with 16- and 32-bpp bitmaps. This member can be one of the following values.

ValueMeaning
BI_RGBAn uncompressed format.
BI_RLE8A run-length encoded (RLE) format for bitmaps with 8 bpp. The compression format is a two-byte format consisting of a count byte followed by a byte containing a color index. If bV5Compression is BI_RGB and the bV5BitCount member is 16, 24, or 32, the bitmap array specifies the actual intensities of blue, green, and red rather than using color table indexes. For more information, see Bitmap Compression.
BI_RLE4An RLE format for bitmaps with 4 bpp. The compression format is a two-byte format consisting of a count byte followed by two word-length color indexes. For more information, see Bitmap Compression.
BI_BITFIELDSSpecifies that the bitmap is not compressed and that the color table consists of three DWORD color masks that specify the red, green, and blue components of each pixel. Valid when used with 16- and 32-bpp bitmaps.
BI_JPEGSpecifies that the image is compressed using the JPEG file Interchange Format. JPEG compression trades off compression against loss; it can achieve a compression ratio of 20:1 with little noticeable loss.
BI_PNGSpecifies that the image is compressed using the PNG file Interchange Format.

bV5SizeImage
The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps.

If bV5Compression is BI_JPEG or BI_PNG, bV5SizeImage is the size of the JPEG or PNG image buffer.

bV5XPelsPerMeter
The horizontal resolution, in pixels-per-meter, of the target device for the bitmap. An application can use this value to select a bitmap from a resource group that best matches the characteristics of the current device.

bV5YPelsPerMeter
The vertical resolution, in pixels-per-meter, of the target device for the bitmap.

bV5ClrUsed
The number of color indexes in the color table that are actually used by the bitmap. If this value is zero, the bitmap uses the maximum number of colors corresponding to the value of the bV5BitCount member for the compression mode specified by bV5Compression.

If bV5ClrUsed is nonzero and bV5BitCount is less than 16, the bV5ClrUsed member specifies the actual number of colors the graphics engine or device driver accesses. If bV5BitCount is 16 or greater, the bV5ClrUsed member specifies the size of the color table used to optimize performance of the system color palettes. If bV5BitCount equals 16 or 32, the optimal color palette starts immediately following the BITMAPV5HEADER. If bV5ClrUsed is nonzero, the color table is used on palettized devices, and bV5ClrUsed specifies the number of entries.

bV5ClrImportant
The number of color indexes that are required for displaying the bitmap. If this value is zero, all colors are required.

bV5RedMask
Color mask that specifies the red component of each pixel, valid only if bV5Compression is set to BI_BITFIELDS.

bV5GreenMask
Color mask that specifies the green component of each pixel, valid only if bV5Compression is set to BI_BITFIELDS.

bV5BlueMask
Color mask that specifies the blue component of each pixel, valid only if bV5Compression is set to BI_BITFIELDS.

bV5AlphaMask
Color mask that specifies the alpha component of each pixel.

bV5CSType
The color space of the DIB.

The following table specifies the values for bV5CSType.

ValueMeaning
LCS_CALIBRATED_RGBThis value implies that endpoints and gamma values are given in the appropriate fields.
LCS_sRGBSpecifies that the bitmap is in sRGB color space.
LCS_WINDOWS_COLOR_SPACEThis value indicates that the bitmap is in the system default color space, sRGB.
PROFILE_LINKEDThis value indicates that bV5ProfileData points to the file name of the profile to use (gamma and endpoints values are ignored).
PROFILE_EMBEDDEDThis value indicates that bV5ProfileData points to a memory buffer that contains the profile to be used (gamma and endpoints values are ignored).

See the LOGCOLORSPACE structure for information that defines a logical color space.

bV5Endpoints
A CIEXYZTRIPLE structure that specifies the x, y, and z coordinates of the three colors that correspond to the red, green, and blue endpoints for the logical color space associated with the bitmap. This member is ignored unless the bV5CSType member specifies LCS_CALIBRATED_RGB.

bV5GammaRed
Toned response curve for red. Used if bV5CSType is set to LCS_CALIBRATED_RGB. Specified in 16^16 format.

bV5GammaGreen
Toned response curve for green. Used if bV5CSType is set to LCS_CALIBRATED_RGB. Specified in 16^16 format.

bV5GammaBlue
Toned response curve for blue. Used if bV5CSType is set to LCS_CALIBRATED_RGB. Specified in 16^16 format.

bV5Intent
Rendering intent for bitmap. This can be one of the following values.

ValueIntentICCnameMeaning
LCS_GM_ABS_COLORIMETRICMatchAbsolute ColorimetricMaintains the white point. Matches the colors to their nearest color in the destination gamut.
LCS_GM_BUSINESS GraphicSaturationMaintains saturation.Used for business charts and other situations in which undithered colors are required.
LCS_GM_GRAPHICSProofRelative ColorimetricMaintains colorimetric match. Used for graphic designs and named colors.
LCS_GM_IMAGESPicturePerceptualMaintains contrast. Used for photographs and natural images.

bV5ProfileData
The offset, in bytes, from the beginning of the BITMAPV5HEADER structure to the start of the profile data. If the profile is embedded, profile data is the actual profile, and it is linked. (The profile data is the null-terminated file name of the profile.) This cannot be a Unicode string. It must be composed exclusively of characters from the Windows character set (code page 1252). These profile members are ignored unless the bV5CSType member specifies PROFILE_LINKED or PROFILE_EMBEDDED.

bV5ProfileSize
Size, in bytes, of embedded profile data.

bV5Reserved
This member has been reserved. Its value should be set to zero.

Remarks

If bV5Height is negative, indicating a top-down DIB, bV5Compression must be either BI_RGB or BI_BITFIELDS. Top-down DIBs cannot be compressed.

The Independent Color Management interface (ICM) 2.0 allows International Color Consortium (ICC) color profiles to be linked or embedded in DIBs (DIBs). See Using Structures for more information.

When a DIB is loaded into memory, the profile data (if present) should follow the color table, and the bV5ProfileData should provide the offset of the profile data from the beginning of the BITMAPV5HEADER structure. The value stored in bV5ProfileData will be different from the value returned by the sizeof operator given the BITMAPV5HEADER argument, because bV5ProfileData is the offset in bytes from the beginning of the BITMAPV5HEADER structure to the start of the profile data. (Bitmap bits do not follow the color table in memory). Applications should modify the bV5ProfileData member after loading the DIB into memory.

For packed DIBs, the profile data should follow the bitmap bits similar to the file format. The bV5ProfileData member should still give the offset of the profile data from the beginning of the BITMAPV5HEADER.

Applications should access the profile data only when bV5Size equals the size of the BITMAPV5HEADER and bV5CSType equals PROFILE_EMBEDDED or PROFILE_LINKED.

If a profile is linked, the path of the profile can be any fully qualified name (including a network path) that can be opened using the CreateFile function.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
windows平台上支持BITMAPCOREHEADERBITMAPINFOHEADERBITMAPV4HEADERBITMAPV5HEADER四种类型位图的类库! 简单用法举例: DibBitmap bmp,ret,tmp; bmp.Open(_T("E:\\bmp.bmp"));//打开 bmp.ConvertBit(4,ret);//转为4位位图,ret保存返回值 ret.RotateLeft(tmp);//向左旋转90度,tmp保存返回值 tmp.Invert();//所有像素反色,即RGB(1,2,3)变为RGB(254,253,252) tmp.At(10,10)=tmp.At(20,20);//单个像素点的取值和赋值操作 tmp.At(10,20)=ret.At(30,30);//注意,设置成的颜色如果颜色表内不存在,会设置成相近色 tmp.At(20,10)=RGB(255,0,0); bmp.AlphaBlend(0,0,tmp,128,RGB(255,255,255),true);//tmp以透明度128画到bmp的(0,0)处,其中tmp中的白色会镂空 bmp.Mirror();//bmp水平翻转 bmp.ConvertBit(16,ret,true);//转为5-6-5型16位位图,ret保存返回值 ret.SetClipbrd();//存入剪切板中 ret.Save(_T("E:\\bmp2.bmp"));//保存到文件 该类的头文件接口大致如下: class DibBitmap { BITMAPFILEHEADER* m_pbmfh; DWORD m_size;//保存m_pbmfh中malloc出来的内存大小,即是capacity//不为0时保证图像是可以处理的 public: enum BmType{NONE=0,CORETYPE,INFOTYPE,V4TYPE,V5TYPE}; public: class reference { //略.. }; public://DibBitmap01.cpp DibBitmap(); explicit DibBitmap(LPCTSTR pstrFileName); explicit DibBitmap(BITMAPFILEHEADER* pbmfh);//只是简单的赋值给成员变量m_pbmfh DibBitmap(HDC hdc, HBITMAP hBitmap, int BitCount);//1,4,8;16,24,32 DibBitmap(const DibBitmap& rhs); ~DibBitmap(); bool Open(LPCTSTR pstrFileName);//打开失败会Close() bool Save(LPCTSTR pstrFileName)const; void Close(); void Swap(DibBitmap& rhs); DibBitmap& operator=(const DibBitmap& rhs);//不一定申请过新内存 public://DibBitmap01.cpp BITMAPFILEHEADER* Get();//获取文件头 const BITMAPFILEHEADER* Get()const; BITMAPINFOHEADER* GetInfoHead();//获取信息头 const BITMAPINFOHEADER* GetInfoHead()const; RGBQUAD* GetQuad();//获取颜色表//没有颜色表,则返回NULL const RGBQUAD* GetQuad()const; BYTE* GetByte();//获取图素位 const BYTE* GetByte()const; bool GetMask(DWORD* dwMask,bool b565=false)const; //dwMask个数为四,需要屏蔽码时,依次存入RGB屏蔽码,并返回true //当为BITMAPV4HEADER以上时,还存入AlphaMask;b565参数同GetClr bool Attach(BITMAPFILEHEADER* pbmfh); BITMAPFILEHEADER* Detach();//返回值最后须free掉 HBITMAP CreateBitmap(HDC hdc)const;//返回值最后须DeleteObject掉 HBITMAP CreateDibSection ()const;//返回值最后须DeleteObject掉 BmType Type()const; DWORD Capacity()const;//返回m_size的值//注意,此值可能小于实际malloc的内存长度 DWORD FileSize()const;//整个文件的大小//不是返回m_size的值,m_size的值大于等于此返回值 DWORD BitsSize()const;//图素位的大小,即去掉文件头,信息头和颜色表之后的大小 DWORD Offset()const;//图素位的偏移量 LONG Width()const; LONG Height()const;//可能为负值 WORD Planes()const; WORD BitCount()const; DWORD ClrUsed()const; //一般是4,8位图才小于2^(4,8),其余的等于对应颜色数,m_pbmfh为空时返回0,32位图时,返回-1,16位555位图颜色数按565算 public://DibBitmap02.cpp LPTSTR DisplayDibHeader (LPTSTR szBuffer)const;//szBuffer得大于1200个//返回szBuffer RGBQUAD GetClr(size_t x,size_t y,bool b565=false)const; //获取(x,y)处的颜色值,已考虑方向问题,b565只有在16位深位图且没有屏蔽码时才有用,指明是5-5-5还是5-6-5 COLORREF GetRGBClr(size_t x,size_t y,bool b565=false)const;//条件同上//返回的最高位为0 bool GetClipbrd(HWND hwnd);//失败不一定会Close() void SetClipbrd(HWND hwnd)const; //If hwnd is NULL, the open clipboard is associated with the current task. void Mirror(bool bHoriz);//镜像//false表示垂直镜像 public://DibBitmap03.cpp void Invert(bool b565=false);//反色//在这里b565参数不起任何作用 RGBQUAD Invert(size_t x,size_t y,bool b565=false);//(x,y)处的颜色反色,返回反色后的近似颜色 RGBQUAD SetClr(size_t x,size_t y,RGBQUAD quad,bool b565=false);//设置颜色,返回设置成的最相近的颜色 COLORREF SetRGBClr(size_t x,size_t y,COLORREF clr,bool b565=false);//设置颜色,返回设置成的最相近的颜色 //以下两个函数相当牛逼,可直接引用修改颜色 COLORREF At(size_t x,size_t y,bool b565=false)const;//获取(x,y)处的颜色 reference At(size_t x,size_t y,bool b565=false);//获取(x,y)处的颜色引用,可直接进行修改 void AlphaBlend(int x,int y,const DibBitmap& rhs,BYTE bAlpha,COLORREF clr,bool bClr=false,bool b565=false); //把rhs以透明度bAlpha画到this中的(x,y)处(可以为负),注意:当&rhs==this时直接返回,啥也不操作 //若bClr为true,则clr参数有用,rhs中颜色值为clr的像素点完全透明 void RotateLeft(DibBitmap& ret)const; //this旋转(逆时针90度)后存入ret中,若this原先为空,则不改变ret,注意:当&ret==this时直接返回,啥也不操作 void RotateRight(DibBitmap& ret)const; //this旋转(顺时针90度)后存入ret中,若this原先为空,则不改变ret,注意:当&ret==this时直接返回,啥也不操作 void RotateOpposite();//旋转180度,注意后面没有const,此函数是旋转自身 public://DibBitmap04.cpp bool ConvertBit(WORD BitCount,DibBitmap& ret,bool b565=false)const; //转为同类型的不同位数位图//1,4,8;16,24,32,注意:当&ret==this时直接返回,啥也不操作 }; 说明: 此类支持四种位图格式: BITMAPCOREHEADERBITMAPINFOHEADERBITMAPV4HEADERBITMAPV5HEADER。 该类像素点坐标序号从0开始,原点位于位图左上角,不管位图信息头的高度字段是否为负,内部都已作转化处理 暂不支持这四种位图的以下几种情况: 1、biCompression字段为BI_RLE4,BI_RLE8,BI_JPEG,BI_PNG的位图; 2、BITMAPV5HEADER时,bV5CSType字段等于PROFILE_LINKED或PROFILE_EMBEDDED时的位图。 有问题联系:[email protected]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值