QNX下显示图片

QNX下显示图片部分代码如下,支持各种常用图片:

 

/* * Image.c * * Created on: 2009-8-11 * Author: CockRoach * Support BMP, GIF, JPEG, PCX, PNG, and SGI files */ #include #include #include #include #include #include #include #include #include #include #include #include void *memory_allocate( long nbytes, int type ); void *memory_free( void *memory, int type ); void *warning( char *msg ); void *error( char *msg ); void *progress( int percent ); int UseShmem = 1; int LoadImageFile(char* FileName, int x, int y) { PhImage_t *img; PxMethods_t methods; PhPoint_t pos; memset( &methods, 0, sizeof( PxMethods_t ) ); methods.px_alloc = memory_allocate; methods.px_free = memory_free; methods.px_warning = warning; methods.px_error = error; methods.px_progress = progress; methods.flags |= PX_LOAD; img = PxLoadImage( FileName, &methods ); if( img == NULL ) { fprintf( stderr, "Error loading/query %s/n", FileName ); return 0; } pos.x = x; pos.y = y; PgDrawPhImage(&pos, img, NULL); return 1; } void *memory_allocate( long nbytes, int type ) { if( type == PX_IMAGE && UseShmem ) { return( PgShmemCreate( nbytes, NULL ) ); } else { return( calloc( 1, nbytes ) ); } } void *memory_free( void *memory, int type ) { if( type == PX_IMAGE && UseShmem ) { PgShmemDestroy( memory ); } else { free( memory ); } return NULL; } void *warning( char *msg ) { printf( "%s/n", msg ); return NULL; } void *error( char *msg ) { printf( "%s/n", msg ); PtExit( EXIT_FAILURE ); return NULL; } void *progress( int percent ) { printf( "Load Status: %d.%d percent/n", percent >> 16, percent & 0xffff ); return NULL; }

你可能感兴趣的:(QNX)