StretchDIBits

機能
DIBを拡大・縮小してコピーする
Declare Function StretchDIBits Lib "gdi32.dll" _
(ByVal hdc As Long, ByVal XDest As Long, ByVal YDest As Long, _
ByVal nDestWidth As Long, ByVal nDestHeight As Long, ByVal XSrc As Long, _
ByVal YSrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, _
lpBits As Any, lpBitsInfo As BITMAPINFO, ByVal iUsage As Long, _
ByVal dwRop As Long) As Long
Declare Function StretchDIBits Lib "gdi32.dll" _
(ByVal hdc As Integer, ByVal XDest As Integer, ByVal YDest As Integer, _
ByVal nDestWidth As Integer, ByVal nDestHeight As Integer, ByVal XSrc As Integer, _
ByVal YSrc As Integer, ByVal nSrcWidth As Integer, ByVal nSrcHeight As Integer, _
lpBits As Integer, lpBitsInfo As BITMAPINFO, ByVal iUsage As Integer, _
ByVal dwRop As Integer) As Integer

int StretchDIBits(
HDC hdc,
int XDest,
int YDest,
int nDestWidth,
int nDestHeight,
int XSrc,
int YSrc,
int nSrcWidth,
int nSrcHeight,
CONST VOID *lpBits,
CONST BITMAPINFO *lpBitsInfo,
UINT iUsage,
DWORD dwRop
);


引数
hdc
デバイスコンテキストのハンドル
XDest
コピー先の矩形の左上隅のX座標
YDest
同、Y座標
nDestWidth
コピー先の矩形の幅
nDestHeight
同、高さ
XSrc
コピー元の矩形の左上隅のX座標
YSrc
同、Y座標
nSrcWidth
コピー元の矩形の幅
nSrcHeight
同、高さ
lpBits
DIBデータを格納したバイト配列
lpBitsInfo
DIBに関するデータを格納したBITMAPINFO構造体
iUsage
BITMAPINFO構造体のbmiColorsの意味を指定する定数
dwRop
ラスタコード
戻り値
正常終了のとき                      コピーしたピクセル行数
エラーのとき                        GDI_ERROR(=&HFFFF)
備考
nSrcWidthとnSrcHeightの数値の符号を操作することでイメージを上下左右に反転できる。
nSrcWidthとnDestWidthの符合が違うとき、コピーされたイメージはX軸回りに反転する。
同様に、nSrcHeightとnDestHeightのときは、Y軸回りに反転する。
iUsageの定数

DIB_PAL_COLORS = 1                  DIBカラーは論理パレットによる
DIB_RGB_COLORS = 0                  DIBカラーはRGBカラー値
dwRopの定数

BLACKNESS = &H42                    0
DSTINVERT = &H550009                Not D
MERGECOPY = &HC000CA                S And P
MERGEPAINT = &HBB0226               Not(S) or D
NOTSRCCOPY = &H330008               Not S
NOTSRCERASE = &H1100A6              Not(S Or D)
PATCOPY = &HF00021                  P
PATINVERT = &H5A0049                P Xor D
PATPAINT = &HFB0A09                 (P Or Not(S)) Or D
SRCAND = &H8800C6                   S And D
SRCCOPY = &HCC0020                  S
SRCERASE = &H440328                 Not(D) And S
SRCINVERT = &H660046                S Xor D
SRCPAINT = &HEE0086                 S Or D
WHITENESS = &HFF0062                1