Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with 'Picture' type Annotations

I'm trying to create an annotation to hold a bitmap, but I'm running into
trouble. When I run the code I get an exception when any of the 'Image'
attributes are set (Url, Stretch, Tranparent, etc). This exception is
caught by CDocument::OnOpenDocument() !? This happens whether or not I set
XCoordinates/YCoordinates. 'm_sGraphicFileName' does exist and is a valid
bmp file.

I'm not sure what I'm doing wrong or leaving out. Anyone have an idea?

Thanks


CNiAnnotation tad = m_graph.Annotations.Add();
tad.Shape.Type = CNiShape::Picture;
tad.CoordinateType = CNiAnnotation::AxesCoordinates;
tad.Plot = m_Plots[0]; // CNiPlot[]

CNiReal64Vector xt(5), yt(5);
xt[0] = structure.m_BMP_XMin;
yt[0] = structure.m_BMP_YMin;
xt[1] = stru
cture.m_BMP_XMin;
yt[1] = structure.m_BMP_YMax;
xt[2] = structure.m_BMP_XMax;
yt[2] = structure.m_BMP_YMax;
xt[3] = structure.m_BMP_XMax;
yt[3] = structure.m_BMP_YMin;
xt[4] = structure.m_BMP_XMin;
yt[4] = structure.m_BMP_YMin;
tad.Shape.XCoordinates = xt;
tad.Shape.YCoordinates = yt;

tad.Shape.Image.Url = m_sGraphicFileName; // !!!***** EXCEPTION *****!!!
tad.Shape.Image.Stretch = true;
tad.Shape.Image.Transparent = false;
tad.Shape.Image.Reload();
0 Kudos
Message 1 of 7
(3,718 Views)
It might be the way that you're specifying the coordinates. When specifying the coordinates for an image, you only need to specify 2 values for the X & Y coordinate vectors that indicate the starting point and width/height rather than 5 values for the the 4 corners and closing point. For example, create a new project, add a graph, create a member variable called m_graph, add a button, double-click on the button, and add the following code. Assuming that you have a file on your system at C:\Windows\WINNT.bmp (XP systems will have this), you should see be able to run, click the button, and see the image annotation:

CNiAnnotation annotation = m_graph.Annotations.Add();
annotation.Shape.Type = CNiShape::Picture;

const int imageWidth = 275;
c
onst int imageHeight = 174;

// Create coordinates for the top-left corner of plot area.
CNiReal64Vector xCoordinates(2), yCoordinates(2);
xCoordinates[0] = 0;
xCoordinates[1] = imageWidth;
yCoordinates[0] = 0;
yCoordinates[1] = imageHeight;
annotation.CoordinateType = CNiAnnotation::PlotAreaCoordinates;
annotation.Shape.XCoordinates = xCoordinates;
annotation.Shape.YCoordinates = yCoordinates;

annotation.Shape.Image.Url = _T("C:\\Windows\\WINNT.bmp");
annotation.Shape.Image.Reload();

- Elton
0 Kudos
Message 2 of 7
(3,718 Views)
Thanks for responding. I did as you suggested and created a new project/etc
and tried your code. I can now properly size the box, but the image problem
still persists. It still throws an exception on the first 'Shape.Image'
attribute accessed, but it is now caught by AfxCallWndProc(). Also, a new
popup box is now displayed showing "SCODE: -2147467262". This may be
unrelated as it does not show up in my original program even if I swap in
your code segment. I am using Measurement Studio version 6. Any further
ideas would be greatly appreciated. Thanks.


"Elton Wells" wrote in message
news:50650000000500000073240100-1042324653000@exchange.ni.com...
> It might be the way that you're specifying the coordinates. When
> specifying the coordinates for an image, you only need to specify 2
> values for the X & Y coordinate vectors that indicate the starting
> point and width/height rather than 5 values for the the 4 corners and
> closing point. For example, create a new project, add a graph, create
> a member variable called m_graph, add a button, double-click on the
> button, and add the following code. Assuming that you have a file on
> your system at C:\Windows\WINNT.bmp (XP systems will have this), you
> should see be able to run, click the button, and see the image
> annotation:
>
> CNiAnnotation annotation = m_graph.Annotations.Add();
> annotation.Shape.Type = CNiShape::Picture;
>
> const int imageWidth = 275;
> const int imageHeight = 174;
>
> // Create coordinates for the top-left corner of plot area.
> CNiReal64Vector xCoordinates(2), yCoordinates(2);
> xCoordinates[0] = 0;
> xCoordinates[1] = imageWidth;
> yCoordinates[0] = 0;
> yCoordinates[1] = imageHeight;
> annotation.CoordinateType = CNiAnnotation::PlotAreaCoordinates;
> annotation.Shape.XCoordinates = xCoordinates;
> annotation.Shape.YCoordinates = yCoordinates;
>
> annotation.Shape.Image.Url = _T("C:\\Windows\\WINNT.bmp");
> annotation.Shape.Image.Reload();
>
> - Elton
0 Kudos
Message 3 of 7
(3,718 Views)
What kind of image are you using? Could you please post a small test project along with an image that reproduces the behavior that you're seeing? Thanks.

- Elton
0 Kudos
Message 4 of 7
(3,718 Views)
At the moment I am using the winnt.bmp that you suggested. Here is a zip of
a simple dialog project that illustrates the behavior. Included in the
source is the "winnt.bmp" image and a screen capture of the behavior
("behavior.jpg"). Thanks for your help.


"Elton Wells" wrote in message
news:506500000005000000CC240100-1042324653000@exchange.ni.com...
> What kind of image are you using? Could you please post a small test
> project along with an image that reproduces the behavior that you're
> seeing? Thanks.
>
> - Elton



[Attachment annot.zip, see below]
0 Kudos
Message 5 of 7
(3,718 Views)
Elton,

Were you able to build the source I sent? I'd be interrested to hear your
take on it, if you have the opportunity. Thanks.


"Elton Wells" wrote in message
news:506500000005000000CC240100-1042324653000@exchange.ni.com...
> What kind of image are you using? Could you please post a small test
> project along with an image that reproduces the behavior that you're
> seeing? Thanks.
>
> - Elton
0 Kudos
Message 6 of 7
(3,718 Views)
Hello Andrew,

I wanted to let you know that we have fixed the issue you were running into (with Picture type annotations). You can find the installer for the Measurement Studio 6.0 Updater, which will fix the required components, here:

http://digital.ni.com/softlib.nsf/websearch/E906DFC1159F08FA86256D8800564F29?Opendocument

Let me know if you have any questions.

Best Regards,
Azucena Perez
National Instruments
0 Kudos
Message 7 of 7
(3,718 Views)