Skip to content

Commit

Permalink
Fix for #901712, enforces minumum canvas size
Browse files Browse the repository at this point in the history
Prevents a breakdown of canvas where size would be set to 0 because of
zooming too far out on a small image. You can now no longer zoom so far
out that the canvas becomes smaller than 1 px wide or high.
  • Loading branch information
robpvn committed Feb 6, 2012
1 parent 569611a commit 89c3cd2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Pinta.Core/Classes/DocumentWorkspace.cs
Expand Up @@ -96,9 +96,9 @@ internal DocumentWorkspace (Document document)
get { return (double)CanvasSize.Width / (double)document.ImageSize.Width; }
set {
if (value != (double)CanvasSize.Width / (double)document.ImageSize.Width || value != (double)CanvasSize.Height / (double)document.ImageSize.Height) {
int new_x = (int)(document.ImageSize.Width * value);
int new_y = (int)((new_x * document.ImageSize.Height) / document.ImageSize.Width);
int new_x = Math.Max ((int)(document.ImageSize.Width * value), 1);
int new_y = Math.Max ((int)((new_x * document.ImageSize.Height) / document.ImageSize.Width), 1);

CanvasSize = new Gdk.Size (new_x, new_y);
Invalidate ();
}
Expand Down Expand Up @@ -194,6 +194,9 @@ public void ZoomToRectangle (Cairo.Rectangle rect)
#region Private Methods
private void ZoomAndRecenterView (ZoomType zoomType, Cairo.PointD point)
{
if (zoomType == ZoomType.ZoomOut && (CanvasSize.Width == 1 || CanvasSize.Height ==1))
return; //Can't zoom in past a 1x1 px canvas

double zoom;

if (!ViewActions.TryParsePercent (PintaCore.Actions.View.ZoomComboBox.ComboBox.ActiveText, out zoom))
Expand Down

0 comments on commit 89c3cd2

Please sign in to comment.