@@ -395,60 +395,60 @@ async function captureSnip(autoImageSearch = false) {
395
395
// scaleFactor: 1.0,
396
396
// });
397
397
398
- let url2 = source . thumbnail . toBitmap ( ) ;
399
- var image = new Jimp ( width * factor , height * factor , async function (
400
- err ,
401
- image
402
- ) {
403
- let buffer = image . bitmap . data ;
404
- let snipPath = path . join ( app . getPath ( "temp" ) , `snip${ index } .png` ) ;
405
- for ( var x = 0 ; x < width * factor ; x ++ ) {
406
- for ( var y = 0 ; y < height * factor ; y ++ ) {
407
- const offset = ( y * width * factor + x ) * 4 ; // RGBA = 4 bytes
408
- buffer [ offset ] = url2 [ offset + 2 ] ; // R
409
- buffer [ offset + 1 ] = url2 [ offset + 1 ] ; // G
410
- buffer [ offset + 2 ] = url2 [ offset + 0 ] ; // B
411
- buffer [ offset + 3 ] = url2 [ offset + 3 ] ; // Alpha
412
- }
413
- }
414
- await image . write ( snipPath ) ;
415
-
416
- console . log ( `Took ${ performance . now ( ) - now } ms to get PNG` ) ;
417
-
418
- let url =
419
- "data:image/png;base64," +
420
- fs . readFileSync ( snipPath ) . toString ( "base64" ) ;
421
-
422
- let snipWindow = createSnipWindow ( {
423
- width,
424
- height,
425
- area : primaryDisplay . workArea ,
426
- } ) ;
427
-
428
- snippingWindows . push ( snipWindow ) ;
429
-
430
- let nowSnip = performance . now ( ) ;
431
- images [ snipWindow . webContents . id ] = {
432
- index,
433
- url,
434
- width,
435
- height,
436
- display : primaryDisplay ,
437
- autoImageSearch,
438
- } ;
439
- snipWindow . webContents . send ( "SET_SOURCE" , {
440
- index,
441
- width,
442
- height,
443
- } ) ;
444
-
445
- console . log ( `Took ${ performance . now ( ) - nowSnip } ms to send source` ) ;
446
-
447
- console . log (
448
- `Took ${ performance . now ( ) - veryStart } ms to capture shot`
449
- ) ;
398
+ // let url2 = source.thumbnail.toBitmap();
399
+ // var image = new Jimp(width * factor, height * factor, async function (
400
+ // err,
401
+ // image
402
+ // ) {
403
+ // let buffer = image.bitmap.data;
404
+ // let snipPath = path.join(app.getPath("temp"), `snip${index}.png`);
405
+ // for (var x = 0; x < width * factor; x++) {
406
+ // for (var y = 0; y < height * factor; y++) {
407
+ // const offset = (y * width * factor + x) * 4; // RGBA = 4 bytes
408
+ // buffer[offset] = url2[offset + 2]; // R
409
+ // buffer[offset + 1] = url2[offset + 1]; // G
410
+ // buffer[offset + 2] = url2[offset + 0]; // B
411
+ // buffer[offset + 3] = url2[offset + 3]; // Alpha
412
+ // }
413
+ // }
414
+ // await image.write(snipPath);
415
+
416
+ let snipPath = path . join ( app . getPath ( "temp" ) , `snip${ index } .png` ) ;
417
+ let url2 = source . thumbnail . toPNG ( ) ;
418
+ fs . writeFileSync ( snipPath , url2 ) ;
419
+
420
+ console . log ( `Took ${ performance . now ( ) - now } ms to get PNG` ) ;
421
+
422
+ let url = "data:image/png;base64," + url2 . toString ( "base64" ) ;
423
+
424
+ let snipWindow = createSnipWindow ( {
425
+ width,
426
+ height,
427
+ area : primaryDisplay . workArea ,
428
+ } ) ;
429
+
430
+ snippingWindows . push ( snipWindow ) ;
431
+
432
+ let nowSnip = performance . now ( ) ;
433
+ images [ snipWindow . webContents . id ] = {
434
+ index,
435
+ url,
436
+ width,
437
+ height,
438
+ display : primaryDisplay ,
439
+ autoImageSearch,
440
+ } ;
441
+ snipWindow . webContents . send ( "SET_SOURCE" , {
442
+ index,
443
+ width,
444
+ height,
450
445
} ) ;
451
446
447
+ console . log ( `Took ${ performance . now ( ) - nowSnip } ms to send source` ) ;
448
+
449
+ console . log ( `Took ${ performance . now ( ) - veryStart } ms to capture shot` ) ;
450
+ // });
451
+
452
452
return ;
453
453
}
454
454
} ) ;
@@ -488,7 +488,7 @@ async function openColorPicker() {
488
488
) ;
489
489
490
490
if ( ! source ) {
491
- source = source [ sourceIndex ] ;
491
+ source = sources [ sourceIndex ] ;
492
492
}
493
493
494
494
if ( source ) {
@@ -499,63 +499,62 @@ async function openColorPicker() {
499
499
500
500
now = performance . now ( ) ;
501
501
502
- let url2 = source . thumbnail . toBitmap ( ) ;
503
- var image = new Jimp ( width * factor , height * factor , async function (
504
- err ,
505
- image
506
- ) {
507
- let buffer = image . bitmap . data ;
508
- let snipPath = path . join ( app . getPath ( "temp" ) , `snip${ index } .png` ) ;
509
- for ( var x = 0 ; x < width * factor ; x ++ ) {
510
- for ( var y = 0 ; y < height * factor ; y ++ ) {
511
- const offset = ( y * width * factor + x ) * 4 ; // RGBA = 4 bytes
512
- buffer [ offset ] = url2 [ offset + 2 ] ; // R
513
- buffer [ offset + 1 ] = url2 [ offset + 1 ] ; // G
514
- buffer [ offset + 2 ] = url2 [ offset + 0 ] ; // B
515
- buffer [ offset + 3 ] = url2 [ offset + 3 ] ; // Alpha
516
- }
517
- }
518
- await image . write ( snipPath ) ;
519
-
520
- console . log ( `Took ${ performance . now ( ) - now } ms to get PNG` ) ;
521
-
522
- let url =
523
- "data:image/png;base64," +
524
- fs . readFileSync ( snipPath ) . toString ( "base64" ) ;
525
-
526
- let snipWindow = createColorPicker ( {
527
- display : primaryDisplay ,
528
- width,
529
- height,
530
- area : primaryDisplay . workArea ,
531
- } ) ;
532
-
533
- snippingWindows . push ( snipWindow ) ;
534
-
535
- let nowSnip = performance . now ( ) ;
536
- images [ snipWindow . webContents . id ] = {
537
- index,
538
- url,
539
- width,
540
- height,
541
- display : primaryDisplay ,
542
- } ;
543
- console . log ( width , factor ) ;
544
- snipWindow . webContents . send ( "SET_SOURCE" , {
545
- index,
546
- width : width * factor ,
547
- height : height * factor ,
548
- factor,
549
- } ) ;
550
- currentColorPicker = snipWindow ;
551
- currentColorPickerDisplay = primaryDisplay ;
552
-
553
- console . log ( `Took ${ performance . now ( ) - nowSnip } ms to send source` ) ;
554
-
555
- console . log (
556
- `Took ${ performance . now ( ) - veryStart } ms to capture shot`
557
- ) ;
502
+ // let url2 = source.thumbnail.toBitmap();
503
+ // var image = new Jimp(width * factor, height * factor, async function (
504
+ // err,
505
+ // image
506
+ // ) {
507
+ // let buffer = image.bitmap.data;
508
+ // let snipPath = path.join(app.getPath("temp"), `snip${index}.png`);
509
+ // for (var x = 0; x < width * factor; x++) {
510
+ // for (var y = 0; y < height * factor; y++) {
511
+ // const offset = (y * width * factor + x) * 4; // RGBA = 4 bytes
512
+ // buffer[offset] = url2[offset + 2]; // R
513
+ // buffer[offset + 1] = url2[offset + 1]; // G
514
+ // buffer[offset + 2] = url2[offset + 0]; // B
515
+ // buffer[offset + 3] = url2[offset + 3]; // Alpha
516
+ // }
517
+ // }
518
+ // await image.write(snipPath);
519
+ let snipPath = path . join ( app . getPath ( "temp" ) , `snip${ index } .png` ) ;
520
+ let url2 = source . thumbnail . toPNG ( ) ;
521
+ fs . writeFileSync ( snipPath , url2 ) ;
522
+
523
+ console . log ( `Took ${ performance . now ( ) - now } ms to get PNG` ) ;
524
+
525
+ let url = "data:image/png;base64," + url2 . toString ( "base64" ) ;
526
+
527
+ let snipWindow = createColorPicker ( {
528
+ display : primaryDisplay ,
529
+ width,
530
+ height,
531
+ area : primaryDisplay . workArea ,
532
+ } ) ;
533
+
534
+ snippingWindows . push ( snipWindow ) ;
535
+
536
+ let nowSnip = performance . now ( ) ;
537
+ images [ snipWindow . webContents . id ] = {
538
+ index,
539
+ url,
540
+ width,
541
+ height,
542
+ display : primaryDisplay ,
543
+ } ;
544
+ console . log ( width , factor ) ;
545
+ snipWindow . webContents . send ( "SET_SOURCE" , {
546
+ index,
547
+ width : width * factor ,
548
+ height : height * factor ,
549
+ factor,
558
550
} ) ;
551
+ currentColorPicker = snipWindow ;
552
+ currentColorPickerDisplay = primaryDisplay ;
553
+
554
+ console . log ( `Took ${ performance . now ( ) - nowSnip } ms to send source` ) ;
555
+
556
+ console . log ( `Took ${ performance . now ( ) - veryStart } ms to capture shot` ) ;
557
+ // });
559
558
560
559
return ;
561
560
}
0 commit comments