Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - How to swap images using a label: Page 1 of 29 (29 Items)
   
How to swap images using a label  
Hi,

I'm new to QNX and PhAB, but have been programming for 20+ years. I guess I'm most familiar with the Visual Studio 
paradigm. 

I am using Neil Carter's example of showing an image using a label.

int ShowImage( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
   
   PhImage_t   *myImg;
   char        myImgFlnm[20] = "PICTURE.BMP";

   /* eliminate 'unreferenced' warnings */
   widget = widget, apinfo = apinfo, cbinfo = cbinfo;
    
   if ((myImg = PxLoadImage( myImgFlnm, NULL)) == NULL) {
      fprintf( stderr, "Error loading image file %s\n", myImgFlnm);
      PtExit( EXIT_FAILURE );
   }
   PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg, 0);
    
   return( Pt_CONTINUE );
}

How can I swap out the current image with another image after a short delay?

I tried the following, but it simple shows the 2nd image:

int ShowImage( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
   
   PhImage_t   *myImg, *myImg2;
   char        myImgFlnm[20] = "PICTURE.BMP";
   char        myImgFlnm2[20] = "PICTURE2.BMP";

   /* eliminate 'unreferenced' warnings */
   widget = widget, apinfo = apinfo, cbinfo = cbinfo;
    
   if ((myImg = PxLoadImage( myImgFlnm, NULL)) == NULL) {
      fprintf( stderr, "Error loading image file %s\n", myImgFlnm);
      PtExit( EXIT_FAILURE );
   }
   PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg, 0);

   delay(5000); /* delay 5 secs */

   if ((myImg2 = PxLoadImage( myImgFlnm2, NULL)) == NULL) {
      fprintf( stderr, "Error loading image file %s\n", myImgFlnm2);
      PtExit( EXIT_FAILURE );
   }
   PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg2, 0);

    
   return( Pt_CONTINUE );
}


Thanks,

Frank