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
);
デバイスコンテキストのハンドル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の数値の符号を操作することでイメージを上下左右に反転できる。iUsageの定数
nSrcWidthとnDestWidthの符合が違うとき、コピーされたイメージはX軸回りに反転する。
同様に、nSrcHeightとnDestHeightのときは、Y軸回りに反転する。
dwRopの定数
DIB_PAL_COLORS = 1 DIBカラーは論理パレットによる
DIB_RGB_COLORS = 0 DIBカラーはRGBカラー値
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