FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(ios-image-source): update definitions and fix logic of image-sou… · NativeScript/NativeScript@018ef93 · GitHub

Commit 018ef93

Browse files
committed
feat(ios-image-source): update definitions and fix logic of image-sources
update definitions and fix logic of quality in image-sources closes #5474
1 parent 6bb32de commit 018ef93

3 files changed

Lines changed: 4 additions & 9 deletions

File tree

‎tests/app/image-source/image-source-tests.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ export function testSaveToFile() {
5555
}
5656

5757
export function testSaveToFile_WithQuality() {
58-
// >> imagesource-save-to
5958
const img = imageSource.fromFile(imagePath);
6059
const folder = fs.knownFolders.documents();
6160
const path = fs.path.join(folder.path, "test.png");
6261
const saved = img.saveToFile(path, "png", 70);
63-
// << imagesource-save-to
6462
TKUnit.assert(saved, "Image not saved to file");
6563
TKUnit.assert(fs.File.exists(path), "Image not saved to file");
6664
}
@@ -199,11 +197,8 @@ export function testBase64Encode_PNG() {
199197
}
200198

201199
export function testBase64Encode_PNG_WithQuality() {
202-
// >> imagesource-to-base-string
203200
const img = imageSource.fromFile(smallImagePath);
204201
let base64String = img.toBase64String("png", 80);
205-
// << imagesource-to-base-string
206-
207202
base64String = base64String.substr(0, expectedPngStart.length);
208203
TKUnit.assertEqual(
209204
base64String,

‎tns-core-modules/image-source/image-source.d.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ export class ImageSource {
9898
* Saves this instance to the specified file, using the provided image format and quality.
9999
* @param path The path of the file on the file system to save to.
100100
* @param format The format (encoding) of the image.
101-
* @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality.
101+
* @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. Quality varies on a scale of 0 to 100.
102102
*/
103103
saveToFile(path: string, format: "png" | "jpeg" | "jpg", quality?: number): boolean;
104104

105105
/**
106106
* Converts the image to base64 encoded string, using the provided image format and quality.
107107
* @param format The format (encoding) of the image.
108-
* @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality.
108+
* @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality. Quality varies on a scale of 0 to 100.
109109
*/
110110
toBase64String(format: "png" | "jpeg" | "jpg", quality?: number): string;
111111
}

‎tns-core-modules/image-source/image-source.ios.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class ImageSource implements ImageSourceDefinition {
130130
return false;
131131
}
132132

133-
if (quality != null && quality > 1) {
133+
if (quality) {
134134
quality = quality - 0 / (100 - 0); // Normalize quality on a scale of 0 to 1
135135
}
136136

@@ -148,7 +148,7 @@ export class ImageSource implements ImageSourceDefinition {
148148
return res;
149149
}
150150

151-
if (quality != null && quality > 1) {
151+
if (quality) {
152152
quality = quality - 0 / (100 - 0); // Normalize quality on a scale of 0 to 1
153153
}
154154

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL