-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added extra overload to the compare method to get access to the compa…
…re image.
- Loading branch information
Showing
5 changed files
with
210 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
import { ImageMagick } from '../../image-magick'; | ||
|
||
/** @internal */ | ||
export class DoublePointer { | ||
private readonly instance: number; | ||
|
||
private constructor() { | ||
this.instance = ImageMagick._api._malloc(8); | ||
ImageMagick._api.setValue(this.instance, 0, 'double'); | ||
} | ||
|
||
get ptr(): number { return this.instance; } | ||
|
||
get value(): number { return ImageMagick._api.getValue(this.instance, 'double'); } | ||
|
||
static use<TReturnType>(func: (pointer: DoublePointer) => TReturnType): TReturnType { | ||
const pointer = new DoublePointer(); | ||
try { | ||
return func(pointer); | ||
} finally { | ||
ImageMagick._api._free(pointer.instance); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/magick-wasm. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
import { IMagickImage } from '../magick-image'; | ||
|
||
/** | ||
* Compare result. | ||
*/ | ||
export class CompareResult { | ||
private constructor(distortion: number, difference: IMagickImage) { | ||
this.distortion = distortion; | ||
this.difference = difference; | ||
} | ||
|
||
/** | ||
* Gets the difference image. | ||
*/ | ||
readonly difference; | ||
/** | ||
* Gets the distortion. | ||
*/ | ||
readonly distortion; | ||
|
||
/** @internal */ | ||
static _create(distortion: number, difference: IMagickImage): CompareResult { | ||
return new CompareResult(distortion, difference); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters