44
55namespace Intervention \Image \Drivers \Gd \Analyzers ;
66
7- use GdImage ;
87use Intervention \Image \Analyzers \PixelColorAnalyzer as GenericPixelColorAnalyzer ;
98use Intervention \Image \Exceptions \AnalyzerException ;
109use Intervention \Image \Exceptions \InvalidArgumentException ;
1110use Intervention \Image \Exceptions \StateException ;
1211use Intervention \Image \Interfaces \ColorInterface ;
13- use Intervention \Image \Interfaces \ColorspaceInterface ;
12+ use Intervention \Image \Interfaces \ColorProcessorInterface ;
13+ use Intervention \Image \Interfaces \FrameInterface ;
1414use Intervention \Image \Interfaces \ImageInterface ;
1515use Intervention \Image \Interfaces \SpecializedInterface ;
1616use ValueError ;
@@ -28,19 +28,14 @@ class PixelColorAnalyzer extends GenericPixelColorAnalyzer implements Specialize
2828 */
2929 public function analyze (ImageInterface $ image ): mixed
3030 {
31- return $ this ->colorAt (
32- $ image ->colorspace (),
33- $ image ->core ()->frame ($ this ->frame )->native ()
34- );
31+ $ colorProcessor = $ this ->driver ()->colorProcessor ($ image );
32+
33+ return $ this ->colorAt ($ colorProcessor , $ image ->core ()->frame ($ this ->frame ));
3534 }
3635
37- /**
38- * @throws InvalidArgumentException
39- * @throws AnalyzerException
40- * @throws StateException
41- */
42- protected function colorAt (ColorspaceInterface $ colorspace , GdImage $ gd ): ColorInterface
36+ protected function colorAt (ColorProcessorInterface $ processor , FrameInterface $ frame ): ColorInterface
4337 {
38+ $ gd = $ frame ->native ();
4439 $ index = @imagecolorat ($ gd , $ this ->x , $ this ->y );
4540
4641 if (!is_int ($ index )) {
@@ -57,6 +52,6 @@ protected function colorAt(ColorspaceInterface $colorspace, GdImage $gd): ColorI
5752 );
5853 }
5954
60- return $ this -> driver ()-> colorProcessor ( $ colorspace ) ->nativeToColor ($ index );
55+ return $ processor ->nativeToColor ($ index );
6156 }
6257}
0 commit comments