bug: image montage layout
This commit is contained in:
+2
-3
@@ -91,8 +91,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations
|
|||||||
|
|
||||||
if (MontageHorizontalLayout)
|
if (MontageHorizontalLayout)
|
||||||
DoHorizontalLayout(images, montageGraphics);
|
DoHorizontalLayout(images, montageGraphics);
|
||||||
else
|
else if (MontageVerticalLayout)
|
||||||
if (MontageVerticalLayout)
|
|
||||||
DoVirticalLayout(images, montageGraphics);
|
DoVirticalLayout(images, montageGraphics);
|
||||||
else
|
else
|
||||||
DoTableLayout(images, montageGraphics);
|
DoTableLayout(images, montageGraphics);
|
||||||
@@ -164,7 +163,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations
|
|||||||
{
|
{
|
||||||
var image = Images[imageIndex];
|
var image = Images[imageIndex];
|
||||||
var cellPoint = new PointF((cellSize.Width * columnIndex) + (Padding * columnIndex), (cellSize.Height * rowIndex) + (Padding * rowIndex));
|
var cellPoint = new PointF((cellSize.Width * columnIndex) + (Padding * columnIndex), (cellSize.Height * rowIndex) + (Padding * rowIndex));
|
||||||
MontageGraphics.Clip = new Region(new RectangleF(cellPoint, cellSize));
|
MontageGraphics.SetClip(new RectangleF(cellPoint, cellSize));
|
||||||
MontageGraphics.DrawImageResized(image);
|
MontageGraphics.DrawImageResized(image);
|
||||||
imageIndex++;
|
imageIndex++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace Disco.Services
|
|||||||
|
|
||||||
public static RectangleF CalculateResize(int SourceWidth, int SourceHeight, int TargetWidth, int TargetHeight, out float scaleRatio)
|
public static RectangleF CalculateResize(int SourceWidth, int SourceHeight, int TargetWidth, int TargetHeight, out float scaleRatio)
|
||||||
{
|
{
|
||||||
scaleRatio = Math.Min((float)(TargetWidth) / SourceWidth, (float)(TargetHeight) / SourceHeight);
|
scaleRatio = Math.Min((float)TargetWidth / SourceWidth, (float)TargetHeight / SourceHeight);
|
||||||
|
|
||||||
float width = SourceWidth * scaleRatio,
|
float width = SourceWidth * scaleRatio,
|
||||||
height = SourceHeight * scaleRatio,
|
height = SourceHeight * scaleRatio,
|
||||||
@@ -126,9 +126,7 @@ namespace Disco.Services
|
|||||||
|
|
||||||
public static RectangleF CalculateResize(int SourceWidth, int SourceHeight, int TargetWidth, int TargetHeight)
|
public static RectangleF CalculateResize(int SourceWidth, int SourceHeight, int TargetWidth, int TargetHeight)
|
||||||
{
|
{
|
||||||
float scaleRatio;
|
return CalculateResize(SourceWidth, SourceHeight, TargetWidth, TargetHeight, out _);
|
||||||
|
|
||||||
return CalculateResize(SourceWidth, SourceHeight, TargetHeight, TargetHeight, out scaleRatio);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RectangleF CalculateResize(this Image Source, int TargetWidth, int TargetHeight, out float scaleRatio)
|
public static RectangleF CalculateResize(this Image Source, int TargetWidth, int TargetHeight, out float scaleRatio)
|
||||||
@@ -138,13 +136,14 @@ namespace Disco.Services
|
|||||||
|
|
||||||
public static RectangleF CalculateResize(this Image Source, int TargetWidth, int TargetHeight)
|
public static RectangleF CalculateResize(this Image Source, int TargetWidth, int TargetHeight)
|
||||||
{
|
{
|
||||||
return CalculateResize(Source.Width, Source.Height, TargetHeight, TargetHeight);
|
return CalculateResize(Source.Width, Source.Height, TargetWidth, TargetHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DrawImageResized(this Graphics graphics, Image SourceImage)
|
public static void DrawImageResized(this Graphics graphics, Image SourceImage)
|
||||||
{
|
{
|
||||||
RectangleF clipBounds = graphics.VisibleClipBounds;
|
RectangleF clipBounds = graphics.VisibleClipBounds;
|
||||||
var resizeBounds = SourceImage.CalculateResize((int)clipBounds.Width, (int)clipBounds.Height);
|
var resizeBounds = SourceImage.CalculateResize((int)clipBounds.Width, (int)clipBounds.Height);
|
||||||
|
resizeBounds.Offset(clipBounds.Location);
|
||||||
|
|
||||||
graphics.DrawImage(SourceImage, resizeBounds, new RectangleF(0, 0, SourceImage.Width, SourceImage.Height), GraphicsUnit.Pixel);
|
graphics.DrawImage(SourceImage, resizeBounds, new RectangleF(0, 0, SourceImage.Width, SourceImage.Height), GraphicsUnit.Pixel);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user