@@ -29,20 +29,24 @@ module MakeDiff (IO1 : ImageIO.ImageIO) (IO2 : ImageIO.ImageIO) = struct
2929
3030 let compare (base : IO1.t ImageIO.img ) (comp : IO2.t ImageIO.img )
3131 ?(antialiasing = false ) ?(outputDiffMask = false ) ?(diffLines = false )
32- ?diffPixel ?(threshold = 0.1 ) ?ignoreRegions () =
32+ ?diffPixel ?(threshold = 0.1 ) ?ignoreRegions ?( captureDiff = true ) () =
3333 let maxDelta = maxYIQPossibleDelta *. (threshold ** 2. ) in
3434 let diffPixel = match diffPixel with Some x -> x | None -> redPixel in
3535 let diffOutput =
36- match outputDiffMask with
37- | true -> IO1. makeSameAsLayout base
38- | false -> base
36+ match captureDiff with
37+ | true ->
38+ Some
39+ (match outputDiffMask with
40+ | true -> IO1. makeSameAsLayout base
41+ | false -> base)
42+ | false -> None
3943 in
4044
4145 let diffCount = ref 0 in
4246 let diffLinesStack = Stack. create () in
4347 let countDifference x y =
4448 incr diffCount;
45- IO1. setImgColor ~x ~y diffPixel diffOutput ;
49+ diffOutput |> Option. iter ( IO1. setImgColor ~x ~y diffPixel) ;
4650
4751 if
4852 diffLines
@@ -115,10 +119,23 @@ module MakeDiff (IO1 : ImageIO.ImageIO) (IO2 : ImageIO.ImageIO) = struct
115119 && (base.width <> comp.width || base.height <> comp.height)
116120 then Layout
117121 else
118- let diffResult =
122+ let diffOutput, diffCount, diffPercentage, diffLinesStack =
119123 compare base comp ~threshold ~diff Pixel ~output DiffMask ~antialiasing
120- ~diff Lines ?ignoreRegions ()
124+ ~diff Lines ?ignoreRegions ~capture Diff: true ()
121125 in
126+ Pixel (Option. get diffOutput, diffCount, diffPercentage, diffLinesStack)
122127
128+ let diffWithoutOutput (base : IO1.t ImageIO.img ) (comp : IO2.t ImageIO.img )
129+ ?(threshold = 0.1 ) ?(failOnLayoutChange = true ) ?(antialiasing = false )
130+ ?(diffLines = false ) ?ignoreRegions () =
131+ if
132+ failOnLayoutChange = true
133+ && (base.width <> comp.width || base.height <> comp.height)
134+ then Layout
135+ else
136+ let diffResult =
137+ compare base comp ~threshold ~output DiffMask:false ~antialiasing
138+ ~diff Lines ?ignoreRegions ~capture Diff:false ()
139+ in
123140 Pixel diffResult
124141end
0 commit comments