📄 offscrn.c
字号:
#define byte unsigned char
#define word unsigned short
#include "metawndo.h" /* master MetaWINDOW include file */
void Waiting(int a);
void offscreen( )
{
void quit(void);
int scrnHeight; // screen height
int scrnWidth; // screen width
rect sR, fR; // temp working rects
grafPort *thePort; // pointer to the screen port(/bitmap)
grafPort *offscrPort; // pointer to the offscreen port(/bitmap)
int GrafixCard = 2;
mwEvent waitEvent;
/* init the system */
// i = InitGraphics( GrafixCard );
GetPort( &thePort ); // get pointer to the screen port
scrnWidth = thePort->portMap->pixWidth;
scrnHeight = thePort->portMap->pixHeight;
// *** create a memory bitmap and port matching the screen ***
// (we could create any size bitmap if we wanted)
offscrPort = CreateBitmap( cMEMORY, scrnWidth, scrnHeight );
if ( offscrPort == 0 ) {
printf("ERROR: Unable to allocate offscreen bitmap\n");
Waiting(150);
return; // abort if CreateBitmap() fails
}
sR = offscrPort->portRect;
PenNormal();
PenColor( LtRed );
BackColor( LtGray );
FillRect( &sR, 30 );
fR = sR;
fR.Xmax--;
fR.Ymax--;
PenColor( LtGreen );
FrameRect( &fR );
PenColor( Blue );
MoveTo( fR.Xmin, fR.Ymin );
LineTo( fR.Xmax, fR.Ymax );
MoveTo( fR.Xmax, fR.Ymin );
LineTo( fR.Xmin, fR.Ymax );
PenColor( Black );
MoveTo( 20,40 );
DrawString("Offscreen bitmaps are easy with CreateBitmap()!");
SetPort( thePort ); // switch back to the screen
PaintRect( &sR ); // fill screen with a different color
// copy the memory bitmap to the screen bitmap
CopyBlit( offscrPort, thePort,
&offscrPort->portRect, &thePort->portRect );
// free the offscreen bitmap
DestroyBitmap( offscrPort );
#ifndef CYCLE
MoveTo( 0,sR.Ymax - 20 );
DrawString( "Press 'x' to exit" );
MoveTo( 0,sR.Ymax - 10 );
DrawString( "any other key to continue" );
while(!KeyEvent(1, &waitEvent));
if((waitEvent.eventChar == 'x') || (waitEvent.eventChar == 'X')) quit();
#else
#ifdef _MNT_
KeyEvent(0, &waitEvent);
if((waitEvent.eventChar == 'x') || (waitEvent.eventChar == 'X')) quit();
#endif
Waiting(150);
#endif
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -