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

📄 wexjpeg.c

📁 2410/vxworks/tornado下的基本实验包括 serial,ramdrv,interrupt,multi-FTP,TCP,UDP-Under the basic experimental
💻 C
📖 第 1 页 / 共 2 页
字号:
/* wexjpeg.c - WindML Jpeg example program *//* Copyright 2000 - 2003 Wind River Systems, Inc. All Rights Reserved *//*modification history--------------------01p,08may03,jlb  Remove UGL_LOCAL on function prototype01o,16apr03,jlb  Improved comments and program documentation01n,01apr03,sts  [SPR 86504] Use uglRegistryFind() safely.01m,22feb02,msr  Backward compatibility for input API.01l,29jan02,rbp  Addition of support for Native Unix.01k,05nov01,gav  Fixed misnamed devIds01j,05nov01,gav  Change to new registry01i,05nov01,gav  Change to new registry01h,31oct01,rfm  Open binary files01g,09oct01,msr  Ported to new UGL_Q_EVENT architecture.01f,19dec00,gav  Entry point identical to filename w/o extension.01e,22nov00,gav  Added command line file path argument.01d,16nov00,msr  Fixed SPR #6205101c,27oct00,rfm  Added stdio usage01b,26oct00,rfm  Modified entry point01a,25oct00,rfm  Added modification history*//*DESCRIPTION This example program demonstrates how a Jpeg can be displayed to the screen and how a jpeg can be created from a bitmap such as the screen. To start the example: -> ld < wexjpeg_ugl.o -> wexjpeg <mode> This example will display 3 different Jpeg images. After the 3rd jpeg has been displayed, a jpeg will be created from the 3rd image on the screen. If the <mode> parameter is positive, no input devices are  assumed to be present and the demo will wait <mode> number of seconds before proceeding to the next image. A value of zero or a negative value assumes that a mouse or keyboard is  present. **************************************************************/#if !defined(WINDML_NATIVE)#include <vxWorks.h>#include <sysLib.h>#endif/* 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/uglMsg.h>#include <ugl/uglfont.h>#include <ugl/uglinput.h>#include <ugl/ext/jpeg/ugljpeg.h>/* Copy these files to the home directory for the target andchange the path below. */#define JPEG_IMG_FILE1 "testimg1.jpg"#define JPEG_IMG_FILE2 "testimg2.jpg"#define JPEG_IMG_FILE3 "testimg3.jpg"/* This file will be created on the host. */#define JPEG_IMG_FILE4 "testimg4.jpg"/* A forward declaration for this program. */void windMLExampleJpeg (int mode, char *path);/* Global variables *//* Control variable to signal when to stop program */volatile UGL_BOOL stopWex = 0;/* Some graphics environment information */UGL_LOCAL int displayHeight, displayWidth;UGL_LOCAL UGL_GC_ID gc;/* Some input related variables for the pause routine */UGL_LOCAL UGL_INPUT_SERVICE_ID inputServiceId;UGL_FONT_ID font;/** 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)/**************************************************************************** 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);    }/**************************************************************************** flushQ - flush the input message queue** This routine reads from the input message queue until it is empty.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL**/void flushQ (void)    {    UGL_MSG msg;    UGL_STATUS status;    do        {        status = uglInputMsgGet (inputServiceId, &msg, UGL_NO_WAIT);        } while (status != UGL_STATUS_Q_EMPTY);    }/**************************************************************************** pause - wait for input from keyboard/pointer or expiration of a delay** This routine waits for input from the keyboard/pointer when the <mode> is * less than or equal to zero.  When a key press or pointer button is clicked* the routine exits.  If <mode> is greater than zero, the routine waits for* number of clock ticks present in <mode> and then returns.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL**/UGL_LOCAL void pause    (    int mode                    /* operating mode */    )    {    static UGL_CHAR * message = "Press any key or mouse button to continue.";    int textWidth, textHeight;    UGL_MSG msg;    UGL_STATUS status;    if (mode <= 0)	{	uglBackgroundColorSet(gc, colorTable[BLACK].uglColor);	uglForegroundColorSet(gc, colorTable[LIGHTGREEN].uglColor);	uglTextSizeGet(font, &textWidth, &textHeight, 		       -1, message);	uglTextDraw(gc, (displayWidth - textWidth) / 2, 			(displayHeight - textHeight) / 2, -1, message);	flushQ();	UGL_FOREVER	    {	    status = uglInputMsgGet (inputServiceId, &msg, UGL_WAIT_FOREVER);	    if (status != UGL_STATUS_Q_EMPTY)		{                if ((msg.type == MSG_KEYBOARD &&                      (msg.data.keyboard.modifiers & UGL_KBD_KEYDOWN)) ||                    (msg.type == MSG_POINTER &&                     (msg.data.pointer.buttonChange &                      msg.data.pointer.buttonState)))		    break;		}	    }	}    else	{#if !defined(WINDML_NATIVE)	uglOSTaskDelay(sysClkRateGet() * mode);#endif	}    }#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 [])    {    windMLExampleJpeg (0, ".");    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);    windMLExampleJpeg(0, ".");    return (0);    }#else/**************************************************************************** wexjpeg - demonstrate JPEG image handling** This routine demonstrates how WindML can work with JPEG images.  ** This example 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 Determine if a JPEG encoder/decoder is present within graphics driver*\m Establish JPEG encoder/decoder mode (image quality, scale, smoothing)*\m Read a JPEG image from a file, convert to a bitmap, and display*\m create a JPEG image from a bitmap and store to a file*\m Releasing all resources and terminating a WindML application.*\me*** The program displays three JPEG images from a file waiting between each* image.  If the <mode> is greater than zero then the program waits the * number of seconds represented in <mode> between each JPEG image display.  * If the value in <mode> is zero or less than zero, the program will await * operator input before moving to the next JPEG image. Any key can be depressed* or a pointer button clicked to move on to the next JPEG image.** The value in <path> is the root to the JPEG test images on the file* system.** RETURNS: ** ERRNO: N/A** SEE ALSO:  **/

⌨️ 快捷键说明

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