Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title Transparent .gif Images for Buttons
Ref. No. QNX.000009777
Category(ies) Development
Issue I am attempting to create a button that has a transparent gif image. The idea is that the button would be over a bitmap and the bitmap would show through the transparent part of the button.
Is this possible with PhAB?

Solution Yes, it is possible. Put your image under the button into shared memory. Try to match the pallete of your image with the palette that you use in Photon.
Then make your button with transparent fill color and a border width of 0.

Here is a sample example on putting the button background image into shared memory:

#define PX_IMAGE_MODULES
#define PX_JPG_SUPPORT
#include <photon/PxImage.h>
void *memory_allocate(long nbytes, int type)
{
x09return(PgShmemCreate(nbytes, NULL));
}
void memory_free(void *memory, int type)
{
x09PgShmemDestroy(memory);
}
int base_setup(PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
x09int i = 0;
x09char *fname ="/tmp/slaunch_bkgd.jpg";
x09PtArg_t arg[2];
x09PhImage_t *img;
x09PxMethods_t methods;
x09/*eliminate 'unreferenced' warnings*/
x09link_instance = link_instance, apinfo = apinfo, cbinfo =cbinfo;
x09memset(&methods, 0, sizeof(PxMethods_t));
x09methods.px_alloc = memory allocate;
x09methods.px_free = memory_free;
x09methods.flags |= PX_LOAD;
x09if(((img = PxLoadImage(fname, &methods))== NULL)
x09{
x09x09fprintf(stderr, "error loading %sn", fname);
x09x09exit(EXIT_FAILURE);
x09}
x09PtSetArg(&arg[0], Pt_ARG_BKGD_IMAGE, img, sizeof(PhImage_t));
x09PtSetResources(ABW_bkgd1, 1, arg);
x09return(Pt_CONTINUE);
}