LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

graph and bitmap

Hi,
I have a problem with CVI 8.0.1 under XP. I want to programmatically put a picture as a background in a graph control (.bmp, .png or .jpg) but I have an error message in debug mode that tell me "Not enough memory" and in release mode nothing appear in my graph control. Is there a way to avoid that?

0 Kudos
Message 1 of 17
(5,704 Views)

Hello Domp,

what method are you using to put the picture on your graph? I usually use the functions below:

 plot = PlotBitmap (pnlHandle, PNL_GRAPH, 0.0, 0.0, 1.0, 1.0, NULL);
 SetCtrlBitmap (pnlHandle, PNL_GRAPH, plot, bitmap);

Message 2 of 17
(5,689 Views)
Hello wim, this is a sample of my code:
//---------- extract from my code  ---------------------------------------------  
  status = FileSelectPopup (".\\cartes", "*.png", "*.png",
                                  "Fichier carte", VAL_LOAD_BUTTON, 0, 0, 1,
                                  0, nomfic);
        
    strcpy (NomFichierCarte, nomfic);
        
    if(status==VAL_NO_FILE_SELECTED)
     {
            ******
            ******
    }
    else  
    {
        //default bitmap will be loaded
        sprintf(NomFichierCarte,"%s%s",direc,nomficcarte);
    }
      
    //plotting my bitmap
    DeleteGraphPlot (panelHandle, PANEL_GRAPH_MAP, -1, VAL_IMMEDIATE_DRAW);
    
    PlotBitmap (panelHandle, PANEL_GRAPH_MAP, 0, 0,
                              largeur_map, hauteur_map, NomFichierCarte);
//--------------------------------------------------------------------------------------

Thanks for your help.
0 Kudos
Message 3 of 17
(5,654 Views)
Hi Domp, have you tried putting a breakpoint in PlotBitmap line and look at NomFichierCarte variable? How it looks?
 
It seems to me that your if statement is to be revised: the default picture should be loaded in VAL_NO_FILE_SELECTED case, while at present it is loaded in all other cases! That is: if the user selects nothing, you use garbage or nothing at all in nomfic as the filename; if the user actually selects a file, you replace it with default filename! Smiley Surprised
Moreover, in builing default image name but you may be missing a "\\" between directory and filename (at least it's not explicitly placed in the sprintf statement).


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 17
(5,650 Views)
Hi Roberto,
In fact the sample of my code was truncated and I have made a mistake. you must see something like that :
//---------- extract from my code  ---------------------------------------------  
  status = FileSelectPopup (".\\cartes", "*.png", "*.png",
                                  "Fichier carte", VAL_LOAD_BUTTON, 0, 0, 1,
                                  0, nomfic);
        
      
    if(status==VAL_NO_FILE_SELECTED) return -1;
    
      
    //plotting my bitmap
    DeleteGraphPlot (panelHandle, PANEL_GRAPH_MAP, -1, VAL_IMMEDIATE_DRAW);
    
    PlotBitmap (panelHandle, PANEL_GRAPH_MAP, 0, 0,
                              largeur_map, hauteur_map, nomfic);
//--------------------------------------------------------------------------------------
My trouble is only due to the problem of memory in including a bitmap in the graph control.
Thanks for your help.
Message 5 of 17
(5,626 Views)

How are you calculating largeur_map and hauteur_map values? According to documentation they are expressed in graph units and the image is rescaled to satisfy these values, so I imagine you may have some memory problems in this operation. I suggest you pass 0 as these parameters to check that the image is loaded correctly: after this is done you may proceed to calculate correct values and pass them to the function.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 17
(5,610 Views)

hi

how to convert bitmap image into graphical data points?

 

thanks in advance,

manju

 

 

 

0 Kudos
Message 7 of 17
(4,969 Views)

Hello manju,

Please do not revive old threads to ask a different thing.

 

What do you intend to do? Canyou give us some more data on your problem?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 8 of 17
(4,965 Views)

hi

I need to get a bitmap image(having a sine wave or some other waveforms) and I need to plot that image in a graph.

So from bitmap image, can i extract graphical data points?

I used the following function.

GetBitmapFromFile
PlotBitmap
SetCtrlBitmap

With GetBitmapFromFile function I can get the bitmap image and and while using PlotBitmap, image is exactly pasting in the graph.

I cant extract data points(like amplitude phase) from that graph.

 

Finally is there any option for converting bitmap image to graphical data values.

 

thanks in advance,

Manju

0 Kudos
Message 9 of 17
(4,960 Views)

I was afraid you want meaning something like that...

 

First of all, are you considering the error involved in such a process? The image (a hard copy of the screen, I suppose) is intrinsically limited to the screen resolution, since the actual graph on screen cannot resolve less then one pixel on each direction so plotting a curve intrinsically introduces some rounding (it's something like having a set of double values and extracting only the integer part for further analysis!).

 

Coming to the operative part, I have no real experience on analizing an image so I can only propose some guidelines mainly from a theorical point of view.

You must load the image content in memory with GetBitmapInfo and GetBitmapData, next you will need to scan the image column-by-column and find the trace point (detecting it based on the color? on the contrast with adjacent pixels?). Since the image in memory is no more than a matrix of pixel colors, you could rebuild the trace data from this process; remapping the trace to the appropriate scales will give you back the measures (subject to the aproximation error I told you before).

While analyzing the image, be aware that bits array is shaped in row-major order so you will need some transposing to easily scan it per columns. See the help for the Bits parameter in GetBitmapData.

 

I can see an additional problem if the drawing process has created more than one point on the single column, for example due to some aliasing or if the original trace has been drawn with "thick pen" like PlotXY with Plot Style = fat line.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 10 of 17
(4,947 Views)