BITMAPV4HEADER
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| bV4Size | DWORD | 4 | +0 | +0 | 構造体に必要なバイト数です。アプリケーションはこのメンバーを使用して、どのビットマップ情報ヘッダー構造体が使用されているかを判断します。 | ||||||||||||||||
| bV4Width | INT | 4 | +4 | +4 | ビットマップの幅 (ピクセル単位) です。 bV4Compression が BI_JPEG または BI_PNG の場合、bV4Width は JPEG または PNG 画像の幅をピクセル単位で指定します。 | ||||||||||||||||
| bV4Height | INT | 4 | +8 | +8 | ビットマップの高さ (ピクセル単位) です。bV4Height が正の場合、ビットマップはボトムアップ DIB であり、原点は左下隅になります。bV4Height が負の場合、ビットマップはトップダウン DIB であり、原点は左上隅になります。 bV4Height が負で、トップダウン DIB であることを示す場合、bV4Compression は BI_RGB または BI_BITFIELDS のいずれかでなければなりません。トップダウン DIB は圧縮できません。 bV4Compression が BI_JPEG または BI_PNG の場合、bV4Height は JPEG または PNG 画像の高さをピクセル単位で指定します。 | ||||||||||||||||
| bV4Planes | WORD | 2 | +12 | +12 | ターゲットデバイスのプレーン数です。この値は 1 に設定しなければなりません。 | ||||||||||||||||
| bV4BitCount | WORD | 2 | +14 | +14 | ピクセルあたりのビット数です。BITMAPV4HEADER 構造体の bV4BitCount メンバーは、各ピクセルを定義するビット数と、ビットマップ内の最大色数を決定します。このメンバーは次のいずれかの値でなければなりません。
| ||||||||||||||||
| bV4V4Compression | BI_COMPRESSION | 4 | +16 | +16 | 圧縮されたボトムアップビットマップの圧縮形式です (トップダウン DIB は圧縮できません)。このメンバーには次のいずれかの値を指定できます。
| ||||||||||||||||
| bV4SizeImage | DWORD | 4 | +20 | +20 | 画像のサイズ (バイト単位) です。BI_RGB ビットマップの場合は 0 に設定できます。 bV4Compression が BI_JPEG または BI_PNG の場合、bV4SizeImage は JPEG または PNG 画像バッファーのサイズです。 | ||||||||||||||||
| bV4XPelsPerMeter | INT | 4 | +24 | +24 | ビットマップのターゲットデバイスの水平方向の解像度 (ピクセル/メートル) です。アプリケーションはこの値を使用して、現在のデバイスの特性に最もよく一致するビットマップをリソースグループから選択できます。 | ||||||||||||||||
| bV4YPelsPerMeter | INT | 4 | +28 | +28 | ビットマップのターゲットデバイスの垂直方向の解像度 (ピクセル/メートル) です。 | ||||||||||||||||
| bV4ClrUsed | DWORD | 4 | +32 | +32 | カラーテーブル内でビットマップが実際に使用するカラーインデックスの数です。この値が 0 の場合、ビットマップは bV4Compression で指定された圧縮モードにおける bV4BitCount メンバーの値に対応する最大数の色を使用します。 bV4ClrUsed が 0 以外で、bV4BitCount メンバーが 16 未満の場合、bV4ClrUsed メンバーはグラフィックスエンジンまたはデバイスドライバーがアクセスする実際の色数を指定します。bV4BitCount が 16 以上の場合、bV4ClrUsed メンバーは、システムのカラーパレットのパフォーマンスを最適化するために使用されるカラーテーブルのサイズを指定します。bV4BitCount が 16 または 32 の場合、最適なカラーパレットは BITMAPV4HEADER の直後から始まります。 | ||||||||||||||||
| bV4ClrImportant | DWORD | 4 | +36 | +36 | ビットマップの表示に必要となるカラーインデックスの数です。この値が 0 の場合、すべての色が重要です。 | ||||||||||||||||
| bV4RedMask | DWORD | 4 | +40 | +40 | 各ピクセルの赤成分を指定するカラーマスクです。bV4Compression が BI_BITFIELDS に設定されている場合にのみ有効です。 | ||||||||||||||||
| bV4GreenMask | DWORD | 4 | +44 | +44 | 各ピクセルの緑成分を指定するカラーマスクです。bV4Compression が BI_BITFIELDS に設定されている場合にのみ有効です。 | ||||||||||||||||
| bV4BlueMask | DWORD | 4 | +48 | +48 | 各ピクセルの青成分を指定するカラーマスクです。bV4Compression が BI_BITFIELDS に設定されている場合にのみ有効です。 | ||||||||||||||||
| bV4AlphaMask | DWORD | 4 | +52 | +52 | 各ピクセルのアルファ成分を指定するカラーマスクです。 | ||||||||||||||||
| bV4CSType | DWORD | 4 | +56 | +56 | DIB の色空間です。次の表に bV4CSType の値を示します。
論理色空間を定義する情報については、LOGCOLORSPACE 構造体を参照してください。 | ||||||||||||||||
| bV4Endpoints | CIEXYZTRIPLE | 36 | +60 | +60 | ビットマップに関連付けられた論理色空間の赤、緑、青のエンドポイントに対応する 3 つの色の x、y、z 座標を指定する CIEXYZTRIPLE 構造体です。このメンバーは、bV4CSType メンバーが LCS_CALIBRATED_RGB を指定していない限り無視されます。 メモ 色空間とは、色を 3 つ以上の座標によって数値的に表現するためのモデルです。たとえば、RGB 色空間は色を赤、緑、青の座標で表現します。
| ||||||||||||||||
| bV4GammaRed | DWORD | 4 | +96 | +96 | 赤のトーンレスポンスカーブです。このメンバーは、色の値が校正済みの RGB 値であり、かつ bV4CSType が LCS_CALIBRATED_RGB に設定されていない限り無視されます。符号なし固定小数点 16.16 形式で指定します。上位 16 ビットが符号なし整数部、下位 16 ビットが小数部です。 | ||||||||||||||||
| bV4GammaGreen | DWORD | 4 | +100 | +100 | 緑のトーンレスポンスカーブです。bV4CSType が LCS_CALIBRATED_RGB に設定されている場合に使用されます。符号なし固定小数点 16.16 形式で指定します。上位 16 ビットが符号なし整数部、下位 16 ビットが小数部です。 | ||||||||||||||||
| bV4GammaBlue | DWORD | 4 | +104 | +104 | 青のトーンレスポンスカーブです。bV4CSType が LCS_CALIBRATED_RGB に設定されている場合に使用されます。符号なし固定小数点 16.16 形式で指定します。上位 16 ビットが符号なし整数部、下位 16 ビットが小数部です。 |
公式ドキュメント
BITMAPV4HEADER 構造体は、ビットマップ情報ヘッダーファイルです。BITMAPINFOHEADER 構造体の拡張版です。
アプリケーションでは、追加機能を利用するために BITMAPV5HEADER 構造体を使用できます。
解説(Remarks)
BITMAPV4HEADER 構造体は、JPEG または PNG 画像をソース画像として StretchDIBits に渡せるように拡張されています。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// CIEXYZ (x64 12 / x86 12 バイト)
typedef struct CIEXYZ {
INT ciexyzX;
INT ciexyzY;
INT ciexyzZ;
} CIEXYZ;
// CIEXYZTRIPLE (x64 36 / x86 36 バイト)
typedef struct CIEXYZTRIPLE {
CIEXYZ ciexyzRed;
CIEXYZ ciexyzGreen;
CIEXYZ ciexyzBlue;
} CIEXYZTRIPLE;
// BITMAPV4HEADER (x64 108 / x86 108 バイト)
typedef struct BITMAPV4HEADER {
DWORD bV4Size;
INT bV4Width;
INT bV4Height;
WORD bV4Planes;
WORD bV4BitCount;
BI_COMPRESSION bV4V4Compression;
DWORD bV4SizeImage;
INT bV4XPelsPerMeter;
INT bV4YPelsPerMeter;
DWORD bV4ClrUsed;
DWORD bV4ClrImportant;
DWORD bV4RedMask;
DWORD bV4GreenMask;
DWORD bV4BlueMask;
DWORD bV4AlphaMask;
DWORD bV4CSType;
CIEXYZTRIPLE bV4Endpoints;
DWORD bV4GammaRed;
DWORD bV4GammaGreen;
DWORD bV4GammaBlue;
} BITMAPV4HEADER;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CIEXYZ
{
public int ciexyzX;
public int ciexyzY;
public int ciexyzZ;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CIEXYZTRIPLE
{
public CIEXYZ ciexyzRed;
public CIEXYZ ciexyzGreen;
public CIEXYZ ciexyzBlue;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BITMAPV4HEADER
{
public uint bV4Size;
public int bV4Width;
public int bV4Height;
public ushort bV4Planes;
public ushort bV4BitCount;
public uint bV4V4Compression;
public uint bV4SizeImage;
public int bV4XPelsPerMeter;
public int bV4YPelsPerMeter;
public uint bV4ClrUsed;
public uint bV4ClrImportant;
public uint bV4RedMask;
public uint bV4GreenMask;
public uint bV4BlueMask;
public uint bV4AlphaMask;
public uint bV4CSType;
public CIEXYZTRIPLE bV4Endpoints;
public uint bV4GammaRed;
public uint bV4GammaGreen;
public uint bV4GammaBlue;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CIEXYZ
Public ciexyzX As Integer
Public ciexyzY As Integer
Public ciexyzZ As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CIEXYZTRIPLE
Public ciexyzRed As CIEXYZ
Public ciexyzGreen As CIEXYZ
Public ciexyzBlue As CIEXYZ
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BITMAPV4HEADER
Public bV4Size As UInteger
Public bV4Width As Integer
Public bV4Height As Integer
Public bV4Planes As UShort
Public bV4BitCount As UShort
Public bV4V4Compression As UInteger
Public bV4SizeImage As UInteger
Public bV4XPelsPerMeter As Integer
Public bV4YPelsPerMeter As Integer
Public bV4ClrUsed As UInteger
Public bV4ClrImportant As UInteger
Public bV4RedMask As UInteger
Public bV4GreenMask As UInteger
Public bV4BlueMask As UInteger
Public bV4AlphaMask As UInteger
Public bV4CSType As UInteger
Public bV4Endpoints As CIEXYZTRIPLE
Public bV4GammaRed As UInteger
Public bV4GammaGreen As UInteger
Public bV4GammaBlue As UInteger
End Structureimport ctypes
from ctypes import wintypes
class CIEXYZ(ctypes.Structure):
_fields_ = [
("ciexyzX", ctypes.c_int),
("ciexyzY", ctypes.c_int),
("ciexyzZ", ctypes.c_int),
]
class CIEXYZTRIPLE(ctypes.Structure):
_fields_ = [
("ciexyzRed", CIEXYZ),
("ciexyzGreen", CIEXYZ),
("ciexyzBlue", CIEXYZ),
]
class BITMAPV4HEADER(ctypes.Structure):
_fields_ = [
("bV4Size", wintypes.DWORD),
("bV4Width", ctypes.c_int),
("bV4Height", ctypes.c_int),
("bV4Planes", ctypes.c_ushort),
("bV4BitCount", ctypes.c_ushort),
("bV4V4Compression", wintypes.DWORD),
("bV4SizeImage", wintypes.DWORD),
("bV4XPelsPerMeter", ctypes.c_int),
("bV4YPelsPerMeter", ctypes.c_int),
("bV4ClrUsed", wintypes.DWORD),
("bV4ClrImportant", wintypes.DWORD),
("bV4RedMask", wintypes.DWORD),
("bV4GreenMask", wintypes.DWORD),
("bV4BlueMask", wintypes.DWORD),
("bV4AlphaMask", wintypes.DWORD),
("bV4CSType", wintypes.DWORD),
("bV4Endpoints", CIEXYZTRIPLE),
("bV4GammaRed", wintypes.DWORD),
("bV4GammaGreen", wintypes.DWORD),
("bV4GammaBlue", wintypes.DWORD),
]#[repr(C)]
pub struct CIEXYZ {
pub ciexyzX: i32,
pub ciexyzY: i32,
pub ciexyzZ: i32,
}
#[repr(C)]
pub struct CIEXYZTRIPLE {
pub ciexyzRed: CIEXYZ,
pub ciexyzGreen: CIEXYZ,
pub ciexyzBlue: CIEXYZ,
}
#[repr(C)]
pub struct BITMAPV4HEADER {
pub bV4Size: u32,
pub bV4Width: i32,
pub bV4Height: i32,
pub bV4Planes: u16,
pub bV4BitCount: u16,
pub bV4V4Compression: u32,
pub bV4SizeImage: u32,
pub bV4XPelsPerMeter: i32,
pub bV4YPelsPerMeter: i32,
pub bV4ClrUsed: u32,
pub bV4ClrImportant: u32,
pub bV4RedMask: u32,
pub bV4GreenMask: u32,
pub bV4BlueMask: u32,
pub bV4AlphaMask: u32,
pub bV4CSType: u32,
pub bV4Endpoints: CIEXYZTRIPLE,
pub bV4GammaRed: u32,
pub bV4GammaGreen: u32,
pub bV4GammaBlue: u32,
}import "golang.org/x/sys/windows"
type CIEXYZ struct {
ciexyzX int32
ciexyzY int32
ciexyzZ int32
}
type CIEXYZTRIPLE struct {
ciexyzRed CIEXYZ
ciexyzGreen CIEXYZ
ciexyzBlue CIEXYZ
}
type BITMAPV4HEADER struct {
bV4Size uint32
bV4Width int32
bV4Height int32
bV4Planes uint16
bV4BitCount uint16
bV4V4Compression uint32
bV4SizeImage uint32
bV4XPelsPerMeter int32
bV4YPelsPerMeter int32
bV4ClrUsed uint32
bV4ClrImportant uint32
bV4RedMask uint32
bV4GreenMask uint32
bV4BlueMask uint32
bV4AlphaMask uint32
bV4CSType uint32
bV4Endpoints CIEXYZTRIPLE
bV4GammaRed uint32
bV4GammaGreen uint32
bV4GammaBlue uint32
}type
CIEXYZ = record
ciexyzX: Integer;
ciexyzY: Integer;
ciexyzZ: Integer;
end;
CIEXYZTRIPLE = record
ciexyzRed: CIEXYZ;
ciexyzGreen: CIEXYZ;
ciexyzBlue: CIEXYZ;
end;
BITMAPV4HEADER = record
bV4Size: DWORD;
bV4Width: Integer;
bV4Height: Integer;
bV4Planes: Word;
bV4BitCount: Word;
bV4V4Compression: DWORD;
bV4SizeImage: DWORD;
bV4XPelsPerMeter: Integer;
bV4YPelsPerMeter: Integer;
bV4ClrUsed: DWORD;
bV4ClrImportant: DWORD;
bV4RedMask: DWORD;
bV4GreenMask: DWORD;
bV4BlueMask: DWORD;
bV4AlphaMask: DWORD;
bV4CSType: DWORD;
bV4Endpoints: CIEXYZTRIPLE;
bV4GammaRed: DWORD;
bV4GammaGreen: DWORD;
bV4GammaBlue: DWORD;
end;const CIEXYZ = extern struct {
ciexyzX: i32,
ciexyzY: i32,
ciexyzZ: i32,
};
const CIEXYZTRIPLE = extern struct {
ciexyzRed: CIEXYZ,
ciexyzGreen: CIEXYZ,
ciexyzBlue: CIEXYZ,
};
const BITMAPV4HEADER = extern struct {
bV4Size: u32,
bV4Width: i32,
bV4Height: i32,
bV4Planes: u16,
bV4BitCount: u16,
bV4V4Compression: u32,
bV4SizeImage: u32,
bV4XPelsPerMeter: i32,
bV4YPelsPerMeter: i32,
bV4ClrUsed: u32,
bV4ClrImportant: u32,
bV4RedMask: u32,
bV4GreenMask: u32,
bV4BlueMask: u32,
bV4AlphaMask: u32,
bV4CSType: u32,
bV4Endpoints: CIEXYZTRIPLE,
bV4GammaRed: u32,
bV4GammaGreen: u32,
bV4GammaBlue: u32,
};type
CIEXYZ {.bycopy.} = object
ciexyzX: int32
ciexyzY: int32
ciexyzZ: int32
CIEXYZTRIPLE {.bycopy.} = object
ciexyzRed: CIEXYZ
ciexyzGreen: CIEXYZ
ciexyzBlue: CIEXYZ
BITMAPV4HEADER {.bycopy.} = object
bV4Size: uint32
bV4Width: int32
bV4Height: int32
bV4Planes: uint16
bV4BitCount: uint16
bV4V4Compression: uint32
bV4SizeImage: uint32
bV4XPelsPerMeter: int32
bV4YPelsPerMeter: int32
bV4ClrUsed: uint32
bV4ClrImportant: uint32
bV4RedMask: uint32
bV4GreenMask: uint32
bV4BlueMask: uint32
bV4AlphaMask: uint32
bV4CSType: uint32
bV4Endpoints: CIEXYZTRIPLE
bV4GammaRed: uint32
bV4GammaGreen: uint32
bV4GammaBlue: uint32struct CIEXYZ
{
int ciexyzX;
int ciexyzY;
int ciexyzZ;
}
struct CIEXYZTRIPLE
{
CIEXYZ ciexyzRed;
CIEXYZ ciexyzGreen;
CIEXYZ ciexyzBlue;
}
struct BITMAPV4HEADER
{
uint bV4Size;
int bV4Width;
int bV4Height;
ushort bV4Planes;
ushort bV4BitCount;
uint bV4V4Compression;
uint bV4SizeImage;
int bV4XPelsPerMeter;
int bV4YPelsPerMeter;
uint bV4ClrUsed;
uint bV4ClrImportant;
uint bV4RedMask;
uint bV4GreenMask;
uint bV4BlueMask;
uint bV4AlphaMask;
uint bV4CSType;
CIEXYZTRIPLE bV4Endpoints;
uint bV4GammaRed;
uint bV4GammaGreen;
uint bV4GammaBlue;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BITMAPV4HEADER サイズ: 108 バイト(x64)
dim st, 27 ; 4byte整数×27(構造体サイズ 108 / 4 切り上げ)
; bV4Size : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; bV4Width : INT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; bV4Height : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; bV4Planes : WORD (+12, 2byte) wpoke st,12,値 / 値 = wpeek(st,12)
; bV4BitCount : WORD (+14, 2byte) wpoke st,14,値 / 値 = wpeek(st,14)
; bV4V4Compression : BI_COMPRESSION (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; bV4SizeImage : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; bV4XPelsPerMeter : INT (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; bV4YPelsPerMeter : INT (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; bV4ClrUsed : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; bV4ClrImportant : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; bV4RedMask : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; bV4GreenMask : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; bV4BlueMask : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; bV4AlphaMask : DWORD (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; bV4CSType : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; bV4Endpoints : CIEXYZTRIPLE (+60, 36byte) varptr(st)+60 を基点に操作(36byte:入れ子/配列)
; bV4GammaRed : DWORD (+96, 4byte) st.24 = 値 / 値 = st.24 (lpoke/lpeek も可)
; bV4GammaGreen : DWORD (+100, 4byte) st.25 = 値 / 値 = st.25 (lpoke/lpeek も可)
; bV4GammaBlue : DWORD (+104, 4byte) st.26 = 値 / 値 = st.26 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global CIEXYZ
#field int ciexyzX
#field int ciexyzY
#field int ciexyzZ
#endstruct
#defstruct global CIEXYZTRIPLE
#field CIEXYZ ciexyzRed
#field CIEXYZ ciexyzGreen
#field CIEXYZ ciexyzBlue
#endstruct
#defstruct global BITMAPV4HEADER
#field int bV4Size
#field int bV4Width
#field int bV4Height
#field short bV4Planes
#field short bV4BitCount
#field int bV4V4Compression
#field int bV4SizeImage
#field int bV4XPelsPerMeter
#field int bV4YPelsPerMeter
#field int bV4ClrUsed
#field int bV4ClrImportant
#field int bV4RedMask
#field int bV4GreenMask
#field int bV4BlueMask
#field int bV4AlphaMask
#field int bV4CSType
#field CIEXYZTRIPLE bV4Endpoints
#field int bV4GammaRed
#field int bV4GammaGreen
#field int bV4GammaBlue
#endstruct
stdim st, BITMAPV4HEADER ; NSTRUCT 変数を確保
st->bV4Size = 100
mes "bV4Size=" + st->bV4Size