LabWindows/CVI Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Bertrand_ENAC

Adding a bitmap to the 3D Graph

Status: New

Hello,

 

I'm using the 3D Graph ActiveX in order to display contour lines for a given parameter.

I would like to overlay this contour map with a Google earth image as shwon below.

 

Bitmap in 3D Graph.jpg

 

So it would be nice to consider adding the possibility to add a bitmap image to the 3D graph as it is possible to add a bitmap as background of a canvas control. The bitmap could also be used to replace the color of a surface plot.

 

 

4 Comments
D_Biel
Active Participant

As a current workaround, you can use an intensity plot on a graph control with a picture control containing a transparent image on top. The intensity graph fulfills the functionality you have in you screenshot by allowing you to specify an intensity (color) for each point in your graph and will allow colors to be interpolated over a range through a color map. Then create a copy of your map image in a file format that accepts transparency. Place this image in a picture control and overlay the picture control onto the graph control.

 

Also, the graph control supports ploting bitmaps, so this Idea Exchange idea to add transparent plots could allow you to do this without the need for the picture control. That idea is currently under consideration.

National Instruments
Bertrand_ENAC
Member

Thank you for this workaround.

I made some tests and did unfortunately run into some trouble.

The following code:

 

for (j=0; j<NbOfPtsY; j++)                  

     {

    for (i=0; i<NbOfPtsX; i++)    

          { 

         Z[j][i] = 1 + sin ((360.0 * i/100)*PI/180);    

          }   

     }     

 PlotIntensity (panelHandle, PANEL_GRAPH, Z, NbOfPtsX, NbOfPtsY, VAL_DOUBLE, ColorMap, VAL_RED, 4, 0, 0);

 GetCtrlDisplayBitmap (panelHandle, PANEL_GRAPH, 0, &BitmapID);      

 GetBitmapInfoEx (BitmapID, &ColorArraySize, &BitsArraySize, &MaskArraySize, &AlphaChannelArraySize); 

 AllocBitmapDataEx (BitmapID, &ColorTable, &BitsTable, &MaskTable,  &AlphaChannelTable);

 GetBitmapDataEx (BitmapID, &BytesPerRow, &PixelDepth, &Width, &Height, NULL, BitsTable, NULL, 

                                AlphaChannelTable);   

 AlphaChannelArraySize = Width * Height;  

 AlphaChannelTable = malloc (AlphaChannelArraySize * sizeof(unsigned char));

 for (i=0; i<AlphaChannelArraySize; i++)    

        AlphaChannelTable[i] = 100;       

SetBitmapDataEx (BitmapID, BytesPerRow, PixelDepth, NULL, BitsTable, NULL, AlphaChannelTable); 

SaveBitmapToPNGFile (BitmapID,

                                       "c:\\Users\\SPITZ\\Documents\\CVI\\TestsGoogleEarth\\WebBrowser 2\\Test image 4.png");   

DisplayImageFile (panelHandle, PANEL_PICTURE,

                             "c:\\Users\\SPITZ\\Documents\\CVI\\TestsGoogleEarth\\WebBrowser 2\\Test image 4.png");   

 

Results in the following:

Test 1.jpg

What did I wrong?

 

D_Biel
Active Participant

I think the problem here is that the bitmap that your code adds the alpha channel to does not have an alpha channel. Because of this, every fourth RGB array value its changed to 100. This makes for a strange looking image. You can fix this by creating a new BitmapEx instead of modifying the existing bitmap. Replace the SetBitmapDataEx with NewBitmapEx.

 

Additionally, the approach I was referring to before is slightly different and may or may not be easier to implement than this method. I actually made the Google Maps image transparent instead of the intensity graph. I added the alpha channel in a image editor, but you can probably achieve the same behavior programmatically in much the same way you did here. Then I loaded the map into a Picture control with a transparent frame. In the UIR editor, I placed the Picture control directly on top of the Graph control drawing region. This approach may be a bit simpler in that you only have to work with the bitmap of the Google Maps image instead of the graph control where you will need to trim the axis region.

 

But there are probably many different ways to achieve this. It might boil down to which image needs to be on top: the graph or the map.

National Instruments
Bertrand_ENAC
Member

Now it works.

 

Thanks