タイル状に敷き詰めて画面をコピーするモジュール

画面を、タイル状に敷き詰めてコピーするモジュールです。繰り返して gcopy するのではなく、 GDI32 の API を使っています。ですので、 gmode の最初の引数で指定するコピーのモードは反映されません。7番目までの引数は gzoom と全く同じです。

モジュール

#ifndef __MOD_GTILE__
#define __MOD_GTILE__

#include "gdi32.as"
#include "user32.as"
#module modGtile
    // gtile p1, p2, p3, p4, p5, p6, p7, p8, p9
    // p1,p2      : 画面にコピーする時の大きさX,Y(ドット単位)
    // p3=0~(0)  : ウィンドウID
    // p4,p5      : コピー元の左上X,Y座標
    // p6,p7      : コピーする大きさX,Y(ドット単位)
    // p8,p9      : タイルの基点X,Y

    #define global gtile( %1=ginfo_sx, %2=ginfo_sy, %3=0, %4=0, %5=0, %6=-1, %7=-1, %8=ginfo_cx, %9=ginfo_cy ) \
        _gtile %1, %2, %3, %4, %5, %6, %7, %8, %9

    #deffunc _gtile int PasteWidth, int PasteHeight, int CopyWndId, int CopyPosX, int CopyPosY, \
        int _CopyWidth, int _CopyHeight, int TileBaseX, int TileBaseY, \
        local bmscr, local redrawSw, \
        local PasteWndId, local CopyWidth, local CopyHeight, local PastePosX, local PastePosY, \
        local hBitmap, local hMemDC, local hBrush, \
        local rect

        PasteWndId = ginfo_sel
        mref bmscr, 67    // BMSCR 構造体
        redrawSw = wpeek( bmscr, 78 )    // 画面の更新が必要か
        if _CopyWidth  == -1 : CopyWidth  = bmscr( 33 )    // gmode で指定されているサイズを取得
        if _CopyHeight == -1 : CopyHeight = bmscr( 34 )
        PastePosX = ginfo_cx    // 貼り付ける座標はカレント座標
        PastePosY = ginfo_cy

        gsel CopyWndId

        // ブラシを作成
        CreateCompatibleBitmap hDC, CopyWidth, CopyHeight
        hBitmap = stat
        CreateCompatibleDC hDC
        hMemDC = stat
        SelectObject hMemDC, hBitmap
        BitBlt hMemDC, 0, 0, CopyWidth, CopyHeight, hDC, CopyPosX, CopyPosY, $00CC0020    // SRCCOPY
        CreatePatternBrush hBitmap
        hBrush = stat
        DeleteDC hMemDC

        gsel PasteWndId

        rect = PastePosX, PastePosY, PastePosX + PasteWidth, PastePosY + PasteHeight
        SetBrushOrgEx hDC, TileBaseX, TileBaseY, 0
        FillRect hDC, varptr( rect ), hBrush

        if redrawSw : redraw

        DeleteObject hBitmap
        DeleteObject hBrush

        return
    
#global

#endif

サンプル

buffer 1
picload dir_exe + "\\sample\\hgimg3\\testchr.bmp"
screen
gmode , 64, 64
pos 20, 20
gtile ginfo_sx - 40, ginfo_sy - 40, 1, 0, 64

インフォメーション

公開日時
2007年7月24日 午前10時18分17秒
最終更新日時
2007年12月19日 午後10時26分59秒
カテゴリ
HSP