Skip to content

Commit 09995fc

Browse files
zhongwuzwfacebook-github-bot
authored andcommittedDec 31, 2024·
Change Image load event size info from logical size to pixel (#45198)
Summary: Fixes #45188. This fixes old arch. fabric fix may wait until #44918. ## Changelog: [IOS] [BREAKING] - Change Image load event size info from logical size to pixel Pull Request resolved: #45198 Test Plan: Android/iOS return the same size . ``` <Image style={{width: '100%', height: '100%'}} source={{ uri: 'https://image-placeholder.com/images/actual-size/75x75.png', }} resizeMode={'cover'} onLoad={e => { console.log( `RNImage:${Platform.OS} load JPEG image from url`, e.nativeEvent, ); }} /> ``` Reviewed By: cortinico Differential Revision: D67735347 Pulled By: cipolleschi fbshipit-source-id: 72422d8c15e4cc6313215bf6d9a2c1e6b5a235ad
1 parent b10491a commit 09995fc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎packages/react-native/Libraries/Image/RCTImageView.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ static BOOL RCTShouldReloadImageForSizeChange(CGSize currentSize, CGSize idealSi
4141
{
4242
NSDictionary *dict = @{
4343
@"uri" : source.request.URL.absoluteString,
44-
@"width" : @(source.size.width),
45-
@"height" : @(source.size.height),
44+
@"width" : @(source.size.width * source.scale),
45+
@"height" : @(source.size.height * source.scale),
4646
};
4747
return @{@"source" : dict};
4848
}
@@ -406,7 +406,7 @@ - (void)imageLoaderLoadedImage:(UIImage *)loadedImage
406406
}
407407
} else {
408408
if (strongSelf->_onLoad) {
409-
RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:source.scale];
409+
RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:image.scale];
410410
strongSelf->_onLoad(onLoadParamsForSource(sourceLoaded));
411411
}
412412
if (strongSelf->_onLoadEnd) {

‎packages/react-native/ReactCommon/react/renderer/components/image/ImageEventEmitter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ void ImageEventEmitter::onLoad(const ImageSource& source) const {
1717
dispatchEvent("load", [source](jsi::Runtime& runtime) {
1818
auto src = jsi::Object(runtime);
1919
src.setProperty(runtime, "uri", source.uri);
20-
src.setProperty(runtime, "width", source.size.width);
21-
src.setProperty(runtime, "height", source.size.height);
20+
src.setProperty(runtime, "width", source.size.width * source.scale);
21+
src.setProperty(runtime, "height", source.size.height * source.scale);
2222
auto payload = jsi::Object(runtime);
2323
payload.setProperty(runtime, "source", src);
2424
return payload;

0 commit comments

Comments
 (0)