@@ -258,35 +258,36 @@ export class Img extends ImageBase {
258258 const height = layout . getMeasureSpecSize ( heightMeasureSpec ) ;
259259 const heightMode = layout . getMeasureSpecMode ( heightMeasureSpec ) ;
260260
261- const image = this . nativeViewProtected . image ;
262-
263- // const measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
264- // const measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
261+ if ( this . nativeViewProtected ) {
262+ const image = this . nativeViewProtected . image ;
263+ // const measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
264+ // const measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
265265
266- const finiteWidth : boolean = widthMode === layout . EXACTLY ;
267- const finiteHeight : boolean = heightMode === layout . EXACTLY ;
268- this . _imageSourceAffectsLayout = ! finiteWidth || ! finiteHeight ;
269- if ( Trace . isEnabled ( ) ) {
270- CLog ( CLogTypes . info , 'onMeasure' , this . src , widthMeasureSpec , heightMeasureSpec , width , height , this . aspectRatio , image && image . imageOrientation ) ;
271- }
272- if ( image || this . aspectRatio > 0 ) {
273- const nativeWidth = image ? layout . toDevicePixels ( image . size . width ) : 0 ;
274- const nativeHeight = image ? layout . toDevicePixels ( image . size . height ) : 0 ;
275- const imgRatio = nativeWidth / nativeHeight ;
276- const ratio = this . aspectRatio || imgRatio ;
277- // const scale = this.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.aspectRatio || imgRatio );
278-
279- if ( ! finiteWidth ) {
280- widthMeasureSpec = layout . makeMeasureSpec ( height * ratio , layout . EXACTLY ) ;
281- }
282- if ( ! finiteHeight ) {
283- heightMeasureSpec = layout . makeMeasureSpec ( width / ratio , layout . EXACTLY ) ;
266+ const finiteWidth : boolean = widthMode === layout . EXACTLY ;
267+ const finiteHeight : boolean = heightMode === layout . EXACTLY ;
268+ this . _imageSourceAffectsLayout = ! finiteWidth || ! finiteHeight ;
269+ if ( Trace . isEnabled ( ) ) {
270+ CLog ( CLogTypes . info , 'onMeasure' , this . src , widthMeasureSpec , heightMeasureSpec , width , height , this . aspectRatio , image && image . imageOrientation ) ;
284271 }
272+ if ( image || this . aspectRatio > 0 ) {
273+ const nativeWidth = image ? layout . toDevicePixels ( image . size . width ) : 0 ;
274+ const nativeHeight = image ? layout . toDevicePixels ( image . size . height ) : 0 ;
275+ const imgRatio = nativeWidth / nativeHeight ;
276+ const ratio = this . aspectRatio || imgRatio ;
277+ // const scale = this.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.aspectRatio || imgRatio );
278+
279+ if ( ! finiteWidth ) {
280+ widthMeasureSpec = layout . makeMeasureSpec ( height * ratio , layout . EXACTLY ) ;
281+ }
282+ if ( ! finiteHeight ) {
283+ heightMeasureSpec = layout . makeMeasureSpec ( width / ratio , layout . EXACTLY ) ;
284+ }
285285
286- if ( Trace . isEnabled ( ) ) {
287- CLog ( CLogTypes . info , 'onMeasure scale' , this . src , this . aspectRatio , finiteWidth , finiteHeight , width , height , nativeWidth , nativeHeight , widthMeasureSpec , heightMeasureSpec ) ;
286+ if ( Trace . isEnabled ( ) ) {
287+ CLog ( CLogTypes . info , 'onMeasure scale' , this . src , this . aspectRatio , finiteWidth , finiteHeight , width , height , nativeWidth , nativeHeight , widthMeasureSpec , heightMeasureSpec ) ;
288+ }
288289 }
289- }
290+ }
290291 super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ;
291292
292293 // const widthAndState = Img.resolveSizeAndState(measureWidth, width, widthMode, 0);
0 commit comments