$B$3$N>O$NL\
$BA0JG(B:2.1 $B$O$8$a$K$K$b$I$k(B
$B

2.2 $B4pK\35G0(B

2.2.1 $B:BI8J?LL!?E@!?D9J}7A(B

$B%G%#%9%W%l%$%W%j%_%F%#%V$G:BI8CM$O2

$BE@(B (Point) $B$O!":BI87O>e$G$N0LCV$rI=$o$9$?$a$N4pK\E*$J35G0$G$"$j!"(B $B0J(B $B2<$N9=B$BN$K$h$jDj5A$5$l$k(B($B4pK\%G!<%?%?%$%W$K4X$7$F$O(B $B!V(B$BBh(B1$BJT(B $BBh(B1$B>O(B $B4pK\%G!<%?%?%$%W(B$B!W$r;2>H$N;v(B)$B!#(B

    /* $BE@(B */
    typedef struct Point {
        H   x;      /* $B?eJ?:BI8CM(B */
        H   y;      /* $B?bD>:BI8CM(B */
    } PNT;

$B$^$?!"D9J}7A(B (Rectangle) $B$O!"(B $B:BI87O>e$G$NNN0h$rI=$o$9$?$a$N=EMW$J35G0$G$"$j!"0J2<$N9=B$BN$K$h$jDj5A$5$l$k!#(B

    /* $BD9J}7A(B */
    typedef union Rectangle {
        struct {
            H   left;       /* $B:8$N:BI8CM(B */
            H   top;        /* $B>e$N:BI8CM(B */
            H   right;      /* $B1&$N:BI8CM(B */
            H   bottom;     /* $B2<$N:BI8CM(B */
        } c;
        struct {
            PNT lefttop;    /* $B:8>e$NE@(B */
            PNT rightbot;   /* $B1&2<$NE@(B */
        } p;
    } RECT;

$B$3$3$G

$B$^$?!"D9J}7A$N=89g$rI=8=$9$k$?$a$ND9J}7A$N%j%9%H(B(RectangleList) $B$O0J2<$N$h$&$KDj5A$5$l$k!#%j%9%H$N:G8e$NMWAG$N(B next $B$O(B NULL(0) $B$H$J$k!#(B

    /* $BD9J}7A%j%9%H(B */
    typedef struct RectangleList {
        RectangleList   *next;      /* $B

    $B%G%#%9%W%l%$%W%j%_%F%#%V$Ge$N%$%a!<%8$KBP1~IU$1$i$l$k!#(B

2.2.2 $B%S%C%H%^%C%W(B

$B%S%C%H%^%C%W(B

$B%S%C%H%^%C%W$O!"(B $B?^7A$dJ8;zEy$NI=<(%$%a!<%8$rBg$-$5!"(B $B$*$h$S?'$r;}$C$?E@(B8$B%T%/%;%k(B)$B$N=89g$H$7$FI=$o$7!"$=$NE@$r%a%b%j>e$N(B1$B%S%C%H!"$"$k$$$OJ#?t%S%C%H$K0lBP0lBP1~$5$;$F!"

$B%S%C%H%^%C%W>e$G$O0J2<$K<($9?^$N$h$&$K!"(B1$B$D$N%T%/%;%k$,@0?t:BI87O>e$N(B1$B$D$NE@$KBP1~$E$1$i$l$k!#(B

$B:BI87O$H%T%/%;%k(B
$B?^(B 17 : $B:BI87O$H%T%/%;%k(B
$B%S%C%H%^%C%W>e$ND9J}7A(B
$B?^(B 18 : $B%S%C%H%^%C%W>e$ND9J}7A(B

$B%S%C%H%^%C%W$O%$%a!<%8$rI=8=$9$k$?$a$N%G!<%?9=B$$G$"$k$,!"]$H$9$k%G%P%$%9$NB0@-$H$7$FDj5A$5$l$k$3$H$K$J$k!#(B

$B%S%C%H%^%C%W$N9=B$(B

$B%S%C%H%^%C%W$O!"4pK\E*$KO"B3$7$?(B1$Be$N%S%C%H$HI=<(>e$N%T%/%;%k$H$NBP1~IU$1$O!"0J2<$N$h$&$KDj5A$5$l$k!#(B

$B%S%C%H%^%C%W$O0J2<$N9=B$BN$K$h$jDj5A$5$l$k!#(B

/* $B%S%C%H%^%C%W(B */
#define PLANES      (1)       /* $B%@%_!<(B */
typedef struct Bitmap {
    UW    planes;             /* $B%W%l!<%s$N?t(B */
    UH    pixbits;            /* ($B6-3&!?M-8z(B)$B%T%/%;%k%S%C%H?t(B */
    UH    rowbytes;           /* $B%W%l!<%s$N2#I}$N%P%$%H?t(B($B6v?t(B) */
    RECT  bounds;             /* $B6-3&D9J}7A(B($B:BI8Dj5A(B) */
    UB    *baseaddr[PLANES];  /* $B3+;O%"%I%l%9(B(planes $B8D$NG[Ns(B) */
} BMP;

planes $B$O%W%l!<%s?t$rI=$o$7!"(B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J$k!#(B

/* $B%T%/%;%kCM(B */
typedef     W   PIXVAL;     /* $B%T%/%;%kCM(B */

$B05=L%S%C%H%^%C%W(B

$B05=L%S%C%H%^%C%W$O!"%S%C%H%^%C%W%G!<%?$r05=L$7!"%5%$%:$r>.$5$/$7$?$b$N$G!"

$B05=L%S%C%H%^%C%W$O!"0J2<$N$h$&$KDj5A$5$l$k!#(B

/* $B05=L%S%C%H%^%C%W(B */
typedef struct CompactedBitmap {
    W       compac;     /* $B%$%a!<%805=LJ}K!(B */
    BMP     bmp;        /* $B%S%C%H%^%C%W(B */
} CBMP;

compac $B$O%$%a!<%8$N05=LJ}K!$r<($9$b$N$G0J2<$N$b$N$H$J$k!#(B

/* $B%$%a!<%805=LJ}K!(B */
enum ImageCompactionMethod {
    NOCOMPAC    = 0,    /* $BHs05=L(B */
    MHCOMPAC    = 1,    /* MH$BId9f(B */
    MR2COMPAC   = 2,    /* MR$BId9f(B (K = 2) */
    MR4COMPAC   = 3     /* MR$BId9f(B (K = 4) */
                        /* = 4$B!A(B  : $BM=Ls(B  */
                        /* < 0 : $B%$%s%W%j%a%s%H$K0MB8$7$?FC

NOCOMPAC ($BHs05=L(B) $B$N>l9g$O!"%S%C%H%^%C%W$NFbMF$ODL>o$N%S%C%H%^%C%W$HA4$/F10l$H$J$k!#05=L$N>l9g$O!"%S%C%H%^%C%W$N(B baseaddr[] $B$G<($5$l$k%G!<%?ItJ,$,05=L$5$l$?7A<0$G3JG<$5$l$k!#(B

  • MH $BId9f(B (MHCOMPAC)$B!'(B

    $B@hF,$N%X%C%@It$K$O0J2<$NFbMF$,F~$j!"%X%C%@It$N8e$K%i%$%sKh$N(BMH$BId9fNs%G!<%?$,JB$V!#(B

    • $BA4BN$N%P%$%H?t(B (UW: 4$B%P%$%H(B)
    • $BA4BN$N%i%$%s?t(B (UH: 2$B%P%$%H(B)
    • $B3F%i%$%sKh$N%G!<%?$X$N%X%C%@It$N@hF,$+$i$N%P%$%H%*%U%;%C%H(B (UW: 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kCM$K$h$kD>@\;XDj!"$*$h$S(B RGB $B$K$h$k@dBP;XDj(B
$B%+%i!<%^%C%W$N@_Dj!'(B
RGB $B$K$h$k@dBP;XDj(B

$B%+%i!<;XDj$O0J2<$KDj5A$5$l$k9=B$BN$K$h$j9T$J$o$l$k!#(B

/* $B%+%i!


$B%+%i!<;XDj(B
$B?^(B 23 : $B%+%i!<;XDj(B
  • $BF)L@!?ITF)L@$O!"(B $BIA2h%+%i!<;XDj$K$N$_;HMQ$5$l!"F)L@$r;XDj$7$?>l9g$O$B%+%i!
    crep$B!a(B0
    $BD>@\%T%/%;%kCM$r<($9!#(B
    crep$B!a(B1
    $B@V!?NP!?@D$N3F?'$N51EY$r(B0$B!A(B255$B$N@55,2=$5$l$?%l%s%8$G<($9!#$9$J$o$A!"(B0$B$,(B0$B!s!"(B255$B$,(B100$B!s$r<($9!#(B
            XXXX RRRRRRRR GGGGGGGG BBBBBBBB
                   $B@V(B(8)    $BNP(B(8)    $B@D(B(8)
    
    crep$B!a(B2$B!A(B7 $BM=Ls(B

$B

crep$B!a(B0$B!'%T%/%;%kCM;XDj(B

COLOR $B$N2<0L(BN$B%S%C%H$r$=$N$^$^%T%/%;%kCM$H$7!">e0L%S%C%H$OL5;k$9$k!#$3$3$G(BN$B$O!"BP>]%S%C%H%^%C%W$N?<$5$r0UL#$9$k!#(B

crep$B!d(B0$B!'@dBP%+%i!<;XDj(B

COLOR $B$G;XDj$7$?%+%i!<$K:G$b6a$$%+%i!<$N%T%/%;%kCM$H$9$k!#%+%i!<%^%C%WJ}<0$N>l9g$O%+%i!<%^%C%W$N8!:w$r9T$J$$!";XDj$7$?(B COLOR $B$K:G$b6a$$?'$N%(%s%H%j$N%$%s%G%C%/%9$r%T%/%;%kCM$H$9$k!#(B

$B8GDj%+%i!l9g$O!"(BCOLOR $B$G$NI8=`(BRGB$BI=5-$K:G$b6a$$?'$N%G%P%$%98GM-$N(BRGB$BI=5-$KJQ49$7$?CM$r%T%/%;%kCM$H$9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V$KEPO?$5$l$F$$$k%G%P%$%9$N$_$,;XDj2DG=$G$"$k!#(B

$B%G%#%9%W%l%$%W%j%_%F%#%V$G$+$J$i$:%5%]!<%H$7$F$$$k%G%P%$%9$H$7$F0J2<$N$b$N$,$"$2$i$k!#(B

  • "SCREEN"
  • "MSGPNL"

$BIA2hBP>]%G%P%$%9$K$O!"0J2<$N%G%P%$%98GM-$N>pJs(B($B;EMM(B)$B$,Dj5A$5$l$F$*$j!"$3$l$O%S%C%H%^%C%W>e$KIA2h$7$?%$%a!<%8$N6qBNE*$JI=8=$NDj5A$r0UL#$9$k!#(B

    typedef struct {
        H   attr;       /* $B%G%P%$%9$NB0@-(B */
        H   planes;     /* $B%W%l!<%s?t(B */
        H   pixbits;    /* $B%T%/%;%k%S%C%H?t(B($B6-3&!?M-8z(B) */
        H   hpixels;    /* $B2#$N%T%/%;%k?t(B */
        H   vpixels;    /* $B=D$N%T%/%;%k?t(B */
        H   hres;       /* $B2#$N2rA|EY(B */
        H   vres;       /* $B=D$N2rA|EY(B */
        H   color[4];   /* $B%+%i!<>pJs(B */
        H   resv[6];    /* $BM=Ls(B */
    } DEV_SPEC;
  • attr $B$O!"%G%P%$%9$NB0@-$r<($90J2<$NFbMF$G$"$k!#(B
        0LMX XXXX XXXX PRRR
    
    L:
    0$B!a$3$N%G%P%$%9$KBP$7$F@8@.$7$?%G%P%$%9IA2h4D6-%l%3!<%I$O%m%C%/$NBP>]$H$5$l$J$$!#(B
    1$B!a(B $B$3$N%G%P%$%9$KBP$7$F@8@.$7$?%G%P%$%9IA2h4D6-%l%3!<%I$O%m%C%/$NBP>]$H$5$l$k!#(B
    M:
    0$B!a(B $B8GM-%$%a!<%8NN0h(B($B%S%C%H%^%C%W(B) $B$O;}$C$F$$$J$$(B($B%G%P%$%9IA2h4D6-$O@[email protected](B)$B!#(B
    1$B!a(B $B8GM-%$%a!<%8NN0h(B($B%S%C%H%^%C%W(B) $B$r;}$C$F$$$k(B($B%G%P%$%9IA2h4D6-$r@[email protected]=(B)$B!#(B
    P:
    0$B!a(B $B%+%i!<%^%C%WL5(B($BD>@\;XDj(B)
    1$B!a(B $B%+%i!<%^%C%WM-(B($B%^%C%W%(%s%H%j?t$O%W%l!<%s?t!_%T%/%;%k%S%C%H?t$G7h$^$k(B)
    R:
    0$B!a(B $BGr9u(B
    1$B!a(B RGB$B%+%i!<(B
    2$B!a(B CMY $B%+%i!<(B
    3$B!A(B $B$=$NB>(B
    X:
    $BM=Ls(B
  • planes $B$O!"%G%P%$%9$KE,MQ$5$l$k%S%C%H%^%C%W$N%W%l!<%s?t$r<($7!"(Bpixbits $B$O!"6-3&!?M-8z%T%/%;%k%S%C%H?t$r<($9$b$N$G!"(BBITMAP $B$NDj5A$HF1$80UL#$r;}$D!#$J$*!"(B planes $B!c(B0$B$N>l9g$OFChpixels $B$H(B vpixels $B$O!"%G%P%$%9$KE,MQ$5$l$k%S%C%H%^%C%W$N2#$H=D$N%T%/%;%k?t$r<($9!#Bg$-$5$,5,Dj$5$l$F$$$J$$>l9g$O(B0$B$H$J$k!#(B
  • hres $B$H(B vres $B$O!"%G%P%$%9$Kl9g$N%S%C%H%^%C%W$N2#$H=D$N2rA|EY$r<($7!"(B1$B%;%s%A%a!<%H%k$^$?$O(B1$B%$%s%AEv$?$j$N%T%/%;%k?t$G<($5$l$k!#%$%s%A$N>l9g$O!"Ii?t$GI=$o$5$l$k!#(B $B2rA|EY$,5,Dj$5$l$F$$$J$$>l9g$O(B0$B$H$J$k!#(B
  • color[] $B$O!"%+%i!<>pJs$G$"$j!"(Battr $B$G;XDj$5$l$k%+%i!
    R = ($BGr9u(B)$B$N>l9g(B
    color[0] $BGr9u$N3,D4%S%C%H?t$r<($9!#(B
    color[1]$B!A(B $BL$;HMQ(B(0)
    R = 1(RGB)$B$N>l9g(B
    color[0] $B@V$N3,D4%S%C%H?t$H$=$N0LCV$r<($9!#(B
    color[1] $BNP$N3,D4%S%C%H?t$H$=$N0LCV$r<($9!#(B
    color[2] $B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G$0UNN0h(B */
#define NX      1   /* $B%@%_!<(B */
#define NS      1   /* $B%@%_!<(B */

struct HorizontalRegion {
    UH  nx;         /* $B?eJ?:BI8$N?t(B($B6v?t(B) */
    UH  x[NX];      /* $B?eJ?:BI8$NCM(B(nx $B8D$NMWAG$GCM$N>.$5$$=g(B) */
};
typedef HorizontalRegion HRGN;  /* $B?eJ?NN0h(B */

struct GenericRegion {
    RECT    r;      /* $BG$0UNN0hA4BN$r0O$`:G>.$ND9J}7A(B($BAjBP:BI87O(B) */
    UW      ns;     /* $B?bD>6h4V?t(B */
    struct {
        UH      y;      /* $B6h4V$N3+;O?bD>:BI8CM(B */
        HRGN    *hp;    /* $B6h4V$N?eJ?NN0h$X$N%]%$%s%?(B */
    } s[NS];
};

typedef GenericRegion   GRGN;   /* $BG$0UNN0h(B */

$B?eJ?NN0h$O(B1$B$D$N?bD>:BI8CM(B($B%i%9%?!<(B)$B$KBP1~$9$k?eJ?:BI8$NNN0h$r;XDj$9$k$b$N$G$"$j!"(Bnx $B$O!"?eJ?:BI8CM$N8D?t$r<($7!"(Bx[0] $B!A(B x[nx-1] $B$O!"(B $B?eJ?:BI8CM$r>.$5$$=g$KJB$Y$?$b$N$G$"$k!#?eJ?:BI8CM$O!"G$0UNN0hA4BN$r0O$`:G>.$ND9J}7A$N(B r.c.left $B$NCM$r(B0$B$H$9$kHsIi$NCM$G<($5$l$k!#(B

$B?eJ?:BI8CM$O(B2$B$D(B1$BAH$G$"$j!"Bh0l$N?eJ?:BI8CM(B($B>.$5$$CM(B)$B$+$i!"BhFs$N?eJ?:BI8CM(B($BBg$-$$CM(B)$B!](B1$B$N?eJ?:BI8CM$^$G$,!"BP>]NN0h$H$J$k!#(B($BBh0l$NCM$O4^$^$l$k$,!"BhFs$NCM$O4^$^$l$J$$!'(Bhalf-open)$B!#(B

$BF10l$N?eJ?:BI8CM$,(B2$B$D0J>e4^$^$l$F$$$?>l9g!"6v?t2s$N$H$-$K$O$=$N:BI8CM$OB8:_$7$J$$$b$N$H8+$J$5$l!"4q?t2s$N$H$-$K$O(B1$B$D$N$_B8:_$7$F$$$k$b$N$H8+$J$9!#(Bnx $B$,6v?t$G$J$$>l9g$O!":G8e$N:BI8CM$OL5;k$5$l$k!#(B

$BF10l$N?eJ?NN0h$r;}$DO"B3$7$??bD>:BI8$NNN0h$r(B($B?bD>(B)$B6h4V$H8F$S!"G$0UNN0h$O!"$$$/$D$+$N(B($B?bD>(B)$B6h4V$K$h$jDj5A$5$l$k!#(Bns $B$O6h4V$N?t$r<($7!"(B ns$B!a(B0$B$N>l9g$O!"G$0UNN0h$OD9J}7A(B r $B$KEy$7$$$3$H$r0UL#$9$k!#(B

s[N].y $B$O6h4V(B N $B$N3+;O?bD>:BI8CM$r<($7!"$=$N6h4V$N=*N;?bD>:BI80LCV$O!"(Bs[N+1].y$B!](B1$B!"$^$?$O(B r.c.bottom$B!](B1($B:G8e$N6h4V$N;~(B)$B$H$J$k!#(B

s[N]. hp $B$O6h4V(B N $B$KBP1~$9$k?eJ?NN0h$X$N%]%$%s%?$r<($9!#(Bs[N].hp$B!a(BNULL$B$N;~$O!"$=$N6h4V$O6u$G$"$k$3$H$r0UL#$9$k!#(B

        r = (0, 0, 17, 15)
        ns = 11
        s[0].y = 0    s[0].hp = &(2, 5, 12)
        s[1].y = 1    s[1].hp = &(4, 3, 8,  9, 14)
        s[2].y = 2    s[2].hp = &(4, 1, 7, 10, 16)
        s[3].y = 3    s[3].hp = &(4, 0, 6, 11, 17)
        s[4].y = 4    s[4].hp = &(4, 0, 5, 12, 17)
        s[5].y = 5    s[5].hp = &(4, 0, 4, 13, 17)
        s[6].y = 10   s[6].hp = &(4, 0, 5, 12, 17)
        s[7].y = 11   s[7].hp = &(4, 0, 6, 11, 17)
        s[8].y = 12   s[8].hp = &(4, 1, 7, 10, 16)
        s[9].y = 13   s[9].hp = &(4, 3, 8,  9, 14)
        s[10].y = 14  s[10].hp = &(2, 5, 12)
$BG$0UNN0h$NNc!](B1
$B?^(B 24 : $BG$0UNN0h$NNc!](B1
        r = (x0, y0, x3, y3)
        ns = 3
        s[0].y = y0 s[0].hp = &(2, x0, x2)
        s[1].y = y1 s[1].hp = NULL
        s[2].y = y2 s[2].hp = &(2, x1, x3)
$BG$0UNN0h$NNc!](B2
$B?^(B 25 : $BG$0UNN0h$NNc!](B2
        r = (x0, y0, x4, y4)
        ns = 4
        s[0].y = y0 s[0].hp = &(2, x0, x3)
        s[1].y = y1 s[1].hp = &(2, x0, x4)
        s[2].y = y2 s[2].hp = &(2, x1, x4)
        s[3].y = y3 s[3].hp = &(2, x1, x2)
$BG$0UNN0h$NNc!](B3
$B?^(B 26 : $BG$0UNN0h$NNc!](B3
$B%/%j%C%T%s%0NN0h(B
$B?^(B 27 : $B%/%j%C%T%s%0NN0h(B

$BIA2h%b!<%I(B

$B$C$F9T$J$o$l$k!#(B

$BIA2h%b!<%I$O!"0J2<$N7A<0$N(B32$B%S%C%H%G!<%?$G;XDj$5$l$k!#(B

    0000 0000 0000 0000 0000  PPCF MMMM MMMM

        M: $BIA2h1i;;%b!<%I;XDj(B
        F: $B%S%C%H%^%C%W7A<0JQ49;XDj(B
        C: $B%+%i!

$BIA2h1i;;%b!<%I$O!"IA2h$NBP>]$H$9$k%T%/%;%k$K!"=q$-9~$`$Y$-%T%/%;%kCM(B(src)$B$H(B $B4{$K8=:_$N%T%/%;%kCM(B(dest)$B$H!"IA2h8e$N%T%/%;%kCM(B(result)$B$H$N4X78$r5,Dj$9$k$b$N$G$"$j!"0J2<$K<($9$b$N$,MQ0U$5$l$F$$$k!#(B

/* $BIA2h1i;;%b!<%I(B */
enum DrawingCopyMode {
    /* $B%T%/%;%kCM$N%S%C%HC10L$NO@M}1i;;(B */
    G_STORE = 0,    /* (src)        -->  (result) */
    G_XOR   = 1,    /* (src) XOR (dest) -->  (result) */
    G_OR    = 2,    /* (src) OR  (dest) -->  (result) */
    G_AND   = 3,    /* (src) AND (dest) -->  (result) */
    G_CPYN  = 4,    /* NOT (src)        -->  (result) */
    G_XORN  = 5,    /* NOT (src) XOR (dest) -->  (result) */
    G_ORN   = 6,    /* NOT (src) OR  (dest) -->  (result) */
    G_ANDN  = 7,    /* NOT (src) AND (dest) -->  (result) */
    G_NOP   = 8     /* (dest)       -->  (result) */
};

$B%S%C%H%^%C%W7A<0JQ49;XDj$O!"%=!<%9$H%G%#%9%F%#%M!<%7%g%s$N%S%C%H%^%C%W$N7A<0(B($B%W%l!<%s?t(B $B!"(B $B%T%/%;%k%S%C%H?t(B)$B$,0[$J$k>l9g$O0J2<$K<($9JQ49$r9T$J$&$3$H$r;XDj$9$k!#(B

  • $BJQ498e$NAPJ}$N2<0L(BN$B%S%C%H$N%T%/%;%kCM$,Ey$7$/$J$k$h$&$KJQ49$9$k!#$3$3$G!"(BN$B$O!"%=!<%9$H%G%#%9%F%#%M!<%7%g%s$N(B depth $B$N:G>.CM$r0UL#$9$k!#(B
  • $B%S%C%H%^%C%W$NA`:n$r9T$&4X?t$KE,MQ$5$l$k$[$+!"IA2h%Q%?!<%s(B($B8e=R(B)$B$H$7$F;XDj$9$k%S%C%H%^%C%W(B(MPAT)$B$N7A<0JQ49$H$7$F$bE,MQ$5$l$k!#(B
    /* $B%S%C%H%^%C%W7A<0JQ49(B */
    enum BitMapFormConversion {
        G_CVFORM    = 0x0100        /* $B%S%C%H%^%C%W7A<0JQ49(B */
    };
    
$B%+%i!pJs!"%+%i!<%^%C%W(B)$B$,0[$J$k>l9g$O0J2<$K<($9JQ49$r9T$J$&$3$H$r;XDj$9$k!#(B
  • $B$I$A$i$+0lJ}$N%+%i!<>pJs$,@_Dj$5$l$F$$$J$$>l9g$OJQ49$5$l$J$$!#(B
  • $B%=!<%9$N%T%/%;%kCM$r@dBP%+%i!<$KJQ49$7!"$=$N@dBP%+%i!<$K:G$b6a$$@dBP%+%i!<$KBP1~$9$k%G%#%9%F%#%M!<%7%g%s$N%T%/%;%kCM$KJQ49$9$k!#(B
  • $B%S%C%H%^%C%W$NA`:n$r9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<%s%?%$%W(B($B!a(B0) */
        UH      hsize;      /* $B%Q%?!<%s$N2#%5%$%:(B($B%T%/%;%k?t(B) */
        UH      vsize;      /* $B%Q%?!<%s$N=D%5%$%:(B($B%T%/%;%k?t(B) */
        COLOR   fgcol;      /* $BA07J?'(B */
        COLOR   bgcol;      /* $BGX7J?'(B */
        UB      *mask;      /* $B%Q%?!<%s%^%9%/%G!<%?$X$N%]%$%s%?(B */
    } spat;
    struct {
        PatKind kind;       /* $B%Q%?!<%s%?%$%W(B($B!a(B1) */
        UH      hsize;      /* $B%Q%?!<%s$N2#%5%$%:(B($B%T%/%;%k?t(B) */
        UH      vsize;      /* $B%Q%?!<%s$N=D%5%$%:(B($B%T%/%;%k?t(B) */
        UB      *mask;      /* $B%Q%?!<%s%^%9%/%G!<%?$X$N%]%$%s%?(B */
        BMP     *bmap;      /* $B%S%C%H%^%C%W$X$N%]%$%s%?(B */
    } mpat;
    struct {
        PatKind kind;       /* $B%Q%?!<%s%?%$%W(B($B!a(B2) */
        UH      hsize;      /* $B%Q%?!<%s$N2#%5%$%:(B($B%T%/%;%k?t(B) */
        UH      vsize;      /* $B%Q%?!<%s$N=D%5%$%:(B($B%T%/%;%k?t(B) */
        UB      *pat;       /* $BFbIt%Q%?!<%s%$%a!<%8$X$N%]%$%s%?(B */
    } ipat;
}

typedef  Pattern    PAT     /* $BIA2h%Q%?!<%s(B */
kind$B!'(B
$B%Q%?!<%s$N%?%$%W$r<($90J2<$NCM$G$"$k!#(B
$B!a(B0 $B!'(B spat $B%?%$%W(B
$B!a(B1 $B!'(B mpat $B%?%$%W(B
$B!a(B2 $B!'(B ipat $B%?%$%W(B
$B!a(B3$B!A!'(B $BM=Ls(B ($B;XDj$7$?>l9g$O!"(BEG_NOSPT $B$N%(%i!<$H$J$k(B)
hsize / vsize $B!'(B
hsize $B$O!"%Q%?!<%s$N2#%5%$%:!"(Bvsize $B$O%Q%?!<%s$N=D%5%$%:$r!"%T%/%;%k?t$GI=$o$7$?$b$N$G$"$k!#(B
fgcol / bgcol$B!'(B
fgcol $B$O%Q%?!<%s%^%9%/%G!<%?$N(B"1"$B$NItJ,$N?'$r;XDj$7!"(Bbgcol $B$O(B"0"$B$NItJ,$N?'$r;XDj$9$k!#(Bfgcol $B$*$h$S(B bgcol $B!c(B0$B$N>l9g$O!"(B $B$=$l$>$lF)L@$r<($9!#(B
mask$B!'(B
$B0J2<$N7A<0$G%Q%?!<%s%^%9%/%$%a!<%8$r<($9!#B($A!"%Q%?!<%s%5%$%:$G<($5$l$kD9J}7A$,F~$k:G>.$N%S%C%H%^%C%W%G!<%?(B($B%T%/%;%k%S%C%H?t!a(B1)$B$G$"$k!#(B
  • mpat $B7A<0$N>l9g!"(B"0"$B$NItJ,$OIA2h$r9T$J$o$:!"F)L@$H$9$k$3$H$r0UL#$9$k!#(B
  • $B$^$?!"(Bmask$B!a(B NULL $B$N>l9g$O!"F)L@ItJ,$OB8:_$7$J$$$3$H$r0UL#$9$k!#(B
  • spat $B7A<0$N>l9g$O!"(BNULL $B$G$"$C$F$O$$$1$J$$!#(B
$B%Q%?!<%s%^%9%/$N9=@.(B
$B?^(B 29 : $B%Q%?!<%s%^%9%/$N9=@.(B

$B$J$*!"0J2<$N%Q%?!<%s%^%9%/%G!<%?$,AH9~$_$GMQ0U$5$l$F$$$k$?$a(B mask $B$H$7$F;HMQ$9$k$3$H$,$G$-$k!#(B($B$3$l$i$O!"%Q%?!<%s$N%5%$%:$KL54X78$K;HMQ$G$-$k!#(B)

/* $BI8=`%Q%?!<%s%^%9%/%]%$%s%?(B */
enum StdPatternMask {
    _FILL0  = (1),  /*   0  % $BEI$jDY$7(B */
    _FILL12 = (2),  /*  12.5% $BEI$jDY$7(B */
    _FILL25 = (3),  /*  25  % $BEI$jDY$7(B */
    _FILL50 = (4),  /*  50  % $BEI$jDY$7(B */
    _FILL75 = (5),  /*  75  % $BEI$jDY$7(B */
    _FILL87 = (6),  /*  87.5% $BEI$jDY$7(B */
    _FILL100 = (7)  /* 100  % $BEI$jDY$7(B */
};

#define FILL0       ((B*)_FILL0)
#define FILL12      ((B*)_FILL12)
#define FILL25      ((B*)_FILL25)
#define FILL50      ((B*)_FILL50)
#define FILL75      ((B*)_FILL75)
#define FILL87      ((B*)_FILL87)
#define FILL100     ((B*)_FILL100)
bmap$B!'(B
$B;XDj$7$?%S%C%H%^%C%W$N:8>e6y$N%Q%?!<%s%5%$%:$GDj5A$5$l$?D9J}7AItJ,$r%Q%?!<%s$H$_$J$9!#(B bounds $B$O%Q%?!<%s%5%$%:$h$j>.$5$/$F$O$$$1$J$$!#$^$?!"(Browbytes $B$O%Q%?!<%s%5%$%:0J>e$G$b$h$$!#(B
$B%S%C%H%^%C%W$N7A<0(B($B%W%l!<%s?t!"%T%/%;%k%S%C%H?t(B)$B$,BP>]$H$9$kIA2h4D6-$N%S%C%H%^%C%W7A<0$HF10l$G$J$$>l9g!"IA2h;~$K7A<0JQ49;XDj!"(B($B?'JQ49;XDj(B)$B$r9T$&I,MW$,$"$k!#(B
$B%S%C%H%^%C%W$G$N%Q%?!<%s;XDj(B
$B?^(B 30 : $B%S%C%H%^%C%W$G$N%Q%?!<%s;XDj(B
pat$B!'(B
$BJQ49$7$?FbIt%Q%?!<%s%$%a!<%8$X$N%]%$%s%?$G$"$k!#(B
$BI8=`%Q%?!<%s$H$7$F0J2<$N%Q%?!<%s$,MQ0U$5$l$F$$$k!#(B
/* $BI8=`%Q%?!<%s%]%$%s%?(B */
enum StdPattern {    /* $B$9$Y$F!"A07J?'!'9u!"GX7J?'!'Gr(B */
    _WHITE0   = (1), /*   0  % $BEI$jDY$7(B */
    _BLACK12  = (2), /*  12.5% $B9uEI$jDY$7(B */
    _BLACK25  = (3), /*  25  % $B9uEI$jDY$7(B */
    _BLACK50  = (4), /*  50  % $B9uEI$jDY$7(B */
    _BLACK75  = (5), /*  75  % $B9uEI$jDY$7(B */
    _BLACK87  = (6), /*  87.5% $B9uEI$jDY$7(B */
    _BLACK100 = (7)  /* 100  % $B9uEI$jDY$7(B */
};

#define WHITE0      ((PAT*)_WHITE0)
#define BLACK12     ((PAT*)_BLACK12)
#define BLACK25     ((PAT*)_BLACK25)
#define BLACK50     ((PAT*)_BLACK50)
#define BLACK75     ((PAT*)_BLACK75)
#define BLACK87     ((PAT*)_BLACK87)
#define BLACK100    ((PAT*)_BLACK100)

$B@~B0@-(B

$BD>@~!"8L$dJD$8$??^7A$NOH$NIA2h$N>l9g$O!"IA2h$9$k@~$NB0@-$r0J2<$N7A$G;XDj$9$k$3$H$,$G$-$k!#(B

    0000  0000  0000 0000 TTTT TTTT WWWW WWWW

        W: $B@~I}(B ($B2<0L(B8$B%S%C%HId9fL5$7(B) (0$B!A(B255)
           $B@~$NI}(B($BB@$5(B)$B$r%T%/%;%k?t$G;XDj$7$?$b$N(B

        T: $B@~e0L(B8$B%S%C%HId9fL5$7(B) (0$B!A(B5,255)
           $B0J2<$K<($9@~l9g$O!"(BEG_NOSPT $B$N%(%i!<(B) */
    LN_MASK     = 255   /* $B;XDj%^%9%/(B */
};


/* $B@~B0@-(B */
typedef W       LATTR;  /* $B@~B0@-(B */

$BIA2h4D6-$K$O!"@~%^%9%/%Q%?!<%s$rEPO?$7$F$*$/$3$H$,2DG=$G$"$j!"(BT = 255$B$N>l9g$O!"EPO?$7$F$*$$$?@~%^%9%/%Q%?!<%s$r;HMQ$7$?@~

$B@~%^%9%/%Q%?!<%s$O!"@~I}(B1$B$N;~$KIA2hBP>]$H$J$k%T%/%;%k$r(B"1"$B$N%S%C%H$G<($7$?<~4|E*$J%^%9%/%Q%?!<%s$H$7$FDj5A$5$l!"<~4|$NC10L$H$7$F(B8$B!A(B64$B%T%/%;%k$^$G!"(B8$B%T%/%;%kC10L$G;XDj$9$k$3$H$,$G$-$k!#B($A!"(B1$B!A(B8$B%P%$%H$^$G%P%$%HG[Ns$K$h$jDj5A$5$l$k!#(B

$B$J$*!"B@$$@~I}$GIA2h$7$?>l9g$O!"Dj5A$7$?%Q%?!<%s$O<+A3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N%G%U%)!<%k%H$NJ8;zIA2h%+%i!<$O!"J8;zGX7J?'$OGr(B($B%+%i!<>pJs$r;}$?$J$$>l9g$O(B0)$B!"J8;zA07J?'$O9u(B($B%+%i!<>pJs$r;}$?$J$$>l9g$O:GBg%T%/%;%kCM(B)$B$H$J$k!#(B

$BJ8;zIA2h0LCV!?J}8~(B

$BIA2h4D6-$K$O!"J8;zIA2h$N:]$K;HMQ$5$l$k!"J8;zIA2h0LCV!"J8;zIA2hJ}8~!"J8;z4V3V(B $B$N%G!<%?$,J];}$5$l$F$$$k!#(B

$BJ8;zIA2h0LCV$O!"

$BJ8;zIA2hJ}8~$O!"J8;z$NIA2hJ}8~$r;XDj$9$k$b$N$G$"$j!"0J2<$NCM$GI=$5$l$k!#J8;zIA2hJ}8~$K$h$j!"J8;z%$%a!<%86k7A(B($BJ8;zOH(B)$B$N$I$N0LCV$rJ8;zIA2h0LCV$H$9$k$+$,0l0UE*$K7hDj$5$l$k!#(B

/* $BJ8;zIA2hJ}8~(B */
enum CharacterDirection {
    TORIGHT = 0;  /* $B1&8~$-(B($BJ8;zOH$N%Y!<%9%i%$%s$N:8C<$,IA2h0LCV(B) */
    TOLEFT  = 1;  /* $B:88~$-(B($BJ8;zOH$N%Y!<%9%i%$%s$N1&C<$,IA2h0LCV(B) */
    TOUP    = 2;  /* $B>e8~$-(B($BJ8;zOH$N:8>e$NE@$,IA2h0LCV(B) */
    TODOWN  = 3;  /* $B2<8~$-(B($BJ8;zOH$N:82<$NE@$,IA2h0LCV(B) */
    TOARB   = 4;  /* $BG$0U$N8~$-(B($BJ8;zOH$N:8>e$NE@$,IA2h0LCV(B) */
};

$BJ8;z4V3V$O!"J8;z$HJ8;z$N4V3V$r;XDj$9$k$b$N$G$"$j!"0J2<$N9=B$BN%G!<%?$K$h$j;XDj$5$l$k!#(B

/* $BJ8;z4V3V(B */
struct SignedGap {
    H   dir;        /* $BJ}8~(B */
    UH  gap;        /* $BJ8;z4V3V(B */
}
typedef SignedGap   SGAP;   /* $BJ8;z4V3V(B */

struct CharacterGap {
    SGAP    hgap;       /* $B?eJ?J8;z4V3V(B */
    SGAP    vgap;       /* $B?bD>J8;z4V3V(B */
    SGAP    hspgap;     /* $B6uGr?eJ?4V3V(B */
    SGAP    vspgap;     /* $B6uGr?bD>4V3V(B */
};
typedef CharacterGap    CGAP;   /* $BJ8;z4V3V(B */
$B?eJ?J8;z4V3V(B (hgap)$B!'(B
$B?eJ?J}8~$NJ8;z4V3V(B
$BJ8;zIA2hJ}K!$,!"(BTOUP$B!?(BTODOWN $B$N>l9g$OL5;k$5$l$k!#(B
$B?bD>J8;z4V3V(B (vgap)$B!'(B
$B?bD>J}8~$NJ8;z4V3V(B
$BJ8;zIA2hJ}K!$,!"(BTORIGHT$B!?(BTOLEFT $B$N>l9g$OL5;k$5$l$k!#(B
$B6uGr?eJ?4V3V(B (hspgap)$B!'(B
$B6uGrJ8;z$ND>8e$KDI2C$5$l$k?eJ?J}8~$NJ8;z4V3VJ8;zIA2hJ}K!$,!"(BTOUP$B!?(BTODOWN$B!?(BTOARB $B$N>l9g$OL5;k$5$l$k!#(B
$B6uGr?bD>4V3V(B (vspgap)$B!'(B
$B6uGrJ8;z$N>l9g$KDI2C$5$l$k?bD>J}8~$NJ8;z4V3VJ8;zIA2hJ}K!$,!"(B TORIGHT$B!?(BTOLEFT$B!?(BTOARB $B$N>l9g$OL5;k$5$l$k!#(B

$B?eJ?!??bD>J8;z4V3V$O!"J8;zIA2hJ}8~$,(B TOARB $B0J30$N>l9g$O!"(B $BJ8;zOH$NC<$Hl9g$O!"J8;zIA2h0LCV$H

$B6uGr?eJ?!??bD>4V3V$O!"(B $B6uGrJ8;z(B($B2DJQI}6uGr!"%3!<%I!a(B0x20) $B$ND>8e$KDI2C$5$l$kJ8;z4V3V$r<($7!"6uGrJ8;z(B($B2DJQI}6uGr(B)$B$NI}!"$^$?$O9b$5$rJQ99$9$k$3$H$KAjEv$9$k!#(B

$BJ8;z4V3V;XDj!"(B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$$(B
TORIGHT $B!'(B $BJQ2=$7$J$$(B
TODOWN $B!'(B $BJ8;z9b$5(B+$B?bD>J8;z4V3V(B+[$B6uGr?bD>4V3V(B]$B$@$1A}2C(B
TOUP $B!'(B $BJ8;z9b$5(B+$B?bD>J8;z4V3V(B+[$B6uGr?bD>4V3V(B]$B$@$18:>/(B
TOARB $B!'(B $B?bD>J8;z4V3V$@$1A}2C(B
  • [$B6uGr?eJ?!??bD>4V3V(B]$B$O2DJQI}6uGrJ8;z$rIA2h$7$?>l9g$N$_E,MQ$5$l$k!#(B
$BJ8;zIA2hJ}8~!?J8;z4V3V(B
$B?^(B 33 : $BJ8;zIA2hJ}8~!?J8;z4V3V(B

$BIA2h4D6-$r@8@.$7$?;~E@$G$O!"0J2<$N%G%U%)!<%k%HCM$,@_Dj$5$l$k!#(B

$BJ8;zIA2h0LCV(B:
(0,0)
$BJ8;zIA2hJ}8~(B:
TORIGHT (0)
$BJ8;z4V3V(B:
$B$9$Y$F(B0

$BJ8;z%U%)%s%H(B

$BJ8;zIA2h$G;HMQ$9$kJ8;z%U%)%s%H$O!"0J2<$N%U%)%s%H;XDj%G!<%?$K$h$j;XDj$5$l$k!#$3$N%U%)%s%H;XDj$K$h$j!"%U%)%s%H$N

/* $B%U%)%s%H;XDj(B */
typedef struct ExtendFontSpecifier {
    TC    name[L_FONTFAMNM];    /* $B%U%)%s%H%U%!%_%jL>(B */
    UW    fclass;               /* $B%U%)%s%H%/%i%9(B */
    UW    attr;                 /* $B%U%)%s%HB0@-(B */
    SIZE  size;                 /* $BJ8;z%5%$%:(B */
} FSSPEC;

$B$^$?!";XDj$7$?%U%)%s%H$K4X$9$k0J2<$N>pJs$rF@$k$3$H$,$G$-$k!#(B

/* $B%U%)%s%H>pJs(B */
struct FontInfo {
    UH      height;     /* $B:GBgJ8;z9b(B ($BJ8;z%5%$%:(B) */
    UH      width;      /* $B:GBgJ8;zI}(B */
    UH      base;       /* $B%Y!<%90LCV(B */
    UH      leading;    /* $B%l%G%#%s%0(B */
};

typedef FontInfo    FNTINFO;    /* $B%U%)%s%H>pJs(B */

$BJ8;z$NB@$5!"I}!"e@~!"LV3]$1!"H?E>!">eIU$-!"2

$B$J$*!"(B $B%U%)%s%H$K4X$9$k>\:Y$O!V(B$BBh(B3$B>O(B 3.9 $B%U%)%s%H%^%M!<%8%c(B$B!W$r;2>H$N$3$H!#(B

/* $BJ8;z%3!<%I(B */
typedef UH  TC      /* $BJ8;z%3!<%I(B(1$BJ8;z(B) */

$B$3$N>O$NL\
$BA0JG(B:2.1 $B$O$8$a$K$K$b$I$k(B
$B