--- a/ImageReader.st Tue Jan 16 16:21:26 2018 +0100
+++ b/ImageReader.st Tue Jan 16 16:24:03 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
@@ -24,6 +26,13 @@
category:'Graphics-Images-Readers'
!
+Query subclass:#EnforcedImageTypeQuery
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:ImageReader
+!
+
!ImageReader primitiveDefinitions!
%{
@@ -2373,6 +2382,22 @@
^ self == ImageReader.
! !
+!ImageReader class methodsFor:'signal constants'!
+
+enforcedImageTypeQuery
+ "the query signal which can be used to override the default type
+ of image as returned by a reader.
+ Currently, only PNGReader supports.
+ Usage:
+ ImageReader enforcedImageTypeQuery answer:#rgb
+ do:[
+ Image fromFile:anRGBAFile
+ ]
+ "
+
+ ^ EnforcedImageTypeQuery
+! !
+
!ImageReader class methodsFor:'testing'!
canRepresent:anImage
@@ -2885,6 +2910,38 @@
].
! !
+!ImageReader::EnforcedImageTypeQuery class methodsFor:'documentation'!
+
+documentation
+"
+ consider this a hack (but a not too bad one):
+
+ with pngReader (and maybe others), we may want to read an image file,
+ but ignore the alpha channel.
+ I.e. read it as an rgb image although the image file is actually rgba formatted.
+ This is useful, if the image contains invalid alpha information anyway,
+ as when asking appium for a screen shot
+ (there are no transparent pixels on the screen - at least not until we get glass-plate displays...)
+
+ Instead of passing this information down through all the possible image and image reader interfaces,
+ this query is asked by some readers (currently only pngReader) and
+ can be answered high above by a caller to answer #rgb.
+
+ The default answer (nil) leads to the old behavior in that the file itself determines the format.
+ Please take a look at the concrete image reader documentation for which answers are valid and useful.
+
+ [author:]
+ cg
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+
+"
+! !
+
!ImageReader class methodsFor:'documentation'!
version