node-native-win-utils 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-native-win-utils",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "author": "RynerNO",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/RynerNO/node-native-win-utils.git",
Binary file
@@ -38,7 +38,7 @@ Napi::Value CaptureWindow(const Napi::CallbackInfo &info)
38
38
  }
39
39
 
40
40
  // Init COM
41
- winrt::init_apartment(winrt::apartment_type::multi_threaded);
41
+ winrt::init_apartment(winrt::apartment_type::single_threaded);
42
42
 
43
43
  // Create Direct 3D Device
44
44
  winrt::com_ptr<ID3D11Device> d3dDevice;
@@ -32,7 +32,7 @@ Napi::Value Imread(const Napi::CallbackInfo &info)
32
32
 
33
33
  // Create a new Uint8Array with the correct size
34
34
 
35
- size_t totalBytes = image.cols * image.rows * image.elemSize();
35
+ size_t totalBytes = image.total() * image.elemSize();
36
36
  Napi::ArrayBuffer arrayBuffer = Napi::ArrayBuffer::New(env, totalBytes);
37
37
  Napi::Uint8Array uint8Array = Napi::Uint8Array::New(env, totalBytes, arrayBuffer, 0);
38
38
 
@@ -354,7 +354,7 @@ Napi::Value GetRegion(const Napi::CallbackInfo &info)
354
354
  {
355
355
  Napi::Env env = info.Env();
356
356
 
357
- if (info.Length() < 2 || !info[0].IsObject() && !info[1].IsObject())
357
+ if (info.Length() < 2 || !info[0].IsObject() || !info[1].IsObject())
358
358
  {
359
359
  Napi::TypeError::New(env, "Invalid arguments. Expected: (object)").ThrowAsJavaScriptException();
360
360
  return env.Null();
@@ -391,7 +391,8 @@ Napi::Value GetRegion(const Napi::CallbackInfo &info)
391
391
  cv::Mat image(imageHeight, imageWidth, CV_8UC3, imageObj.Get("data").As<Napi::TypedArray>().ArrayBuffer().Data());
392
392
 
393
393
  cv::Rect region(x, y, width, height);
394
- cv::Mat regionImage = image(region);
394
+ cv::Mat regionImage = image(region).clone();
395
+
395
396
  size_t totalBytes = regionImage.total() * regionImage.elemSize();
396
397
  Napi::ArrayBuffer arrayBuffer = Napi::ArrayBuffer::New(env, totalBytes);
397
398
  Napi::Uint8Array uint8Array = Napi::Uint8Array::New(env, totalBytes, arrayBuffer, 0);