flicker-free drawing in Qnx 6.21 ?

In QNX helper , I find There are two ways to eliminate flicker in animation:

(1)Create a PtOSContainer (an offscreen-context container) and make it the
parent of all the widgets in the area being animated;
(2)Use the PmMem…() memory-context functions to build the image in memory,
and display it when complete.

I have try both,but there is no help.

For first one ,i made one PtOSContainer as my PtRaw’s parent,but it still
flicker.
//my Drawing
void raw_draw(PtWidget_t *widget, PhTile_t *damage)
{
PhRect_t rect;

PtCalcCanvas(widget, &rect);

PgSetFillColor(Pg_BLUE);
PgDrawRect(&rect, Pg_DRAW_FILL);
PgSetFillColor(Pg_GREEN);
PgDrawRect(&rect, Pg_DRAW_FILL);
}
I have to Draw twice in the same rect,i want one as background.
in another Timer thread ,i damage the PtRaw periodically. it flickering.

for the second one,i create a memory context .

static PhImage_t s_Image;
PhDim_t dim = { 640, 480 };
short bytes_per_pixel = 3;
PhPoint_t translation = { 0, 0 };
memset( &s_Image, 0, sizeof(PhImage_t) );
s_Image.type =Pg_IMAGE_DIRECT_888;
s_Image.size = dim;
s_Image.image = (char *)PgShmemCreate(dim.w * dim.h * bytes_per_pixel,
NULL);
PmMemoryContext_t * s_pMc = PmMemCreateMC( &s_Image, &dim, &translation );

in my RawDraw function,i do:

void raw_draw(PtWidget_t *widget, PhTile_t *damage)
{
PmMemStart( mc );

PhRect_t rect;
PtCalcCanvas(widget, &rect);
PgSetFillColor(Pg_BLUE);
PgDrawRect(&rect, Pg_DRAW_FILL);
PgSetFillColor(Pg_GREEN);
PgDrawRect(&rect, Pg_DRAW_FILL);

PmMemFlush( mc, image ); // get the image
PmMemStop( mc );
}

it works better(No flicker). But when i draw a bitmap:
PxMethods_t methods;
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;

PhImage_t * pImage=PxLoadImage("/root/test.bmp", &methods );

I create Shem like this:

void *memory_allocate( long nbytes, int type )
{
if( type == PX_IMAGE) {
return( PgShmemCreate( nbytes, NULL ) );
}
else {
return( calloc( 1, nbytes ) );
}
}

and then drawing the bitmap:

PgDrawPhImagemx(&pos,pImage,0);

In fact ,it impropriate the whole cpu(100%).

I hope your help,thanks very much!