?? leffect.cpp
字號:
#include <lutils.h>
#include <stdlib.h>
extern "C" void cdecl LGMemListCpy(char *d,long len,short *list,char *s);
extern "C" void cdecl LMemCpyMap(char *dest,char *source,long len,void *map);
void lgEScanLine(short x,short y,short len,char *p,short *list);
void lgEScanLine2(short x,short y,short len,char *p,void *map);
static void lgPzoom(short sx,short sy,short ex,short ey,short *bx);
static short LEBX_LIST[1400],LEBY_LIST[1400];
void lgPutMapImage(short x,short y,char *bitmap,COLOR_MAP *map)
{ short len,wid,i,j;
char *p;
if (!bitmap) return; lgetSize(&len,&wid,bitmap);
for (j=0,p=bitmap+4;j<wid;j++,p+=len)
lgEScanLine2(x,y+j,len,p,&map->data[0][0]);
}
void lgPutImage(short x1,short y1,short x2,short y2,char *bitmap)
{ short slen,swid,i,j,len,wid,linemode=0; char *p;
if (x2<x1) { j=x2; x2=x1; x1=j; }
if (y2<y1) { j=y2; y2=y1; y1=j; }
if (!bitmap) return; lgetSize(&slen,&swid,bitmap);
len=x2-x1+1, wid=y2-y1+1; if (len==slen) linemode=1;
lgPzoom(0,0,swid,wid,LEBY_LIST); bitmap+=4;
if (!linemode) lgPzoom(0,0,slen,len,LEBX_LIST);
for (j=0;j<wid;j++) {
p=bitmap+LEBY_LIST[j]*slen;
if (linemode) lScanLine2(x1,y1+j,len,p);
else lgEScanLine(x1,y1+j,len,p,LEBX_LIST);
}
}
void lgEScanLine2(short x,short y,short len,char *p,void *map)
{ uchar p1, p2; int loff; short l1, l2;
register int lptr;
if (y<0||x+len-1<0) return;
if (x<0) { len+=x; p-=x; x=0; }
if (x>=DrawLen||y>=DrawWid) return;
if (x+len-1>=DrawLen) len=DrawLen-x;
lptr=DrawLb[y]+x;
LMemCpyMap(DrawBuf+lptr,p,len,map);
}
void lgEScanLine(short x,short y,short len,char *p,short *list)
{ uchar p1, p2; int loff; short l1, l2;
register int lptr;
if (y<0||x+len-1<0) return;
if (x<0) { len+=x; list-=x; x=0; }
if (x>=DrawLen||y>=DrawWid) return;
if (x+len-1>=DrawLen) len=DrawLen-x;
lptr=DrawLb[y]+x;
LGMemListCpy(DrawBuf+lptr,len,list,p);
}
static void lgPzoom(short sx,short sy,short ex,short ey,short *bx)
{ register short t,distance;
register short x=0,y=0;
short incx,incy,dx,dy;
dx=ex-sx; dy=ey-sy;
if (dx>0) incx=1;
else if (dx==0) incx=0;
else incx=-1;
if (dy>0) incy=1;
else if (dy==0) incy=0;
else incy=-1;
dx=abs(dx);
dy=abs(dy);
if (dx>dy) distance=dx;
else distance=dy;
for (t=0;t<distance+1;t++)
{ bx[sy]=sx;
x+=dx; y+=dy;
if (x>distance) {
x-=distance;
sx+=incx;
}
if (y>distance) {
y-=distance;
sy+=incy;
}
}
}
void lgClearScr(short way)
{ long len=GModeData.LEN,wid=GModeData.WID,size=len*wid,i;
lActiveSurface(NULL);
switch (way)
{case 0: lsetColor(0);
lActiveSurface(NULL);
for (i=0;i<size*12;i++) lpixel(rand()%len,rand()%wid,0);
lsetColor(0); lbar(0,0,DrawLen-1,DrawWid-1);
break;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -