⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wexbitmp.c

📁 2410/vxworks/tornado下的基本实验包括 serial,ramdrv,interrupt,multi-FTP,TCP,UDP-Under the basic experimental
💻 C
📖 第 1 页 / 共 2 页
字号:
/* wexbitmp.c - WindML Bitmap example program *//* Copyright 2000 - 2003 Wind River Systems, Inc. All Rights Reserved *//*modification history--------------------01n,16apr03,jlb  Improved comments and program documentation01m,02apr03,jlb  Correct Diab compile warning and added function headers01l,01apr03,sts  [SPR 86504] Use uglRegistryFind() safely.01k,22feb02,msr  Backward compatibility for input API.01j,29jan02,rbp  Addition of support for Native Unix.01i,05nov01,gav  Fixed misnamed devIds01h,05nov01,gav  Change to new registry01g,05nov01,gav  Change to new registry01f,09oct01,msr  Ported to new UGL_Q_EVENT architecture.01e,19dec00,gav  Entry point identical to filename w/o extension.01d,07nov00,gav  Added comments about the two transparent blit methods used in                 WindML.01c,27oct00,rfm  Added stdio usage01b,26oct00,rfm  Modified entry point01a,25oct00,rfm  Added modification history*//*DESCRIPTIONThis example program demonstrates how to render bitmaps to the screen.  To start the example: -> ld < wexbitmap_ugl.o -> wexbitmap To stop the example: -> wexBitmapStop*//* This is included for a printf prototype. */#include <stdio.h>/* Include the UGL header file to use UGL functions, etc.  *//* The DIB header has defines specific to the use of DIBs. */#include <ugl/ugl.h>#include <ugl/uglos.h>#include <ugl/ugldib.h>#include <ugl/uglinput.h>#include <ioLib.h>/* This is found in the accompanying C file where the image data is also. */extern UGL_DIB imageDib;/* A forward declaration for this program. */int windMLExampleBitmap (void);/* Global variables */int fd;/* Control variable to signal when to stop program */UGL_LOCAL volatile UGL_BOOL stopWex;/* Some graphics environment information */UGL_LOCAL int displayHeight, displayWidth;/* input service */UGL_LOCAL UGL_INPUT_SERVICE_ID inputServiceId;/** In the accompanying C file there is a DIB we will use.  The* colors for that image will be allocated  using this color table* and be available for the DDB/bitmap that will be created later.*/UGL_COLOR imageColorTable[6];/** The color table is where we define the colors we want* to have available.  The format is an array of* ARGB values paired with their allocated uglColor.  As* of this writing, we don't need to worry about Alpha* ("A") values unless we are using video.*/UGL_LOCAL struct _colorStruct    {    UGL_ARGB rgbColor;    UGL_COLOR uglColor;    }colorTable[] =    {    { UGL_MAKE_ARGB(0xff, 0, 0, 0), 0},    /* The color table uses ARGB's */    { UGL_MAKE_ARGB(0xff, 0, 0, 168), 0},  /* (see uglColorAlloc).        */    { UGL_MAKE_ARGB(0xff, 0, 168, 0), 0},  /* Initialize alpha to 255 for */    { UGL_MAKE_ARGB(0xff, 0, 168, 168), 0},/* now (opaque).               */    { UGL_MAKE_RGB(168, 0, 0), 0},         /* UGL_MAKE_RGB takes care of  */    { UGL_MAKE_RGB(168, 0, 168), 0},       /* the alpha for us.           */    { UGL_MAKE_RGB(168, 84, 0), 0},    { UGL_MAKE_RGB(168, 168, 168), 0},    { UGL_MAKE_RGB(84, 84, 84), 0},    { UGL_MAKE_RGB(84, 84, 255), 0},    { UGL_MAKE_RGB(84, 255, 84), 0},    { UGL_MAKE_RGB(84, 255, 255), 0},    { UGL_MAKE_RGB(255, 84, 84), 0},    { UGL_MAKE_RGB(255, 84, 255), 0},    { UGL_MAKE_RGB(255, 255, 84), 0},    { UGL_MAKE_RGB(255, 255, 255), 0}    };#define BLACK			(0)#define BLUE			(1)#define GREEN			(2)#define CYAN			(3)#define RED		    	(4)#define MAGENTA			(5)#define BROWN			(6)#define LIGHTGRAY		(7)#define DARKGRAY		(8)#define LIGHTBLUE		(9)#define LIGHTGREEN		(10)#define LIGHTCYAN		(11)#define LIGHTRED		(12)#define LIGHTMAGENTA	(13)#define YELLOW			(14)#define WHITE			(15)/** This is the data that will be used to create both regular and* transparent DIBs. The DIBs are then used to create "bitmaps"* of their respective types.  It is the bitmap that UGL draws onto* and "blits" (bit block transfers) to other bitmaps and the* screen (i.e. frame buffer).** Solid fills do not need to have a pattern defined, just* pass an UGL_NULL value in the pattern parameter to* revert (it is the default) to solid fills.*/UGL_LOCAL UGL_UINT8 transparentData[] =    {#define O WHITE,#define B BLUE,#define Y LIGHTGRAY,#define G GREEN,    B B B B B B B B B B B O O O O O O O O O B B B B B B B B B B B B    B B B B B B B B B B B O O O O O O O O O B B B B B B B B B B B B    B B B B B B B B B B B B O O O O O O O B B B B B B B B B B B B B    B B B B B B B B B B B B O O O O O O O B B B B B B B B B B B B B    B B B B B B B B B B B B O O O O O O O B B B B B B B B B B B B B    B B B B B B B B B B B B B O O O O O B B B B B B B B B B B B B B    B B B B B B B B B B B B B O O O O O B B B B B B B B B B B B B B    B B B B B B B B B B B B B O O O O O B B B B B B B B B B B B B B    B B B B B B B B B B B B B B O O O B B B B B B B B B B B B B B B    B B B B B B B B B B B B B B O O O B B B B B B B B B B B B B B B    B B B B B B B B B B B B B B O O O B B B B B B B B B B B B B B B    B B B B B B B B B B B B B B B O B B B B B B B B B B B B B B B B    B B B B B B B B B B B B B B B O B B B B B B B B B B B B B B B B    O O O O O O O O O O O O O O O O O O O O O O O B B B B B B B B B    O O O O O O O O O O O O O O O Y B O O O O O O O O O O O O B B B    O O O O O O O O O O O O O O B Y B B B O O O O O O O O O O O O O    O O O O O O O O O O O O O B B Y B B B B B O O O O O O O O O O B    B O O O O O O O O O B B B B B Y Y B B B B B O O O O O O O O O B    B O O O O O O O O B B B B B B Y Y B B B B B B O O O O O O O B B    B O O O O B B B B B B B B B B Y Y B B B B B B B O O O O O O B B    B O O O B B B B B B B B B B B Y Y B B B B B B B B O O O O O B B    B B O B B B B B B B B B B B B Y Y B B B B B B B B B O O O B B B    B B B B B B B B B B B B B B B Y Y B B B B B B B B B B O O B B B    B B B B B B B B B B B B B B Y Y Y Y B B B B B B B B B B O B B B    B B B B B B B B B B B B B B Y Y Y Y B B B B B B B B B B B B B B    B B B B B B B B B B B B B Y Y Y Y Y Y B B B B B B B B B B B B B    B B B B B B B B B B B B B Y Y Y Y Y Y B B B B B B B B B B B B B    B B B B B B B B B B B B B Y Y Y Y Y Y B B B B B B B B B B B B B    B B B B B B B B B B B B B Y Y Y Y Y Y B B B B B B B B B B B B B    B B B B B B B B B B B B B Y Y Y Y Y Y B B B B B B B B B B B B B    G G G G G G G G G G G G G G G G G G G G G G G G G G G G G G G G    G G G G G G G G G G G G G G G G G G G G G G G G G G G G G G G G#undef G#undef Y#undef B#undef O    };/** This is the data which defines the "mask" for a transparent* bitmap.  There is no such thing as a transparent DIB in UGL.* Transparent bitmaps (DDBs) are created from a regular DIB* and a monochrome DIB (MDIB).** The mask is essentially a monochrome bitmap where bits that* are set (1) indicate that the color of the transparent bitmap* image should be displayed.  A clear bit (0) indicates that* the color of the underlying bitmap should be displayed.**/UGL_LOCAL UGL_UINT8 transparentMask[] =    {    0x00, 0x0F, 0xF0, 0x00,    0x00, 0x7F, 0xFE, 0x00,    0x01, 0xFF, 0xFF, 0x80,    0x03, 0xFF, 0xFF, 0xC0,    0x07, 0xFF, 0xFF, 0xE0,    0x0F, 0xFF, 0xFF, 0xF0,    0x1F, 0xFF, 0xFF, 0xF8,    0x3F, 0xFF, 0xFF, 0xFC,    0x3F, 0xFF, 0xFF, 0xFC,    0x7F, 0xFF, 0xFF, 0xFE,    0x7F, 0xFF, 0xFF, 0xFE,    0x7F, 0xFF, 0xFF, 0xFE,    0xFF, 0xFF, 0xFF, 0xFF,    0xFF, 0xFF, 0xFF, 0xFF,    0xFF, 0xFF, 0xFF, 0xFF,    0xFF, 0xFF, 0xFF, 0xFF,    0xFF, 0xFF, 0xFF, 0xFF,    0xFF, 0xFF, 0xFF, 0xFF,    0xFF, 0xFF, 0xFF, 0xFF,    0xFF, 0xFF, 0xFF, 0xFF,    0x7F, 0xFF, 0xFF, 0xFE,    0x7F, 0xFF, 0xFF, 0xFE,    0x7F, 0xFF, 0xFF, 0xFE,    0x3F, 0xFF, 0xFF, 0xFC,    0x3F, 0xFF, 0xFF, 0xFC,    0x1F, 0xFF, 0xFF, 0xF8,    0x0F, 0xFF, 0xFF, 0xF0,    0x07, 0xFF, 0xFF, 0xE0,    0x03, 0xFF, 0xFF, 0xC0,    0x01, 0xFF, 0xFF, 0x80,    0x00, 0x7F, 0xFE, 0x00,    0x00, 0x0F, 0xF0, 0x00    };/**************************************************************************** ClearScreen - clear the screen** This routine clears the screen by drawing a black rectangle to the display.** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL**/UGL_LOCAL void ClearScreen    (    UGL_GC_ID gc                /* Graphics context */    )    {    uglBackgroundColorSet(gc, colorTable [BLACK].uglColor);    uglForegroundColorSet(gc, colorTable [BLACK].uglColor);    uglLineStyleSet(gc, UGL_LINE_STYLE_SOLID);    uglLineWidthSet(gc, 1);    uglRectangle(gc, 0, 0, displayWidth - 1, displayHeight - 1);    }/**************************************************************************** wexPause - wait for input from keyboard** Wait for the signal to stop.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL**/UGL_LOCAL void wexPause (void)    {    char ch;    while (!stopWex)        {        UGL_MSG msg;/*		        if ((uglInputMsgGet (inputServiceId, &msg, 140) == UGL_STATUS_Q_EMPTY) &&            msg.type == MSG_KEYBOARD)            */      while(read(fd, &ch, 1) > 0)      	{       	if((ch == 'q') || (ch == 'Q'))       		{       		printf("You have press %c, the demo will quit.\n", ch);              stopWex = UGL_TRUE;			  break;       		}        }    	}    }#if defined(WINDML_NATIVE) && defined(__unix__)/**************************************************************************** main - start of demo program for unix native simulator** Start the example program.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL*/int main (int argc, char *argv [])    {    windMLExampleBitmap();    return (0);    }#elif defined(WINDML_NATIVE) && defined(_WIN32)/**************************************************************************** WinMain - start of demo program for windows native simulator** Start the example program.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL*/int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,                   LPSTR lpCmdLine, int nShowCmd)    {    uglWin32Parameters(hInstance, hPrevInstance, lpCmdLine, nShowCmd);    windMLExampleBitmap();    return (0);    }#else/**************************************************************************** wexbitmap - demonstrate bitmap operations** This routine demonstrates the manner to create and manipulate bitmaps.  ** The program demonstrates how to:**\ml *\m Initialize WindML*\m Identify the graphics device and input devices*\m Determine the resolution of the display*\m Create a graphics context*\m Allocate colors*\m Create bitmaps; including transparent bitmaps*\m Move bitmaps (blt) from off screen to on screen; including stretching the bitmap during the blt.*\m Drawing to an off screen bitmap and then transferring the modified bitmap to on screen.*\m Releasing all resources and terminating a WindML application.*\me*** RETURNS: ** ERRNO: N/A** SEE ALSO: wexbitmapStop() **/void wexbitmap (void)    {   fd = open("/tyCo/0", 2, 0644);    ioctl (fd, FIOSETOPTIONS, OPT_ECHO | OPT_CRMOD | OPT_TANDEM | \			 OPT_MON_TRAP | OPT_7_BIT | OPT_ABORT );            stopWex = 0;    printf("To stop wexbitmap, type 'wexbitmapStop'\n");    uglOSTaskCreate("tWindMLbmp", (UGL_FPTR)windMLExampleBitmap, 110,                      0, 10240, 0,0,0,0,0);    }#endif/**************************************************************************** wexbitmapStop - stop the bitmap example program*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -