@@ -1740,8 +1740,9 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
1740
1740
1741
1741
if ([MIMETypeString hasPrefix: @" image/" ]) {
1742
1742
NSImage *image = [[NSImage alloc ] initWithContentsOfURL: fileURL];
1743
- transferItem.width = static_cast <int >(image.size .width );
1744
- transferItem.height = static_cast <int >(image.size .height );
1743
+ CGImageRef cgImage = [image CGImageForProposedRect: nil context: nil hints: nil ];
1744
+ transferItem.width = static_cast <int >(CGImageGetWidth (cgImage));
1745
+ transferItem.height = static_cast <int >(CGImageGetHeight (cgImage));
1745
1746
}
1746
1747
1747
1748
dataTransferItems.push_back (transferItem);
@@ -1753,6 +1754,7 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
1753
1754
NSString *MIMETypeString = imageType == NSPasteboardTypePNG ? @" image/png" : @" image/tiff" ;
1754
1755
NSData *imageData = [pasteboard dataForType: imageType];
1755
1756
NSImage *image = [[NSImage alloc ] initWithData: imageData];
1757
+ CGImageRef cgImage = [image CGImageForProposedRect: nil context: nil hints: nil ];
1756
1758
1757
1759
NSString *dataURLString = RCTDataURL (MIMETypeString, imageData).absoluteString ;
1758
1760
@@ -1761,8 +1763,8 @@ - (void)buildDataTransferItems:(std::vector<DataTransferItem> &)dataTransferItem
1761
1763
.type = MIMETypeString ? MIMETypeString.UTF8String : " " ,
1762
1764
.uri = dataURLString ? dataURLString.UTF8String : " " ,
1763
1765
.size = static_cast <int >(imageData.length ),
1764
- .width = static_cast <int >(image. size . width ),
1765
- .height = static_cast <int >(image. size . height ),
1766
+ .width = static_cast <int >(CGImageGetWidth (cgImage) ),
1767
+ .height = static_cast <int >(CGImageGetHeight (cgImage) ),
1766
1768
};
1767
1769
1768
1770
dataTransferItems.push_back (transferItem);
0 commit comments