blkrotatesize

DOS SVGACC圖形開發庫函式
原型  extern int far blkrotatesize (int ang, RasterBlock far *sourcegfxblk)
輸入 ang - 點陣圖旋轉的角度
sourcegfxblk - 指向源點陣圖的RasterBlock型指針
輸出  如果成功BLKROTATESIZE返回旋轉數組的位元組數,否則返回0
用法 BLKROTATESIZE提取soucegfblk中的點陣圖並且計算調用函式BLKROTATE所需的緩衝區的位元組大小。它也將保證內部庫緩衝區不會溢出。如果經過計算,內部緩衝區會溢出或者目標緩衝區的大小大於65536個位元組,函式將調用失敗。
例子
/*
* Show blkrotate
*/
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include "svgacc.h"
void main(void)
{
int xinc, yinc, x1, y1, x2, y2, i, j, colr, vmode, cntx,
cnty, rot;
RasterBlock *gfxblk, *gfxblk2, *spritebkgnd;
vmode = videomodeget();
if ( !whichvga() || (whichmem() < 512))
exit(1);
if ( !res640() )
exit(1);
xinc = MAXX/10;
yinc = maxy/20;
x1 = maxx/2-xinc;
y1 = maxy/2-yinc;
x2 = maxx/2+xinc;
y2 = maxy/2+yinc;
i = (x2-x1+1)*(y2-y1+1)+4;
gfxblk = (RasterBlock *)malloc(i);
if (!gfxblk) {
restext();
printf("ERROR: Allocating memory for gfxblk: %d
bytes\n",i);
exit(1);
}
colr = 1;
for(i=0;i<=maxx/2;i++) {
DRWCIRCLE(1,colr,maxx/4+i,maxy/2,maxy/5);
colr+=1;
if(colr>15)
colr = 1;
}
DRWBOX(1,0,x1,y1,x2,y2);
blkget(x1,y1,x2,y2,gfxblk);
cntx = (x2-x1) / 2 + x1;
cnty = (y2-y1) / 2 + y1;
fillarea(x1+2,y1+2,0,0);
i = blkrotatesize(45,gfxblk);
if ( !i ) {
restext();
printf("ERROR: rotated sprite will be to large");
exit(1);
}
spritebkgnd = (RasterBlock *)malloc(i);
if (!spritebkgnd) {
restext();
printf("ERROR: Allocating memory for spritebkgnd: %d
bytes\n",i);
exit(1);
}
gfxblk2 = (RasterBlock *)malloc(i);
if (!gfxblk2) {
restext();
printf("ERROR: Allocating memory for gfxblk2: %d
bytes\n",i);
exit(1);
}
blkget(x1,y1,x2,y2,spritebkgnd);
setview(0,64,maxx,maxy);
for(i=0;i<=360;i+=3) {
rot = blkrotate(i,1,gfxblk,gfxblk2);
spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
(spritebkgnd->height)/2,spritebkgnd);
spritegap(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
>height)/2,gfxblk2,spritebkgnd);
sdelay(3);
}
spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
(spritebkgnd->height)/2,spritebkgnd);
blkput(SET,x1,y1,(RasterBlock *)gfxblk);
videomodeset(vmode);
exit(0);
}

相關詞條

相關搜尋

熱門詞條

聯絡我們