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

📄 uglvdemo.c

📁 2410/vxworks/tornado下的基本实验包括 serial,ramdrv,interrupt,multi-FTP,TCP,UDP-Under the basic experimental
💻 C
📖 第 1 页 / 共 3 页
字号:
    pointerDib.hotSpot.x = 0;    pointerDib.hotSpot.y = 0;    pointerDib.pClut = cursorClut;    pointerDib.clutSize = 2;    pointerDib.pImage = pointerData;    pointerImage = uglCursorBitmapCreate (devId, &pointerDib);    uglCursorImageSet (devId, pointerImage);    uglCursorOn (devId);    return;    }/**************************************************************************** createVideoRegion - create the video region** This routine creates a video region** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL  */static void createVideoRegion    (    UGL_GC_ID   gc              /* graphics context */    )    {    UGL_JPEG_MODE jpegMode;    int version;    /* Create rectangular area for video */    uglForegroundColorSet(gc, colorTable[VIDEO_REGION_BORDER_COLOR].uglColor);    uglBackgroundColorSet(gc, colorTable[VIDEO_COLOR_KEY].uglColor);    uglLineWidthSet(gc, VIDEO_REGION_BORDER_WIDTH);    uglRectangle(gc, VIDEO_REGION_LEFT, VIDEO_REGION_TOP, VIDEO_REGION_RIGHT,                  VIDEO_REGION_BOTTOM);    /* Create an overlay for the video      * - use overlay number 1     * - configure overlay as YUV422     * - use bob mode      * - display mode as defined by winMode     */    ovlyId = uglOverlayCreate (devId, 1, UGL_YUV422,                       winMode | UGL_OVERLAY_BOB_MODE,                      colorTable[VIDEO_COLOR_KEY].uglColor,                      VIDEO_REGION_LEFT, VIDEO_REGION_TOP, VIDEO_REGION_RIGHT,                       VIDEO_REGION_BOTTOM, 1);    overlayTop = VIDEO_REGION_TOP;    overlayBottom = VIDEO_REGION_BOTTOM;    /* Attach the JPEG extension to allow image capture */    jpegId = uglJpegInit(ovlyId, &version);    /* set the jpeg mode */    jpegMode.quality = 75;    jpegMode.smooth = 0;    jpegMode.scale = 1;    uglJpegModeSet(jpegId,&jpegMode);    }/**************************************************************************** createStatusRegion - create the status region** This routine obtains the characteristics of the video adapter and* prints the info in an outlined rectangular region on the display. ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL  */static void createStatusRegion (void)    {    char textStr[80];    int line = 90;    int numPorts = 0;    int ix;    uglForegroundColorSet(gc, colorTable[RED].uglColor);    uglBackgroundColorSet(gc, colorTable[BLACK].uglColor);    uglLineWidthSet(gc, 2);    uglRectangle(gc, 550, 50 , 750, 400);    centerTextDraw (gc,fontFixed, BLACK, RED, 55, 550, 750,                    "ADAPTER STATUS");    uglVideoAdapterInfo (videoId, 0, UGL_VIDEO_AVAIL_GET, &availPorts);    /* Determine the available ports, default to first port found */    for (ix = 0; ix < 32; ix++)        {        if ((availPorts >> ix) & 1)            {            if (port == -1)                port = ix;            numPorts++;            }        }        sprintf (textStr,"Number of video ports: %d",numPorts);    textDraw (gc,fontFixed, BLACK, WHITE, line, 560, textStr);    line += 20;    }/**************************************************************************** moveOverlay -  move the video overlay** This routine moves the video overlay** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL  */static void moveOverlay (void)    {    /* Stop the video */    uglVideoStillPut (videoId, gc, port,                      videoInfo.x, videoInfo.y,                       videoInfo.width,  videoInfo.height);    /* Erase old rectangular area for video */    uglForegroundColorSet(gc, BLACK);    uglBackgroundColorSet(gc, BLACK);    uglRectangle(gc, VIDEO_REGION_LEFT, overlayTop, VIDEO_REGION_RIGHT,                  overlayBottom);    if (overlayTop == VIDEO_REGION_TOP)        {        overlayTop = VIDEO_REGION_TOP2;        overlayBottom = VIDEO_REGION_BOTTOM2;        }    else        {        overlayTop = VIDEO_REGION_TOP;        overlayBottom = VIDEO_REGION_BOTTOM;        }    /* Create rectangular area for video */    uglForegroundColorSet(gc, colorTable[VIDEO_REGION_BORDER_COLOR].uglColor);    uglBackgroundColorSet(gc, colorTable[VIDEO_COLOR_KEY].uglColor);    uglLineWidthSet(gc, VIDEO_REGION_BORDER_WIDTH);    uglRectangle(gc, VIDEO_REGION_LEFT, overlayTop, VIDEO_REGION_RIGHT,                  overlayBottom);    /* reposition overlay */    uglOverlayMove (ovlyId,VIDEO_REGION_LEFT, overlayTop, VIDEO_REGION_RIGHT,                 overlayBottom, 1);     /* restart the video */    uglVideoStreamPut(videoId, gc, port,videoInfo.x, videoInfo.y,                      videoInfo.width, videoInfo.height);    /* Draw on top of video */    if (overlayTop == VIDEO_REGION_TOP2)        {        uglForegroundColorSet(gc, colorTable[RED].uglColor);        uglBackgroundColorSet(gc, colorTable[WHITE].uglColor);        uglLineWidthSet(gc, VIDEO_REGION_BORDER_WIDTH);        uglRectangle(gc, BOX_IN_2_LEFT , BOX_IN_2_TOP, BOX_IN_2_RIGHT,                      BOX_IN_2_BOTTOM);        textDraw (gc,fontFixed, ALMOST_BLACK, RED, TEXT_REGION2_LINE,                  BOX_IN_2_RIGHT + 30,                   "Graphics overlay video image");        }    }/**************************************************************************** processInput - wait for input data and process** This routine waits for input data and processes accordingly** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL  */static UGL_UINT16 processInput     (    UGL_BOOL reportType,            /* type of message to retrieve */    UGL_UINT16 * pKeyCode,          /* received key code */    UGL_UINT16 * pX,                /* X position of cursor */    UGL_UINT16 * pY,                /* Y position of cursor */    UGL_UINT16 * pModifiers         /* current modifiers */    )    {    UGL_MSG msg;    UGL_STATUS status;    UGL_UINT16 reportReady = UGL_FALSE;    UGL_UINT16 inType = 0;    while (!reportReady)        {        status = uglInputMsgGet (inputServiceId, &msg, UGL_WAIT_FOREVER);            if (status != UGL_STATUS_Q_EMPTY)            {            switch (msg.type)                {                case MSG_POINTER:                    uglCursorMove(gc->pDriver,                                   msg.data.pointer.position.x,                                   msg.data.pointer.position.y);                    inType = REPORT_PTR;                    if (reportType & REPORT_PTR)                        reportReady = UGL_TRUE;                    *pKeyCode = 0;                    *pX = msg.data.pointer.position.x;                    *pY = msg.data.pointer.position.y;                    *pModifiers = msg.data.pointer.buttonState;                    break;                                    case MSG_KEYBOARD:                    if (msg.data.keyboard.modifiers & UGL_KBD_KEYDOWN)                        {                        *pKeyCode = msg.data.keyboard.key;                        inType = REPORT_KBD;                        if (reportType & REPORT_KBD)                            reportReady = UGL_TRUE;                        }                    *pX = msg.data.keyboard.ptrPos.x;                    *pY = msg.data.keyboard.ptrPos.y;                    *pModifiers = msg.data.keyboard.modifiers;                    break;                }            }        }    return (inType);    }/**************************************************************************** selectPort - select a new video port** This routine selects a new video port <newPort>.** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL  */static void selectPort    (    UGL_UINT32 newPort          /* video port to select */    )    {    char textStr[80];    float maxVideoW, videoW;    UGL_VIDEO_CONFIG videoConfig;    /* validate that the port is available */    if ((availPorts & (1 << newPort)) == 0)        return;    port = newPort;    sprintf (textStr,"Active port: %d", port + 1);    textDraw (gc,fontFixed, BLACK, WHITE, ACTIVE_LINE, 560, textStr);    /* get port info */    uglVideoAdapterInfo (videoId, port, UGL_VIDEO_PORT_INFO,                          &videoInfo);    maxVideoW = videoInfo.maxWidth;    videoW = videoInfo.width;    zoomFactor = maxVideoW/videoW;    sprintf(textStr,"Zoom factor = %1.2f ", zoomFactor);    textDraw (gc,fontFixed, BLACK, WHITE, ZOOM_LINE,               560,textStr);    /* Configure port, as follows:     *   - use color keying     *   - created overlay surface     *   - use NTSC signals     *   - use interlace input     */    videoConfig.overlayId = ovlyId;    videoConfig.videoMode = UGL_VIDEO_NTSC;    videoConfig.interlace = UGL_TRUE;    uglVideoAdapterInfo (videoId, port, UGL_VIDEO_CONFIG_SET, &videoConfig);    uglVideoStreamPut(videoId, gc, port,videoInfo.x, videoInfo.y,                      videoInfo.width, videoInfo.height);    /* update current settings for color attributes */    bzero ((char *)&attrib, sizeof(attrib));    uglVideoAdapterInfo (videoId, port, UGL_VIDEO_ATTRIB_GET,                          &attrib);    sprintf(textStr,"%s = %3d ", attribName[0], attrib.hue);    textDraw (gc,fontFixed, BLACK, WHITE, attribLine[0],               560,textStr);    sprintf(textStr,"%s = %3d ", attribName[1], attrib.saturation);    textDraw (gc,fontFixed, BLACK, WHITE, attribLine[1],               560,textStr);    sprintf(textStr,"%s = %3d ", attribName[2], attrib.contrast);    textDraw (gc,fontFixed, BLACK, WHITE, attribLine[2],               560,textStr);    sprintf(textStr,"%s = %3d ", attribName[3], attrib.brightness);    textDraw (gc,fontFixed, BLACK, WHITE, attribLine[3],               560,textStr);    }/**************************************************************************** freezeVideo -  freeze video in the video region** This routine either freezes or un-freezes the video according to the* <mode> parameter. ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL  */static void freezeVideo    (    int mode              /* freeze change mode */    )    {    static int freeze = FALSE;    switch (mode)        {        case UNFREEZE_VIDEO:            freeze = FALSE;            break;        case FREEZE_VIDEO_TOGGLE:            if (freeze)                freeze = FALSE;            else                freeze = TRUE;            break;        case FREEZE_VIDEO:            freeze = TRUE;            break;        }        if (freeze)         {        uglVideoStillPut (videoId, gc, port,                          videoInfo.x, videoInfo.y,                           videoInfo.width,  videoInfo.height);        textDraw (gc,fontFixed, BLACK, WHITE, FREEZE_LINE, 560, "Freeze Video");        }    else        {        uglVideoStreamPut(videoId, gc, port,videoInfo.x, videoInfo.y,                          videoInfo.width, videoInfo.height);        textDraw (gc,fontFixed, BLACK, WHITE, FREEZE_LINE, 560, blank);        }    }/**************************************************************************** alphaBall -  a bouncing ball that changes alpha level** This routine bounces a ball within the video window. ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL  */static int alphaBall()    {    int left, right, top, bottom;    int direction = 10;    UGL_LOCAL UINT8 alphaValue = 0xff;    UGL_RGB rgbColor;    UGL_COLOR uglColor;    left = BOX_IN_1_RIGHT + 20;    right = left + 50;    top =   BOX_IN_1_TOP;    bottom = top + 50;    bounceBall = UGL_TRUE;    while (bounceBall)         {        rgbColor = UGL_MAKE_ARGB(alphaValue, 168, 0, 0);        uglColorAlloc(devId, &rgbColor, UGL_NULL, &uglColor, 1);        /* draw the ball */        uglForegroundColorSet(gc, colorTable[BLUE].uglColor);        uglBackgroundColorSet(gc, uglColor);        uglEllipse(gc, left, top, right, bottom, 0, 0, 0, 0);        uglOSTaskDelay(sysClkRateGet()/20);        /* erase the ball (use a rectangle) */        uglForegroundColorSet(gc, colorTable[VIDEO_COLOR_KEY].uglColor);        uglBackgroundColorSet(gc, colorTable[VIDEO_COLOR_KEY].uglColor);        uglRectangle(gc, left, top, right, bottom);        top += direction;        bottom += direction;        if (bottom >=  VIDEO_REGION_BOTTOM)            {            direction = -10;            top += direction;            bottom += direction;            }        if (top <= VIDEO_REGION_TOP)           {           direction = 10;           top += direction;           bottom += direction;           alphaValue += 0x10;           alphaValue &= 0xff;           }        }    return (0);    }/**************************************************************************** changeAlpha -  change the alpha level*

⌨️ 快捷键说明

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