Somebody knows how i can draw the edges labels in a box with this library?
I am using it in C#.
Thanks!
If someone have the same problem, i have found a solution. The solution is to modify the Draw class, concretelly the DrawStringInRectCenter method.
I have get as parameter a Graphics and a DObject objects, then i cast if the DOBject is a DNode or DEdge. In case of been DEdge i call DrawRectangle, FillRectangle and DrawString in such order, with the aim of make a box with white background, black border and black label.
Related
This may seem like a strange question, but I have a set of pictures I want to use as a fading screen saver, and I want each picture to have an accompanying quote, but each quote will be in a different place, relative to the picture.
Rather than coding a Rectangle for the area of each image, it would be easier just to draw a rectangle in the image, and have it drawn in there.
Now, the drawn shape would be a stark, uniform coloured border (lime green, for instance) because the colour doesn't appear in the pictures, and it would be on a solid coloured background, like black for instance.
My question is: If I draw a lime green rectangle on each image, how could I then, using C#, find that rectangle in the image, get the dimensions of it, and replace the lime green with the background colour, so in the end product, it'd look like the shape was never there to begin with?
I have not tried anything, I have no code to show, because it's an idea I had and though I'm sure it must be possible, I don't even know what to start searching for.
I hope this is possible, if it isn't, then I'll just draw a rectangle for each one, but that's a last resort. :)
Have you thought about using either the emgucv or aforge libraries? They are able to detect shapes in images quite easily. Though they don't detect edges perfectly, if all you want to detect is a rectangle, either one should work well.
Here are two tutorials on shape detection for emgu cv and aforge. Once you have the shape detected, then you can easily cut it out for the background. Say, for example, that you used the aforge Detection of quadrilaterals (in the link), then you could easily get the rectangles position and size by the calling of blobs[i].Rectangle; and create a rectangle with same size and position with picture background color.
If you need more clarification please feel free to comment. Nice idea!
I need to determine the visible area/areas of a WPF control overlapped by other controls taking in consideration transparency.
Consider the following scenario:
Three controls on a canvas. The blue and the green one are overlapping the third one. The green one has a transparent rectangle area. Is it possible to problematically get the visible regions 1, 2, 3 marked by red rectangles?
Something similar to (following API doesn't exist):
Geometry[] visibleAreas = VisualTreeHelper.GetVisibleGeometry(controlInTheBack);
Thanks in advance for any suggestions.
Update:
I've tried to use DrawingGroup drawingGroup = VisualTreeHelper.GetDrawing(visual) to get the geometries of each control.
Then use CombinedGeometry with GeometryCombineMode="Union" on the overlapping controls to get the overlapping area.
Then use CombinedGeometry with GeometryCombineMode="Exclude" between the geometry of the control in the back and the result of the union to obtain the visible regions.
The problem is that VisualTreeHelper.GetDrawing(control) returns null.
Have you already tried to use HitTest? It may be helpful
http://msdn.microsoft.com/en-us/library/ms752097.aspx
Background
I want to be able to get the drawn dimensions of a zoomed image inside the picturebox (I'll explain below).
The PictureBox.ImageRectangle property seems to be exactly what I'm looking for because it shows the height and width of the resized image, as well as it's relative top, left position inside the control.
The trouble is PictureBox.ImageRectangle is private and so I can't read the values without using reflection (which is obviously not ideal).
Actual Question
My question is, is there another way that I can easily get to these values without writing a method to calculate what the values "ought" to be? I can do that easily enough, but I feel I'd be reinventing the wheel.
Context:
I'm writing a simple image processing app in C# and one of the things it has to do is allow the user to draw a selection around a portion of the image (a lot like the Marquee tool in Photoshop).
I need to know the dimensions of the rendered image so I know where to set the bounds of my marquee tool and also to translate the values of the drawn rectangle to points on the scaled bitmap inside the control.
My answer look simple so maybe I'm missing something, but I think Control.DisplayRectangle suits your need.
EDIT
OK, missed the point; however see How to get the value of non- public members of picturebox?
if you want to access dimension of the image in picture box you can use
GraphicsUnit units = GraphicsUnit.Point;
RectangleF imgRectangleF = pictureBox1.Image.GetBounds(ref units);
Rectangle imgRectangle = Rectangle.Round(imgRectangleF);
Alright, so I need a texture for a game that I'm making and I found a texture that fit to my project(some kind of ball). The texture is next to other textures(Textures sheet).
So I had to download all the sheet. Now, I need to get only the texure that I want (that ball). And I can only circle it by a rectangle(using Paint). Is it true that XNA has an ignorant color? Or there's any other way that I can load ONLY MY BALL? and not the background of it?
Please, I really need an answer for it.. Thanks alot.
To enable colour-key transparency, select your texture in your content project and press F4 to bring up the properties window. Expand the "Content Processor" option to reveal the colour key settings. Turn on colour key and select the appropriate colour.
If you need to use a sprite sheet within XNA (ie: if you're not cropping it in your image editor), you can use the sourceRectangle parameter to SpriteBatch.Draw to treat only a particular rectangular region of your source texture as a sprite.
By default SpriteBatch will draw with BlendState.AlphaBlend (ie: if you use the Begin() overload, you don't need to set it), which will correctly handle the transparency for you.
i am using in my c# project visio activex to import visio floorplan drawings.
and i need to get the vertices of the shapes in that drawing, and i can't find any method or property for it.
if someone has any ideas please help.
You can use the BoundingBox method on the shape class to retrieve the dimensions of the box around a shape.
This MSDN page will give you more information about the method, it returns the top, bottom, left and right of the box, so it should be possible to work out the vertices from that.
Visio uses a PinX and a PinY to describe the location of a shape using the shapes Height and Width will allow you to calculate the vertices.