LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Transparent bitmap on canvas

Solved!
Go to solution

OK, so I'm working on a workaround for this bug. Basically I read my picture rings and generate new canvases on which I put the images from the ring. Then I just put whatever canvas I want on top. Except that there's a problem with the transparency of the images which gets lost in the process:

	int j, New, Bitmap, Left, Top, Width, Height, Pre[3]={1,3,2};	// Only some colors
	for (j=0; j<Nb; j++) {
		GetCtrlBitmap   (Pnl, PNL_PICRING, i, &Bitmap);
		GetCtrlAttribute(Pnl, PNL_PICRING, ATTR_LEFT,  &Left);
		GetCtrlAttribute(Pnl, PNL_PICRING, ATTR_TOP,   &Top);
		GetCtrlAttribute(Pnl, PNL_PICRING, ATTR_WIDTH, &Width);
		GetCtrlAttribute(Pnl, PNL_PICRING, ATTR_HEIGHT,&Height);
		New = NewCtrl (pDgrm, CTRL_CANVAS, "", Top, Left);
		SetCtrlAttribute(Pnl, New, ATTR_DRAW_POLICY, VAL_MARK_FOR_UPDATE);
		SetCtrlAttribute(Pnl, New, ATTR_WIDTH,  Width);
		SetCtrlAttribute(Pnl, New, ATTR_HEIGHT, Height);
		SetCtrlAttribute(Pnl, New, ATTR_PICT_BGCOLOR, VAL_TRANSPARENT);
		CanvasDrawBitmap(Pnl, New, Bitmap, VAL_ENTIRE_OBJECT, VAL_ENTIRE_OBJECT);
		DiscardBitmap(Bitmap);
	}
	SetCtrlAttribute(Pnl, PNL_PICRING, ATTR_VISIBLE, FALSE);

 Am I forgetting something about transparency ?

0 Kudos
Message 1 of 3
(3,499 Views)

Hi gdargaud,

 

Are you expecting to have the bitmap drawn into the canvas be transparent? 

Humphrey H.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(3,478 Views)
Solution
Accepted by topic author gdargaud

Yes. Actually, reading the documentation, I figured out it's actually simpler to use a picture control instead of a canvas. I had forgotten about those. Case closed. But could you please answer my other thread about the major memory leak when using picture rings, which is actually the reason I'm using this workaround ? Thank you.

0 Kudos
Message 3 of 3
(3,475 Views)