Title: Make an improved diagonal picture montage in C#
My earlier example Make a Pinterest-style diagonal picture montage in C# showed how you could make a picture montage showing parts of images rotated by a desired angle. While using that program today I found a small bug. The areas between the images are not always completely filled with the divider color.
The following picture shows the program displaying a picture montage that it created. The red circles show places where pieces of images show between the cells' borders.
The picture on the right shows aa closeup of one of the problem areas.
Fortunately the solution to this problem is simple. The Cell class's Draw method draws a cell's picture and border. The following code shows the part of that method that draws the border. The new statement highlighted in blue fixes the problem.
// Draw the cell.
public void Draw(Graphics gr, Pen pen, float cell_width, float cell_height)
// Draw the cell's picture.
// Outline the cell.
gr.DrawRectangle(pen, Bounds.X, Bounds.Y, Bounds.Width, Bounds.Height);
GraphicsPath path = MakeRoundedRect(Bounds,
2 * pen.Width, 2 * pen.Width, true, true, true, true);
The new statement draws a rectangle around the image before the code draws the image's rounded rectangle. The new rectangle fills in the problem areas where the rounded rectangles' corners don't quite meet the adjacent rectangles.
See the previous post for more details about how the program works.
Download the example to experiment with it and to see additional details.