@@ -10,6 +10,7 @@ import DeveloperError from "./DeveloperError.js";
1010import getAbsoluteUri from "./getAbsoluteUri.js" ;
1111import getBaseUri from "./getBaseUri.js" ;
1212import getExtensionFromUri from "./getExtensionFromUri.js" ;
13+ import getImagePixels from "./getImagePixels.js" ;
1314import isBlobUri from "./isBlobUri.js" ;
1415import isCrossOriginUrl from "./isCrossOriginUrl.js" ;
1516import isDataUri from "./isDataUri.js" ;
@@ -349,21 +350,6 @@ Resource.createIfNeeded = function (resource) {
349350 } ) ;
350351} ;
351352
352- function getColorOfFirstPixel ( imageBitmap ) {
353- const canvas = document . createElement ( "canvas" ) ;
354- const context = canvas . getContext ( "2d" ) ;
355- canvas . width = 1 ;
356- canvas . height = 1 ;
357- context . drawImage ( imageBitmap , 0 , 0 , 1 , 1 ) ;
358- const imageData = context . getImageData ( 0 , 0 , 1 , 1 ) ;
359- return [
360- imageData . data [ 0 ] ,
361- imageData . data [ 1 ] ,
362- imageData . data [ 2 ] ,
363- imageData . data [ 3 ] ,
364- ] ;
365- }
366-
367353let supportsImageBitmapOptionsPromise ;
368354/**
369355 * A helper function to check whether createImageBitmap supports passing ImageBitmapOptions.
@@ -411,8 +397,8 @@ Resource.supportsImageBitmapOptions = function () {
411397 } )
412398 . then ( function ( imageBitmaps ) {
413399 // Check whether the colorSpaceConversion option had any effect on the green channel
414- const colorWithOptions = getColorOfFirstPixel ( imageBitmaps [ 0 ] ) ;
415- const colorWithDefaults = getColorOfFirstPixel ( imageBitmaps [ 1 ] ) ;
400+ const colorWithOptions = getImagePixels ( imageBitmaps [ 0 ] ) ;
401+ const colorWithDefaults = getImagePixels ( imageBitmaps [ 1 ] ) ;
416402 return colorWithOptions [ 1 ] !== colorWithDefaults [ 1 ] ;
417403 } )
418404 . otherwise ( function ( ) {
0 commit comments