请输入您要查询的百科知识:

 

词条 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\",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\",i);

exit(1);

}

gfxblk2 = (RasterBlock *)malloc(i);

if (!gfxblk2) {

restext();

printf("ERROR: Allocating memory for gfxblk2: %d

bytes\",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);

}

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2025/1/27 20:24:43