LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Transparent bitmap over a graph control

Hello,

I am trying to put a bitmap of a diagram over a graph control, whereby the graph can be seen through the bitmap.
I have created a canvas over the graph control and set the attribute to transparent. However when I load the bit map, the white background obscures the graph.

Is there a way I can make the white background of the bitmap transparent so the graph can be seen through the diagram.

Has anyone got any suggestions please?.

Cheerio
Mike
0 Kudos
Message 1 of 9
(4,738 Views)
I tried transparency on CVI 5.5 and eventually gave up. Not sure if it is supported now.
Jattie van der Linde
Engineering Manager, Software & Automation
TEL Magnetic Solutions Ltd
0 Kudos
Message 2 of 9
(4,724 Views)
I have version 7.1 and I cant find anything that supports it, and judging by the responses I dont think it does.

I thought someone might know how to do it by some cleaver way.

Mike
0 Kudos
Message 3 of 9
(4,718 Views)
By coincidence Erwin Timmerman just posted some code yesterday (see
GraphToCanvas.zip below) that I think could be adapted to do what you want.
In line 203 of GraphToCanvas.c a rectangle is drawn on top of the canvas
containing an image of the graph beneath it. Instead of drawing a rectangle,
you would call a new function (say CanvasDrawForegroundPixels()) that draws
the non-transparent pixels of your bitmap, pixel by pixel.

If you load your diagram into a hidden canvas and then call
CanvasGetPixels() to retrieve all of its pixel colors into an array called
DiagramPixelColors[], the pseudo-code for the function to be called (instead
of CanvasDrawRect()) would go something like this:

CanvasDrawForegroundPixels()
{
for i = each pixel in DiagramPixelColors[]
if DiagramPixelColors[i] is a foreground color
then draw it over the graph image with CanvasDrawPoint()
next i
}

Hope it helps,
Nick

"Mikek" <x@no.email> wrote in message news:217851@exchange.ni.com...

> Hello,<br><br>I am trying to put a bitmap of a diagram over a graph
control, whereby the graph can be seen through the bitmap.<br>I have created
a canvas over the graph control and set the attribute to transparent.
However when I load the bit map, the white background obscures the graph.
<br><br>Is there a way I can make the white background of the bitmap
transparent so the graph can be seen through the diagram.<br><br>Has anyone
got any suggestions please?.<br><br>Cheerio<br>Mike


Message 4 of 9
(4,713 Views)
Hi Mike,

Maybe I'm missing something, but why won't this work:
-convert your BMP to ICO
-place a picture control over the graph (z-order in front of graph)
-change the picture control backgroung to transparent with the paint tool

As long as your BMP isn't greater than 255 pixels in either direction, you can make an ICO from your bitmap. Typically we think of Windows ICO files as 16-square, 32-square, or 48-square, but other larger sizes are possible. They simply aren't used often. I'm not sure you can violate the square shape, but there are several good icon editors that advertise the ability to make custom size ICOs.

I have personally placed 48x48 ICO files over a strip chart (with a clear background) and I didn't notice one bit of flicker. I haven't done it with a graph control, but I assume it would be very similar, if not identical, in function. Is there a specific reason for wanting a canvas control?

Orlan
Message 5 of 9
(4,708 Views)
Hi Nick,

Thanks for the reply. Brilliant, I will try what you suggested with the canvas, it should do the trick.

That is an interesting little program from Erwin Timmerman. Maybe CVI should put that zoom box in their graph toolbox instead of using cursors to zoom (See graphcursorctrl.prj)!.

Cheerio
Mike
0 Kudos
Message 6 of 9
(4,680 Views)
Hi Orlan,

Thanks for the reply. Its a good suggestion. In fact I was thinking along those lines but I need the .bmp size to be the same as letter or A4 sheet and my ico editor doesnt handle that size. Someone has suggested copying the foreground bits of the bmp to a transparent canvas which should do the trick.

Thanks again
Cheerio
Mike
0 Kudos
Message 7 of 9
(4,677 Views)
Say Mike,

If you go to the trouble to adapt Erwin's code to display a bitmap, maybe
you could post your source here. It sounds like a nifty "bell and whistle"
to add to data graphing apps.

Cheers,

Nick




0 Kudos
Message 8 of 9
(4,665 Views)
Hi Nick,

You gotta deal!.

Cheerio
Mike
0 Kudos
Message 9 of 9
(4,640 Views)