Menu

#316 -affine sometimes produces output with missing rows

v1.0_(example)
closed-fixed
None
5
2015-09-13
2015-09-13
No

There's a bug in magick/render.c:

edge.y2 is a float. If it is between the value (image->rows-1 + 0.5) and (image->rows - epsilon), then this faulty condition will evaluate to false. One too many rows will be generated and a failure will be triggered for the last row.

if (edge.y2 >= image->rows)
       edge.y2=image->rows-1;

y_max will be equal to image->rows.

y_max=(long) floor(edge.y2+0.5);

GetImagePixelsEx will fail because y == image->rows.

q=GetImagePixelsEx(image,x,y,stop-x+1,1,&image->exception);
if (q == (PixelPacket *) NULL)
  thread_status=MagickFail;
~~~~~

The global status will be set to MagickFail and if OpenMP is enabled, then rows in the middle of the destination image will be skipped if the last row is evaluated before them.  If OpenMP is disabled, the rows will be evaluated in order and since it's the very last row that triggers the failure, no defect will be visible.

The following change should be made.
  • if (edge.y2 >= image->rows)
  • if (edge.y2 > image->rows - 1)
    edge.y2=image->rows-1;
    ~~~~~~

Discussion

  • Kevin Matzen

    Kevin Matzen - 2015-09-13

    Same with x:

    -      if (inverse_edge.x2 >= image->columns)
    +      if (inverse_edge.x2 > image->columns-1)
             inverse_edge.x2=image->columns-1;
    
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-09-13
    • status: open --> closed-fixed
    • assigned_to: Bob Friesenhahn
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-09-13

    Thanks for the analysis and the fix. The fix is checked into Mercurial and will appear in the next development snapshot.

     

Log in to post a comment.

MongoDB Logo MongoDB