From 8680a08a8de0b2183272f6bec19cb96ca8608ff2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 14 Dec 2016 10:18:01 -0800 Subject: [PATCH] Add deprecated comment to scaleFactor parameter --- atom/common/api/atom_api_native_image.cc | 5 +++-- spec/api-native-image-spec.js | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index 46b36f1eddc1..a8f89f15e15a 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -410,13 +410,14 @@ mate::Handle NativeImage::CreateFromBuffer( int height = 0; double scale_factor = 1.; - args->GetNext(&scale_factor); - mate::Dictionary options; if (args->GetNext(&options)) { options.Get("width", &width); options.Get("height", &height); options.Get("scaleFactor", &scale_factor); + } else { + // TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings + args->GetNext(&scale_factor); } gfx::ImageSkia image_skia; diff --git a/spec/api-native-image-spec.js b/spec/api-native-image-spec.js index 226d2b60e735..7bb2e040f6c4 100644 --- a/spec/api-native-image-spec.js +++ b/spec/api-native-image-spec.js @@ -44,6 +44,13 @@ describe('nativeImage module', () => { const imageH = nativeImage.createFromBuffer(imageA.toJPEG(100), {width: 100, height: 200}) assert.deepEqual(imageH.getSize(), {width: 538, height: 190}) + + const imageI = nativeImage.createFromBuffer(imageA.toBitmap(), + {width: 538, height: 190, scaleFactor: 2.0}) + assert.deepEqual(imageI.getSize(), {width: 269, height: 95}) + + const imageJ = nativeImage.createFromBuffer(imageA.toPNG(), 2.0) + assert.deepEqual(imageJ.getSize(), {width: 269, height: 95}) }) })