05-01-2007 01:05 PM
// Create the image.
CNiAnnotation image = m_graph.Annotations.Add();
image.SetBuiltinStyle(CNiAnnotation::Picture);
image.Shape.Type = CNiShape::Picture;
image.Plot = m_StructurePlot; // The first plot added to the graph.
image.CoordinateType = CNiAnnotation::AxesCoordinates;
// Hardcode the location for testing purposes.
CNiReal64Vector xt(2), yt(2);
xt[0] = 2;
xt[1] = 12;
yt[0] = 2;
yt[1] = 12;
image.Shape.XCoordinates = xt;
image.Shape.YCoordinates = yt;
image.Shape.Image.Url = structure.m_GraphicFile;
image.Shape.Image.Stretch = true;
image.Shape.Image.Transparent = true;
image.Shape.Image.TransparentColor.SetBlue(255);
image.Shape.Image.TransparentColor.SetGreen(255);
image.Shape.Image.TransparentColor.SetRed(255);
image.Shape.Image.Reload();
05-02-2007 11:37 AM
Hi ADombroski,
What you are noticing when trying to set the image to transparent is actually the correct behavior. The transparent property actually only makes one color transparent. You can use the Transparent and TransparentColor properties to create transparent regions within a bitmap, icon, or metafile. When the graph draws the image, it does not draw any pixels that are the color of the Transparent color. Thus, whatever graphics are underneath the image show through. So, first you should choose the color you want to make transparent and then set the transparent property to true.
I assume you actually have a multi-colored image, which is why you are seeing the image quality decrease. The quality is not actually decreasing; rather, it is missing a few colors.
I'm a little confused why you are trying to add a image as an annotation and then make it transparent. If you don't want the image to appear, you could use the CNiAnnotation or CNiImage Visible property which should be easier to control.
Regards,
Matt M.
NI
05-02-2007 12:39 PM
Hi Matt,
Thanks for the response. Actually I'm not all that fixated on the 'transparent' feature, but was looking into it as a means to solve my problem. The problem is that I have a 2D point plot graph that I would like to add a picture to. The picture represents a real-world structure (like a metal plate or bar). The image annotation seems perfect for this because it will pan/zoom/stretch/etc with the data. Unfortunately it also covers up (hides) the data points (dots). Basically I want to see the dots drawn on top of the image, not the other way around. If possible, i'd like to have the grid drawn on top of it as well.
There are several plots on this graph. The first one added to the graph is the one containing the annotation. Ones added later hold the data points.
Is there any way to accomplish this?
Thanks.
05-03-2007 12:59 PM
05-04-2007 09:15 AM
Hi Matt,
Thanks for your help. This is dissapointing though, as I am very impressed with the versatility of annotations. If necessary I will look into doing it by hand as you suggest.
I'd like to take one final crack at annotations though, using the Transparent properties. If my images were basically stick figures on a white background, I could make the color white transparent and achieve much of what I'm looking for. Unfortunately I can't seem to make any color other than black transparent. Perhaps I'm doing something wrong, but this code does not seem to work.
image.Shape.Image.Transparent = true;
image.Shape.Image.TransparentColor.SetBlue(255);
image.Shape.Image.TransparentColor.SetGreen(255);
image.Shape.Image.TransparentColor.SetRed(255);
Regardless of the color I set in the code above, black (0,0,0) is always transparent (nothing else is transparent). For this test I am using a simple 2 color bitmap with only black (0,0,0) and white (255,255,255) used. Am I missing something?
Thanks,
Andrew
05-04-2007 04:25 PM
05-07-2007 08:15 AM
Matt,
That works. If all we need are thin color-on-white line drawings then this will work out for us. Thanks for your help.
Regards,
Andrew