PxLoadImage How to USE ?

I have problems when try to load an image from a file into PtLabel
this is part of my code

#include <photon/PxImage.h>

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 );

PhImage_t *img;
int UseShmem = 1;

void SetImage (PtWidget_t *mywidget, char *texto)
{

PtArg_t     arg[5];
char        fname[255] = { 0 };
 PxMethods_t methods;

    memset( &methods, 0, sizeof( PxMethods_t ) );
    methods.px_alloc    = memory_allocate;
    methods.px_free     = (void *)memory_free;
methods.px_warning  = (void *)warning;
methods.px_error    = (void *)error;
methods.px_progress = (void *)progress;

    methods.flags |= PX_LOAD;

strcpy(fname,texto);
if( ( img = PxLoadImage( fname, &methods ) ) == NULL ) 
{
               fprintf( stderr, "Error loading/query %s\n",fname );
               PtExit( EXIT_FAILURE );
     }
  
     img->flags |= Ph_RELEASE_IMAGE_ALL;

     PtSetArg( &arg[0], Pt_ARG_LABEL_TYPE, Pt_IMAGE, 0 );
     PtSetArg( &arg[1], Pt_ARG_LABEL_IMAGE, img, 0);
     PtSetResources(mywidget, 2, arg);  

     /* Free the PhImage_t structure (but not its contents). */
    free( img );

}
// ---------------------------------------------------------------------------
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 );
}
}
// ---------------------------------------------------------------------------
void warning( char *msg )
{
printf( “%s\n”, msg );
}
// ---------------------------------------------------------------------------
void error( char *msg )
{
printf( “%s\n”, msg );
PtExit( EXIT_FAILURE );
}
// ---------------------------------------------------------------------------
void progress( int percent )
{
printf( “Load Status: %d.%d percent\n”,
percent >> 16, percent & 0xffff );
}

Does anybody help me or send me same code thats works ok

thank you

Thanks

I resolve this problem yet

bye