Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions packages/react-native/Libraries/Image/RCTImageLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,6 @@ static NSInteger RCTImageBytesForImage(RCTPlatformImage *image) // [macOS]
#endif // macOS]
}

#if TARGET_OS_OSX // [macOS

/**
* Github #1611 - We can't depend on RCTUIKit here, because this file's podspec (React-RCTImage) doesn't
* take a dependency on RCTUIKit's pod `React-Core`. Let's just copy the methods we want to shim here
*/

static NSData *NSImageDataForFileType(NSImage *image, NSBitmapImageFileType fileType, NSDictionary<NSString *, id> *properties)
{
RCTAssert(image.representations.count == 1, @"Expected only a single representation since UIImage only supports one.");

NSBitmapImageRep *imageRep = (NSBitmapImageRep *)image.representations.firstObject;
if (![imageRep isKindOfClass:[NSBitmapImageRep class]]) {
RCTAssert([imageRep isKindOfClass:[NSBitmapImageRep class]], @"We need an NSBitmapImageRep to create an image.");
return nil;
}

return [imageRep representationUsingType:fileType properties:properties];
}


NSData *UIImagePNGRepresentation(NSImage *image) {
return NSImageDataForFileType(image, NSBitmapImageFileTypePNG, @{});
}

NSData *UIImageJPEGRepresentation(NSImage *image, CGFloat compressionQuality) {
return NSImageDataForFileType(image,
NSBitmapImageFileTypeJPEG,
@{NSImageCompressionFactor: @(compressionQuality)});
}
#endif // macOS]

static auto currentRequestCount = std::atomic<uint64_t>(0);

static NSError *addResponseHeadersToError(NSError *originalError, NSHTTPURLResponse *response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,16 @@ NS_INLINE NSImage *UIImageWithData(NSData *imageData)
// MARK: - Image encoding (macOS only)

#if TARGET_OS_OSX
#ifdef __cplusplus
extern "C" {
#endif

NSData *UIImagePNGRepresentation(NSImage *image);
NSData *UIImageJPEGRepresentation(NSImage *image, CGFloat compressionQuality);

#ifdef __cplusplus
}
#endif
#endif

NS_ASSUME_NONNULL_END