head 1.1; access; symbols; locks poly:1.1; strict; comment @ * @; 1.1 date 2004.06.28.06.15.57; author poly; state Exp; branches; next ; desc @initial @ 1.1 log @Initial revision @ text @ #include "SyStamps.h" #include "BigEasyX.h" #include "BigEasyGrafish.h" //#include <QD/QD.h> //#include <Resources.h> // quickdraw.h OSErr SyLoadStamp(SyStamp *stamp,long picResID) { OSErr result = 0; PicHandle pH; Rect r; GrafPtr oldPort; { char *x = (char *)(&stamp->port); int i; for(i = 0; i < sizeof(GrafPort); i++) *x++ = 0; } pH = (PicHandle)GetResource('PICT',picResID); if(!pH) { result = -1; goto goHome; } r = (**pH).picFrame; OffsetRect(&r,-r.left,-r.top); stamp->port.portRect = r; stamp->port.portBits.bounds = r; stamp->port.portBits.rowBytes = (r.right + 31) / 32 * 4; stamp->port.portBits.baseAddr = NewPtrClear(stamp->port.portBits.rowBytes * stamp->port.portBits.bounds.bottom); stamp->port.visRgn = stamp->port.clipRgn = NewRgn(); RectRgn(stamp->port.visRgn,&stamp->port.portRect); GetPort(&oldPort); SetPort(&stamp->port); GoBW(); DrawPicture(pH,&r); ReleaseResource((Handle)pH); SetPort(oldPort); goHome: return result; } void SyAddSubstamp(SyStamp *stamp,Rect *r,long columns,long rows) { SySubstamp *substamp; substamp = &stamp->substamp[stamp->substampCount++]; substamp->r = *r; substamp->width = r->right - r->left; substamp->height = r->bottom - r->top; substamp->columns = columns; substamp->rows = rows; } void SyDrawStamp(SyStamp *stamp,long substampNumber,long stampNumber,long left,long top) { Rect srcR,dstR; long x,y; SySubstamp *substamp; substamp = &stamp->substamp[substampNumber]; x = stampNumber % substamp->columns; y = stampNumber / substamp->columns; srcR.left = substamp->r.left + x * substamp->width / substamp->columns; srcR.right = substamp->r.left + (x + 1) * substamp->width / substamp->columns; srcR.top = substamp->r.top + y * substamp->height / substamp->rows; srcR.bottom = substamp->r.top + (y + 1) * substamp->height / substamp->rows; dstR = srcR; OffsetRect(&dstR,left - dstR.left,top - dstR.top); CopyBits(&stamp->port.portBits,(BitMap *)&qd.thePort->portBits, &srcR,&dstR,0,0); } @