📄 wexbitmp.c
字号:
/* wexbitmp.c - WindML Bitmap example program *//* Copyright 2000 Wind River Systems, Inc. All Rights Reserved *//*modification history--------------------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*//*************************************************************** WindML Example - Bitmaps** This 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 VxWorks taskDelay and taskSpawn. */#include <taskLib.h>/* 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/ugldib.h>#include <ugl/uglinput.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 *//* Control variable to signal when to stop program */UGL_LOCAL volatile UGL_BOOL stopWex;/* Some graphics environment information */UGL_LOCAL int displayHeight, displayWidth;/** 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 };/* Use this to make sure the frame buffer is clear */UGL_LOCAL void ClearScreen(UGL_GC_ID gc) { 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); }/** Wait for the signal to stop. This is the last function* called before freeing resources and de-initializing UGL.*/UGL_LOCAL UGL_EVENT_Q_ID qId = 0;UGL_LOCAL void wexPause(void) { while (!stopWex) { UGL_EVENT event; if ((uglEventGet (qId, &event, sizeof (event), 140) == UGL_STATUS_Q_EMPTY) && event.header.type == UGL_EVENT_TYPE_KEYBOARD) stopWex = UGL_TRUE; } }/** Start the example program. This function and the bitmapStop function* can be invoked from the host shell in order to control the program.*/void wexbitmap (void) { stopWex = 0; printf("To stop wexbitmap, type 'wexbitmapStop'\n"); taskSpawn("tWindMLbmp", 110, 0, 10240, (FUNCPTR)windMLExampleBitmap, 0,1,2,3,4,5,6,7,8,9); }/* Stop the example program; by signalling the wexPause function. */void wexbitmapStop (void) { stopWex = 1; }/* The main function */int windMLExampleBitmap (void) { /* An int for miscellaneous counters,etc. */ int i; /* * The UGL Graphics Context (GC) is an important concept in UGL. * The GC contains data that various UGL functions can use. * If there were no such thing as a GC, most function calls * would require several more parameters to communicate that * information. */ UGL_GC_ID gc; /* * This structure is filled in with data about the frame buffer * by the uglInfo() function. */ UGL_MODE_INFO modeInfo; /* * The device ID is critical to the operation of UGL. It * identifies individual "devices" (display adapter, keyboard, * font engine, etc.) to functions that may be able to work * with more than one device. */ UGL_DEVICE_ID devId; UGL_EVENT_SERVICE_ID eventServiceId; /* * As mentioned in the comments to transparentMask, the mask pattern * is defined as a monochrome bitmap. To create the bitmap
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -