--- a/Image.st Mon Nov 26 22:03:24 2001 +0100
+++ b/Image.st Wed Nov 28 14:24:51 2001 +0100
@@ -245,319 +245,319 @@
any default bitmaps, or make certain that your application
finds its bitmaps - even if they are in a separate directory)
- [exBegin]
- (Image fromFile:'goodies/bitmaps/gifImages/claus.gif') inspect
- [exEnd]
- [exBegin]
- (Image fromFile:'libtool/bitmaps/SmalltalkX.xbm') inspect
- [exEnd]
- [exBegin]
- (Image fromFile:'goodies/bitmaps/winBitmaps/okSmily_up.bmp') inspect
- [exEnd]
+ [exBegin]
+ (Image fromFile:'goodies/bitmaps/gifImages/claus.gif') inspect
+ [exEnd]
+ [exBegin]
+ (Image fromFile:'libtool/bitmaps/SmalltalkX.xbm') inspect
+ [exEnd]
+ [exBegin]
+ (Image fromFile:'goodies/bitmaps/winBitmaps/okSmily_up.bmp') inspect
+ [exEnd]
The following examples demonstrate various depth
and colorMap variations ...
inline image:
default: depth=1 & #blackIs0
- [exBegin]
- (Image width:8 height:8
- fromArray:#( 2r11111111
- 2r10000001
- 2r10000001
- 2r10000001
- 2r10000001
- 2r10000001
- 2r10000001
- 2r11111111 )) inspect
- [exEnd]
+ [exBegin]
+ (Image width:8 height:8
+ fromArray:#( 2r11111111
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r11111111 )) inspect
+ [exEnd]
with #whiteIs0 photometric
- [exBegin]
- ((Image width:8 height:8
- fromArray:#( 2r11111111
- 2r10000001
- 2r10000001
- 2r10000001
- 2r10000001
- 2r10000001
- 2r10000001
- 2r11111111 ))
- photometric:#whiteIs0)
- inspect
- [exEnd]
+ [exBegin]
+ ((Image width:8 height:8
+ fromArray:#( 2r11111111
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r11111111 ))
+ photometric:#whiteIs0)
+ inspect
+ [exEnd]
with a colorMap
- [exBegin]
- ((Image width:8 height:8
- fromArray:#( 2r11111111
- 2r10000001
- 2r10000001
- 2r10000001
- 2r10000001
- 2r10000001
- 2r10000001
- 2r11111111 ))
- colorMap:(Array with:(Color red)
- with:(Color yellow)))
- inspect
- [exEnd]
+ [exBegin]
+ ((Image width:8 height:8
+ fromArray:#( 2r11111111
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r10000001
+ 2r11111111 ))
+ colorMap:(Array with:(Color red)
+ with:(Color yellow)))
+ inspect
+ [exEnd]
a depth4 greyScale image:
(default photometric is #blackIs0)
- [exBegin]
- (Depth4Image
- width:8
- height:4
- fromArray:#[
- 16r00 16r11 16r22 16r33
- 16r44 16r55 16r66 16r77
- 16r88 16r99 16raa 16rbb
- 16rcc 16rdd 16ree 16rff
- ]) inspect
- [exEnd]
+ [exBegin]
+ (Depth4Image
+ width:8
+ height:4
+ fromArray:#[
+ 16r00 16r11 16r22 16r33
+ 16r44 16r55 16r66 16r77
+ 16r88 16r99 16raa 16rbb
+ 16rcc 16rdd 16ree 16rff
+ ]) inspect
+ [exEnd]
the same, magnified:
- [exBegin]
- ((Depth4Image
- width:4
- height:4
- fromArray:#[
- 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref
- ])
- magnifiedBy:30)
- inspect
- [exEnd]
+ [exBegin]
+ ((Depth4Image
+ width:4
+ height:4
+ fromArray:#[
+ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref
+ ])
+ magnifiedBy:30)
+ inspect
+ [exEnd]
the following has the same effect:
- [exBegin]
- ((Image
- width:4
- height:4
- depth:4
- fromArray:#[
- 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref
- ])
- magnifiedBy:30)
- inspect
- [exEnd]
+ [exBegin]
+ ((Image
+ width:4
+ height:4
+ depth:4
+ fromArray:#[
+ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref
+ ])
+ magnifiedBy:30)
+ inspect
+ [exEnd]
with reverse grey-interpretation:
- [exBegin]
- ((Depth4Image
- width:4
- height:4
- fromArray:#[
- 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref
- ])
- photometric:#whiteIs0;
- magnifiedBy:30)
- inspect
- [exEnd]
+ [exBegin]
+ ((Depth4Image
+ width:4
+ height:4
+ fromArray:#[
+ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref
+ ])
+ photometric:#whiteIs0;
+ magnifiedBy:30)
+ inspect
+ [exEnd]
with 1-bit-per-pixel rgb interpretation:
- [exBegin]
- ((Depth4Image
- width:4
- height:4
- fromArray:#[
- 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref
- ])
- photometric:#rgb;
- samplesPerPixel:3;
- bitsPerSample:#(1 1 1);
- magnifiedBy:30)
- inspect
- [exEnd]
+ [exBegin]
+ ((Depth4Image
+ width:4
+ height:4
+ fromArray:#[
+ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref
+ ])
+ photometric:#rgb;
+ samplesPerPixel:3;
+ bitsPerSample:#(1 1 1);
+ magnifiedBy:30)
+ inspect
+ [exEnd]
with 1/2/1 rgb interpretation:
- [exBegin]
- ((Depth4Image
- width:4
- height:4
- fromArray:#[
- 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref
- ])
- photometric:#rgb;
- samplesPerPixel:3;
- bitsPerSample:#(1 2 1);
- magnifiedBy:30)
- inspect
- [exEnd]
+ [exBegin]
+ ((Depth4Image
+ width:4
+ height:4
+ fromArray:#[
+ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref
+ ])
+ photometric:#rgb;
+ samplesPerPixel:3;
+ bitsPerSample:#(1 2 1);
+ magnifiedBy:30)
+ inspect
+ [exEnd]
a 2/2/0 rgb image (i.e. no blue):
- [exBegin]
- |i|
-
- i := Depth4Image
- width:4
- height:4
- fromArray:#[ 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref ].
- i photometric:#rgb.
- i samplesPerPixel:3.
- i bitsPerSample:#(2 2 0).
-
- i := i magnifiedBy:30.
- i inspect.
- [exEnd]
+ [exBegin]
+ |i|
+
+ i := Depth4Image
+ width:4
+ height:4
+ fromArray:#[ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref ].
+ i photometric:#rgb.
+ i samplesPerPixel:3.
+ i bitsPerSample:#(2 2 0).
+
+ i := i magnifiedBy:30.
+ i inspect.
+ [exEnd]
a 0/0/4 rgb image (i.e. no red or green):
- [exBegin]
- |i|
-
- i := Depth4Image
- width:4
- height:4
- fromArray:#[ 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref ].
- i photometric:#rgb.
- i samplesPerPixel:3.
- i bitsPerSample:#(0 0 4).
-
- i := i magnifiedBy:30.
- i inspect.
- [exEnd]
+ [exBegin]
+ |i|
+
+ i := Depth4Image
+ width:4
+ height:4
+ fromArray:#[ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref ].
+ i photometric:#rgb.
+ i samplesPerPixel:3.
+ i bitsPerSample:#(0 0 4).
+
+ i := i magnifiedBy:30.
+ i inspect.
+ [exEnd]
a 2plane greyscale image:
- [exBegin]
- ((Depth2Image
- width:4
- height:4
- fromArray:#[
- 4r0123
- 4r1230
- 4r2301
- 4r3012
- ])
- magnifiedBy:30)
- inspect
- [exEnd]
+ [exBegin]
+ ((Depth2Image
+ width:4
+ height:4
+ fromArray:#[
+ 4r0123
+ 4r1230
+ 4r2301
+ 4r3012
+ ])
+ magnifiedBy:30)
+ inspect
+ [exEnd]
with colors:
- [exBegin]
- ((Depth2Image
- width:4
- height:4
- fromArray:#[
- 4r0123
- 4r1230
- 4r2301
- 4r3012
- ])
- colorMap:(Array with:(Color black)
- with:(Color red)
- with:(Color green)
- with:(Color blue));
- magnifiedBy:30)
- inspect
- [exEnd]
+ [exBegin]
+ ((Depth2Image
+ width:4
+ height:4
+ fromArray:#[
+ 4r0123
+ 4r1230
+ 4r2301
+ 4r3012
+ ])
+ colorMap:(Array with:(Color black)
+ with:(Color red)
+ with:(Color green)
+ with:(Color blue));
+ magnifiedBy:30)
+ inspect
+ [exEnd]
depth8 image with 3/3/2 rgb interpretation:
- [exBegin]
- ((Depth8Image
- width:16
- height:16
- fromArray:(ByteArray withAll:(0 to:16rFF)))
- photometric:#rgb;
- samplesPerPixel:3;
- bitsPerSample:#(3 3 2);
- magnifiedBy:10)
- inspect
- [exEnd]
+ [exBegin]
+ ((Depth8Image
+ width:16
+ height:16
+ fromArray:(ByteArray withAll:(0 to:16rFF)))
+ photometric:#rgb;
+ samplesPerPixel:3;
+ bitsPerSample:#(3 3 2);
+ magnifiedBy:10)
+ inspect
+ [exEnd]
depth8 image with 2/2/2 rgb interpretation:
- [exBegin]
- ((Depth8Image
- width:8
- height:8
- fromArray:(ByteArray withAll:(0 to:16r3F)))
- photometric:#rgb;
- samplesPerPixel:3;
- bitsPerSample:#(2 2 2);
- magnifiedBy:10)
- inspect
- [exEnd]
+ [exBegin]
+ ((Depth8Image
+ width:8
+ height:8
+ fromArray:(ByteArray withAll:(0 to:16r3F)))
+ photometric:#rgb;
+ samplesPerPixel:3;
+ bitsPerSample:#(2 2 2);
+ magnifiedBy:10)
+ inspect
+ [exEnd]
trueColor image:
- [exBegin]
- ((Depth24Image
- width:4
- height:4
- fromArray:#[
- 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00
- 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00
- 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF
- 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
- ])
- photometric:#rgb;
- samplesPerPixel:3;
- bitsPerSample:#(8 8 8);
- magnifiedBy:30)
- inspect
- [exEnd]
+ [exBegin]
+ ((Depth24Image
+ width:4
+ height:4
+ fromArray:#[
+ 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00
+ 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00
+ 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF
+ 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
+ ])
+ photometric:#rgb;
+ samplesPerPixel:3;
+ bitsPerSample:#(8 8 8);
+ magnifiedBy:30)
+ inspect
+ [exEnd]
storing - only a few formats (TIFF, XBM, XPM) currently support storing:
- [exBegin]
- |img|
-
- img := Image fromFile:'goodies/bitmaps/winBitmaps/okSmily_up.bmp'.
- img saveOn:'myImage.tiff'.
- (Image fromFile:'myImage.tiff') inspect
- [exEnd]
+ [exBegin]
+ |img|
+
+ img := Image fromFile:'goodies/bitmaps/winBitmaps/okSmily_up.bmp'.
+ img saveOn:'myImage.tiff'.
+ (Image fromFile:'myImage.tiff') inspect
+ [exEnd]
magnifying (any factor):
- [exBegin]
- ((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
- magnifiedTo:(48@48))
- inspect
- [exEnd]
- [exBegin]
- ((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
- magnifiedBy:0.7)
- inspect
- [exEnd]
+ [exBegin]
+ ((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
+ magnifiedTo:(48@48))
+ inspect
+ [exEnd]
+ [exBegin]
+ ((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
+ magnifiedBy:0.7)
+ inspect
+ [exEnd]
rotating:
- [exBegin]
- ((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
- rotated:90)
- inspect
- [exEnd]
- [exBegin]
- (((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
- magnifiedBy:0.3@0.7) rotated:270)
- inspect
- [exEnd]
- [exBegin]
- (((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
- ) rotated:30)
- inspect
- [exEnd]
+ [exBegin]
+ ((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
+ rotated:90)
+ inspect
+ [exEnd]
+ [exBegin]
+ (((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
+ magnifiedBy:0.3@0.7) rotated:270)
+ inspect
+ [exEnd]
+ [exBegin]
+ (((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
+ ) rotated:30)
+ inspect
+ [exEnd]
negative:
- [exBegin]
- ((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
- negative)
- inspect
- [exEnd]
+ [exBegin]
+ ((Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
+ negative)
+ inspect
+ [exEnd]
"
! !
@@ -873,7 +873,7 @@
(self == Image
or:[anImage class == self
- and:[photometricOrNil isNil or:[photometricOrNil == anImage photometric]]]) ifTrue:[^ anImage].
+ and:[photometricOrNil isNil or:[photometricOrNil == anImage photometric]]]) ifTrue:[^ anImage].
^ self new fromImage:anImage photometric:photometricOrNil.
"
@@ -945,9 +945,9 @@
|cls newImage|
self == Image ifTrue:[
- cls := (self implementorForDepth:anImage depth).
+ cls := (self implementorForDepth:anImage depth).
] ifFalse:[
- cls := self.
+ cls := self.
].
newImage := cls new.
^ newImage fromSubImage:anImage in:aRectangle.
@@ -1300,19 +1300,19 @@
inStream := Smalltalk systemFileStreamFor:name.
inStream isNil ifTrue:[
- inStream := Smalltalk bitmapFileStreamFor:name.
- inStream isNil ifTrue:[
-
- "/ this signal is a query - if noone seems to
- "/ care, return nil.
- "/ However, a handler may provide a replacement.
+ inStream := Smalltalk bitmapFileStreamFor:name.
+ inStream isNil ifTrue:[
+
+ "/ this signal is a query - if noone seems to
+ "/ care, return nil.
+ "/ However, a handler may provide a replacement.
"/ ('IMAGE: ' , aFileName , ' does not exist or is not readable') infoPrintCR.
- ^ ImageNotFoundQuerySignal
- raiseRequestWith:aFileName
- errorString:('IMAGE [warning]: ''' , aFileName asFilename pathName, ''' does not exist or is not readable').
- ].
- name := 'bitmaps/' , name.
+ ^ ImageNotFoundQuerySignal
+ raiseRequestWith:aFileName
+ errorString:('IMAGE [warning]: ''' , aFileName asFilename pathName, ''' does not exist or is not readable').
+ ].
+ name := 'bitmaps/' , name.
].
inStream notNil ifTrue:[pathName := inStream pathName].
inStream close.
@@ -1325,14 +1325,14 @@
"/ handle compressed-suffix
"/
(#('Z' 'gz') includes:suffix) ifTrue:[
- fn := fn withoutSuffix.
- nm := fn name.
- suffix := fn suffix.
- mustDecompress := true.
+ fn := fn withoutSuffix.
+ nm := fn name.
+ suffix := fn suffix.
+ mustDecompress := true.
].
suffix isEmpty ifTrue:[
- suffix := nm.
+ suffix := nm.
].
"/ get the imageReader class from the files extension
@@ -1340,26 +1340,26 @@
readerClass := MIMETypes imageReaderForSuffix:suffix.
readerClass notNil ifTrue:[
- mustDecompress == true ifTrue:[
- inPipe := PipeStream readingFrom:'gunzip <' , pathName.
- inPipe notNil ifTrue:[
- [
- image := readerClass fromStream:inPipe.
- ] valueNowOrOnUnwindDo:[
- inPipe close
- ].
- image notNil ifTrue:[^ image].
- ]
- ] ifFalse:[
- BadImageFormatQuerySignal handle:[:ex |
- (readersErrorMsg := ex errorString) infoPrintCR.
- image := nil.
- ex return.
- ] do:[
- image := readerClass fromFile:name.
- ].
- image notNil ifTrue:[^ image].
- ]
+ mustDecompress == true ifTrue:[
+ inPipe := PipeStream readingFrom:'gunzip <' , pathName.
+ inPipe notNil ifTrue:[
+ [
+ image := readerClass fromStream:inPipe.
+ ] valueNowOrOnUnwindDo:[
+ inPipe close
+ ].
+ image notNil ifTrue:[^ image].
+ ]
+ ] ifFalse:[
+ BadImageFormatQuerySignal handle:[:ex |
+ (readersErrorMsg := ex errorString) infoPrintCR.
+ image := nil.
+ ex return.
+ ] do:[
+ image := readerClass fromFile:name.
+ ].
+ image notNil ifTrue:[^ image].
+ ]
].
"
@@ -1369,15 +1369,15 @@
therefore, it takes a bit longer.
"
MIMETypes imageReaderClasses do:[:mimeReaderClass |
- (mimeReaderClass notNil
- and:[mimeReaderClass ~~ readerClass]) ifTrue:[
- (mimeReaderClass isValidImageFile:name) ifTrue:[
- image := mimeReaderClass fromFile:name.
- image notNil ifTrue:[
- ^ image
- ]
- ]
- ]
+ (mimeReaderClass notNil
+ and:[mimeReaderClass ~~ readerClass]) ifTrue:[
+ (mimeReaderClass isValidImageFile:name) ifTrue:[
+ image := mimeReaderClass fromFile:name.
+ image notNil ifTrue:[
+ ^ image
+ ]
+ ]
+ ]
].
"/ nope - unknown format
@@ -1388,8 +1388,8 @@
"/ 'IMAGE: unknown image file format: ' infoPrint. aFileName infoPrintNL.
^ ImageNotFoundQuerySignal
- raiseRequestWith:aFileName
- errorString:(readersErrorMsg ? ('IMAGE [warning]: unknown image file format: ''' , aFileName asFilename pathName , '''')).
+ raiseRequestWith:aFileName
+ errorString:(readersErrorMsg ? ('IMAGE [warning]: unknown image file format: ''' , aFileName asFilename pathName , '''')).
"
Image fromFile:'goodies/bitmaps/gifImages/claus.gif'
@@ -1408,10 +1408,10 @@
Image imageNotFoundQuerySignal
handle:[:ex |
- Transcript showCR:ex errorString.
- ex proceedWith:nil
+ Transcript showCR:ex errorString.
+ ex proceedWith:nil
] do:[
- Image fromFile:'fooBar'
+ Image fromFile:'fooBar'
]
"
@@ -1420,7 +1420,7 @@
Image imageNotFoundQuerySignal
answer:(Image fromFile:'bitmaps/SmalltalkX.xbm')
do:[
- Image fromFile:'fooBar'
+ Image fromFile:'fooBar'
]
"
@@ -1529,10 +1529,10 @@
this format ...
"
MIMETypes imageReaderClasses do:[:readerClass |
- readerClass notNil ifTrue:[
- image := readerClass fromStream:aStream.
- image notNil ifTrue:[^ image].
- ]
+ readerClass notNil ifTrue:[
+ image := readerClass fromStream:aStream.
+ image notNil ifTrue:[^ image].
+ ]
].
"
@@ -1541,8 +1541,8 @@
"/ 'Image [info]: unknown image file format in stream: ' infoPrintCR.
^ ImageNotFoundQuerySignal
- raiseRequestWith:aStream
- errorString:('IMAGE [warning]: unknown image file format in stream').
+ raiseRequestWith:aStream
+ errorString:('IMAGE [warning]: unknown image file format in stream').
"
Image fromFile:'goodies/bitmaps/dano.tiff'
@@ -1977,8 +1977,8 @@
the returned Image is NOT correct.
You may want to raise the view before using this method.
WARNING: with doGrab true, this temporarily grabs the display
- and it may not work from within a buttonMotion
- (use with a false grabArg then)."
+ and it may not work from within a buttonMotion
+ (use with a false grabArg then)."
|org device|
@@ -2682,8 +2682,8 @@
0 for masked pixels (invisible), 1 for unmasked (visible)."
mask isNil ifTrue:[
- maskValue == 1 ifTrue:[^ self].
- self error:'image has no mask'.
+ maskValue == 1 ifTrue:[^ self].
+ self error:'image has no mask'.
].
^ mask pixelAtX:x y:y put:maskValue
@@ -3331,9 +3331,9 @@
deviceDepth := aDevice depth.
deviceDepth == 8 ifFalse:[
- (aDevice supportedImageFormatForDepth:8) isNil ifTrue:[
- ^ nil.
- ]
+ (aDevice supportedImageFormatForDepth:8) isNil ifTrue:[
+ ^ nil.
+ ]
].
pseudoBits := self floydSteinbergDitheredDepth8BitsColors:fixColors.
@@ -3348,51 +3348,51 @@
"/
map := Array new:256.
fixColors do:[:clr |
- map at:clr colorId + 1 put:clr
+ map at:clr colorId + 1 put:clr
].
f colorMap:map.
f initGC.
f bits:pseudoBits.
aDevice
- drawBits:pseudoBits
- bitsPerPixel:8
- depth:deviceDepth
- padding:8
- width:width height:height
- x:0 y:0
- into:(f id) x:0 y:0
- width:width height:height
- with:(f gcId).
+ drawBits:pseudoBits
+ bitsPerPixel:8
+ depth:deviceDepth
+ padding:8
+ width:width height:height
+ x:0 y:0
+ into:(f id) x:0 y:0
+ width:width height:height
+ with:(f gcId).
^ f
"
example:
- color reduction from Depth8 to Depth4 (dithering) can be done by:
+ color reduction from Depth8 to Depth4 (dithering) can be done by:
|img8 reducedImg8 img4 map form|
map := #(
- (0 0 0)
- (0 0 100)
- (0 50 0)
- (0 50 100)
- (0 100 0)
- (0 100 100)
- (100 0 0)
- (100 0 100)
- (100 50 0)
- (100 50 100)
- (100 100 0)
- (100 100 100)) collect:[:rgb | (Color red:(rgb at:1)
- green:(rgb at:2)
- blue:(rgb at:3)) on:Display].
+ (0 0 0)
+ (0 0 100)
+ (0 50 0)
+ (0 50 100)
+ (0 100 0)
+ (0 100 100)
+ (100 0 0)
+ (100 0 100)
+ (100 50 0)
+ (100 50 100)
+ (100 100 0)
+ (100 100 100)) collect:[:rgb | (Color red:(rgb at:1)
+ green:(rgb at:2)
+ blue:(rgb at:3)) on:Display].
img8 := Image fromFile:'goodies/bitmaps/bf.im8'.
form := img8 paletteImageAsDitheredPseudoFormOn:Display
- colors:map
- nRed:2
- nGreen:3
- nBlue:2.
+ colors:map
+ nRed:2
+ nGreen:3
+ nBlue:2.
img8 := Depth8Image fromForm:form. 'dithered version of original image'.
img4 := Depth4Image fromImage:img8.
"
@@ -3414,9 +3414,9 @@
deviceDepth := aDevice depth.
deviceDepth == 8 ifFalse:[
- (aDevice supportedImageFormatForDepth:8) isNil ifTrue:[
- ^ nil
- ]
+ (aDevice supportedImageFormatForDepth:8) isNil ifTrue:[
+ ^ nil
+ ]
].
pseudoBits := self floydSteinbergDitheredDepth8BitsColors:fixColors nRed:nRed nGreen:nGreen nBlue:nBlue.
@@ -3431,51 +3431,51 @@
"/
map := Array new:256.
fixColors do:[:clr |
- map at:clr colorId + 1 put:clr
+ map at:clr colorId + 1 put:clr
].
f colorMap:map.
f initGC.
f bits:pseudoBits.
aDevice
- drawBits:pseudoBits
- bitsPerPixel:8
- depth:deviceDepth
- padding:8
- width:width height:height
- x:0 y:0
- into:(f id) x:0 y:0
- width:width height:height
- with:(f gcId).
+ drawBits:pseudoBits
+ bitsPerPixel:8
+ depth:deviceDepth
+ padding:8
+ width:width height:height
+ x:0 y:0
+ into:(f id) x:0 y:0
+ width:width height:height
+ with:(f gcId).
^ f
"
example:
- color reduction from Depth8 to Depth4 (dithering) can be done by:
+ color reduction from Depth8 to Depth4 (dithering) can be done by:
|img8 reducedImg8 img4 map form|
map := #(
- (0 0 0)
- (0 0 100)
- (0 50 0)
- (0 50 100)
- (0 100 0)
- (0 100 100)
- (100 0 0)
- (100 0 100)
- (100 50 0)
- (100 50 100)
- (100 100 0)
- (100 100 100)) collect:[:rgb | (Color red:(rgb at:1)
- green:(rgb at:2)
- blue:(rgb at:3)) on:Display].
+ (0 0 0)
+ (0 0 100)
+ (0 50 0)
+ (0 50 100)
+ (0 100 0)
+ (0 100 100)
+ (100 0 0)
+ (100 0 100)
+ (100 50 0)
+ (100 50 100)
+ (100 100 0)
+ (100 100 100)) collect:[:rgb | (Color red:(rgb at:1)
+ green:(rgb at:2)
+ blue:(rgb at:3)) on:Display].
img8 := Image fromFile:'goodies/bitmaps/bf.im8'.
form := img8 paletteImageAsDitheredPseudoFormOn:Display
- colors:map
- nRed:2
- nGreen:3
- nBlue:2.
+ colors:map
+ nRed:2
+ nGreen:3
+ nBlue:2.
img8 := Depth8Image fromForm:form. 'dithered version of original image'.
img4 := Depth4Image fromImage:img8.
"
@@ -3491,12 +3491,12 @@
depth := aDevice depth.
(depth == 1
or:[aDevice hasGrayscales not]) ifTrue:[
- "/ for monochrome, there is specialized
- "/ monochrome dither code available
-
- bits := self floydSteinbergDitheredMonochromeBits.
+ "/ for monochrome, there is specialized
+ "/ monochrome dither code available
+
+ bits := self floydSteinbergDitheredMonochromeBits.
] ifFalse:[
- bits := self floydSteinbergDitheredGrayBitsDepth:depth.
+ bits := self floydSteinbergDitheredGrayBitsDepth:depth.
].
^ self makeDeviceGrayPixmapOn:aDevice depth:depth fromArray:bits
@@ -3525,12 +3525,12 @@
|ditheredBits|
(depth == 1) ifTrue:[
- ^ self asFloydSteinbergDitheredMonochromeImage
+ ^ self asFloydSteinbergDitheredMonochromeImage
].
ditheredBits := self floydSteinbergDitheredGrayBitsDepth:depth.
^ (self class implementorForDepth:depth)
- width:width height:height fromArray:ditheredBits
+ width:width height:height fromArray:ditheredBits
"
|i|
@@ -3546,11 +3546,11 @@
|i|
i := Depth24Image width:4 height:1
- fromArray:#[
- 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00
- 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00
- 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00
- 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00].
+ fromArray:#[
+ 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00
+ 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00
+ 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00
+ 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00 16rFF 16r00 16r00].
i := i magnifiedBy:4@1.
i inspect.
@@ -3563,13 +3563,13 @@
|i|
i := Depth24Image width:4 height:6
- fromArray:#[
- 16r00 16r00 16r00 16r00 16r00 16r80 16r00 16r00 16rff 16r00 16r80 16r00
- 16r00 16r80 16r80 16r00 16rFF 16r00 16r00 16rFF 16r80 16r00 16rFF 16rFF
- 16r80 16r00 16r00 16r80 16r00 16r80 16r80 16r00 16rff 16r80 16r80 16r00
- 16r80 16r80 16r80 16r80 16rFF 16r00 16r80 16rFF 16r80 16r80 16rFF 16rFF
- 16rFF 16r00 16r00 16rFF 16r00 16r80 16rFF 16r00 16rff 16rFF 16r80 16r00
- 16rFF 16r80 16r80 16rFF 16rFF 16r00 16rFF 16rFF 16r80 16rFF 16rFF 16rFF].
+ fromArray:#[
+ 16r00 16r00 16r00 16r00 16r00 16r80 16r00 16r00 16rff 16r00 16r80 16r00
+ 16r00 16r80 16r80 16r00 16rFF 16r00 16r00 16rFF 16r80 16r00 16rFF 16rFF
+ 16r80 16r00 16r00 16r80 16r00 16r80 16r80 16r00 16rff 16r80 16r80 16r00
+ 16r80 16r80 16r80 16r80 16rFF 16r00 16r80 16rFF 16r80 16r80 16rFF 16rFF
+ 16rFF 16r00 16r00 16rFF 16r00 16r80 16rFF 16r00 16rff 16rFF 16r80 16r00
+ 16rFF 16r80 16r80 16rFF 16rFF 16r00 16rFF 16rFF 16r80 16rFF 16rFF 16rFF].
i := i magnifiedBy:30.
i inspect.
@@ -3601,14 +3601,14 @@
|i|
i := Depth4Image
- width:4
- height:4
- fromArray:#[
- 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref
- ].
+ width:4
+ height:4
+ fromArray:#[
+ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref
+ ].
i := i magnifiedBy:30.
i inspect.
(i asFloydSteinbergDitheredGrayImageDepth:1) inspect.
@@ -3639,16 +3639,16 @@
|i f|
i := Depth2Image width:8 height:8
- fromArray:#[
- 4r0000 4r0000
- 4r0000 4r0000
- 4r1111 4r1111
- 4r1111 4r1111
- 4r2222 4r2222
- 4r2222 4r2222
- 4r3333 4r3333
- 4r3333 4r3333
- ].
+ fromArray:#[
+ 4r0000 4r0000
+ 4r0000 4r0000
+ 4r1111 4r1111
+ 4r1111 4r1111
+ 4r2222 4r2222
+ 4r2222 4r2222
+ 4r3333 4r3333
+ 4r3333 4r3333
+ ].
(i asFloydSteinbergDitheredMonochromeFormOn:Display) inspect.
"
@@ -3688,14 +3688,14 @@
|i|
i := Depth4Image
- width:4
- height:4
- fromArray:#[
- 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref
- ].
+ width:4
+ height:4
+ fromArray:#[
+ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref
+ ].
i := i magnifiedBy:30.
i inspect.
i asFloydSteinbergDitheredMonochromeImage inspect.
@@ -3715,22 +3715,22 @@
deviceDepth := aDevice depth.
has8BitImage := (deviceDepth == 8)
- or:[ (aDevice supportedImageFormatForDepth:8) notNil ].
+ or:[ (aDevice supportedImageFormatForDepth:8) notNil ].
has8BitImage ifFalse:[
- deviceDepth == 4 ifFalse:[^ nil].
-
- pseudoBits8 := self nfloydSteinbergDitheredDepth8BitsColors:colors.
- pseudoBits8 isNil ifTrue:[^ nil].
- "/ convert to devices depth
-
- pseudoBits := ByteArray new:(width*4+7//8 * height).
- pseudoBits8 compressPixels:4 width:width height:height into:pseudoBits mapping:nil.
- d := 4.
+ deviceDepth == 4 ifFalse:[^ nil].
+
+ pseudoBits8 := self nfloydSteinbergDitheredDepth8BitsColors:colors.
+ pseudoBits8 isNil ifTrue:[^ nil].
+ "/ convert to devices depth
+
+ pseudoBits := ByteArray new:(width*4+7//8 * height).
+ pseudoBits8 compressPixels:4 width:width height:height into:pseudoBits mapping:nil.
+ d := 4.
] ifTrue:[
- pseudoBits := self nfloydSteinbergDitheredDepth8BitsColors:colors.
- pseudoBits isNil ifTrue:[^ nil].
- d := 8.
+ pseudoBits := self nfloydSteinbergDitheredDepth8BitsColors:colors.
+ pseudoBits isNil ifTrue:[^ nil].
+ d := 8.
].
f := Form width:width height:height depth:deviceDepth on:aDevice.
@@ -3742,23 +3742,23 @@
"/
map := Array new:256 withAll:0.
colors do:[:clr |
- clr notNil ifTrue:[
- map at:clr colorId + 1 put:clr
- ]
+ clr notNil ifTrue:[
+ map at:clr colorId + 1 put:clr
+ ]
].
f colorMap:map.
f initGC.
f bits:pseudoBits.
aDevice
- drawBits:pseudoBits
- bitsPerPixel:d
- depth:deviceDepth
- padding:8
- width:width height:height
- x:0 y:0
- into:(f id) x:0 y:0
- width:width height:height
- with:(f gcId).
+ drawBits:pseudoBits
+ bitsPerPixel:d
+ depth:deviceDepth
+ padding:8
+ width:width height:height
+ x:0 y:0
+ into:(f id) x:0 y:0
+ width:width height:height
+ with:(f gcId).
^ f
"
@@ -3929,28 +3929,28 @@
((aDevice == device) and:[monoDeviceForm notNil]) ifTrue:[^ monoDeviceForm].
depth == 1 ifTrue:[
- ((aDevice == device) and:[deviceForm notNil]) ifTrue:[^ deviceForm].
+ ((aDevice == device) and:[deviceForm notNil]) ifTrue:[^ deviceForm].
].
form := self asMonochromeFormOn:aDevice dither:DitherAlgorithm.
(device isNil or:[aDevice == device]) ifTrue:[
- "remember this form in the receiver ..."
-
- form notNil ifTrue:[
- monoDeviceForm := form.
- device isNil ifTrue:[
- device := aDevice.
- Lobby register:self
- ] ifFalse:[
- Lobby registerChange:self
- ].
- "
- can save space, by not keeping the images data-bits
- twice (here and in the device form)
- "
- form forgetBits
- ]
+ "remember this form in the receiver ..."
+
+ form notNil ifTrue:[
+ monoDeviceForm := form.
+ device isNil ifTrue:[
+ device := aDevice.
+ Lobby register:self
+ ] ifFalse:[
+ Lobby registerChange:self
+ ].
+ "
+ can save space, by not keeping the images data-bits
+ twice (here and in the device form)
+ "
+ form forgetBits
+ ]
].
^ form
@@ -4009,9 +4009,9 @@
deviceDepth := aDevice depth.
deviceDepth == 8 ifFalse:[
- (aDevice supportedImageFormatForDepth:8) isNil ifTrue:[
- ^ nil
- ]
+ (aDevice supportedImageFormatForDepth:8) isNil ifTrue:[
+ ^ nil
+ ]
].
pseudoBits := self nearestPaintDepth8BitsColors:fixColors.
@@ -4026,51 +4026,51 @@
"/
map := Array new:256.
fixColors do:[:clr |
- map at:clr colorId + 1 put:clr
+ map at:clr colorId + 1 put:clr
].
f colorMap:map.
f initGC.
f bits:pseudoBits.
aDevice
- drawBits:pseudoBits
- bitsPerPixel:8
- depth:deviceDepth
- padding:8
- width:width height:height
- x:0 y:0
- into:(f id) x:0 y:0
- width:width height:height
- with:(f gcId).
+ drawBits:pseudoBits
+ bitsPerPixel:8
+ depth:deviceDepth
+ padding:8
+ width:width height:height
+ x:0 y:0
+ into:(f id) x:0 y:0
+ width:width height:height
+ with:(f gcId).
^ f
"
example:
- color reduction from Depth8 to Depth4 (dithering) can be done by:
+ color reduction from Depth8 to Depth4 (dithering) can be done by:
|img8 reducedImg8 img4 map form|
map := #(
- (0 0 0)
- (0 0 100)
- (0 50 0)
- (0 50 100)
- (0 100 0)
- (0 100 100)
- (100 0 0)
- (100 0 100)
- (100 50 0)
- (100 50 100)
- (100 100 0)
- (100 100 100)) collect:[:rgb | (Color red:(rgb at:1)
- green:(rgb at:2)
- blue:(rgb at:3)) on:Display].
+ (0 0 0)
+ (0 0 100)
+ (0 50 0)
+ (0 50 100)
+ (0 100 0)
+ (0 100 100)
+ (100 0 0)
+ (100 0 100)
+ (100 50 0)
+ (100 50 100)
+ (100 100 0)
+ (100 100 100)) collect:[:rgb | (Color red:(rgb at:1)
+ green:(rgb at:2)
+ blue:(rgb at:3)) on:Display].
img8 := Image fromFile:'goodies/bitmaps/claus.gif'.
form := img8 asNearestPaintDepth8FormOn:Display
- colors:map
- nRed:2
- nGreen:3
- nBlue:2.
+ colors:map
+ nRed:2
+ nGreen:3
+ nBlue:2.
img8 := Depth8Image fromForm:form. 'dithered version of original image'.
img4 := Depth4Image fromImage:img8.
"
@@ -4092,9 +4092,9 @@
deviceDepth := aDevice depth.
deviceDepth == 8 ifFalse:[
- (aDevice supportedImageFormatForDepth:8) isNil ifTrue:[
- ^ nil
- ]
+ (aDevice supportedImageFormatForDepth:8) isNil ifTrue:[
+ ^ nil
+ ]
].
pseudoBits := self nearestPaintDepth8BitsColors:fixColors nRed:nRed nGreen:nGreen nBlue:nBlue.
@@ -4109,51 +4109,51 @@
"/
map := Array new:256.
fixColors do:[:clr |
- map at:clr colorId + 1 put:clr
+ map at:clr colorId + 1 put:clr
].
f colorMap:map.
f initGC.
f bits:pseudoBits.
aDevice
- drawBits:pseudoBits
- bitsPerPixel:8
- depth:deviceDepth
- padding:8
- width:width height:height
- x:0 y:0
- into:(f id) x:0 y:0
- width:width height:height
- with:(f gcId).
+ drawBits:pseudoBits
+ bitsPerPixel:8
+ depth:deviceDepth
+ padding:8
+ width:width height:height
+ x:0 y:0
+ into:(f id) x:0 y:0
+ width:width height:height
+ with:(f gcId).
^ f
"
example:
- color reduction from Depth8 to Depth4 (dithering) can be done by:
+ color reduction from Depth8 to Depth4 (dithering) can be done by:
|img8 reducedImg8 img4 map form|
map := #(
- (0 0 0)
- (0 0 100)
- (0 50 0)
- (0 50 100)
- (0 100 0)
- (0 100 100)
- (100 0 0)
- (100 0 100)
- (100 50 0)
- (100 50 100)
- (100 100 0)
- (100 100 100)) collect:[:rgb | (Color red:(rgb at:1)
- green:(rgb at:2)
- blue:(rgb at:3)) on:Display].
+ (0 0 0)
+ (0 0 100)
+ (0 50 0)
+ (0 50 100)
+ (0 100 0)
+ (0 100 100)
+ (100 0 0)
+ (100 0 100)
+ (100 50 0)
+ (100 50 100)
+ (100 100 0)
+ (100 100 100)) collect:[:rgb | (Color red:(rgb at:1)
+ green:(rgb at:2)
+ blue:(rgb at:3)) on:Display].
img8 := Image fromFile:'goodies/bitmaps/claus.gif'.
form := img8 asNearestPaintDepth8FormOn:Display
- colors:map
- nRed:2
- nGreen:3
- nBlue:2.
+ colors:map
+ nRed:2
+ nGreen:3
+ nBlue:2.
img8 := Depth8Image fromForm:form. 'dithered version of original image'.
img4 := Depth4Image fromImage:img8.
"
@@ -4171,16 +4171,16 @@
depth := aDevice depth.
(depth == 1
or:[aDevice hasGrayscales not]) ifTrue:[
- "/ for monochrome, there is highly specialized
- "/ monochrome dither code available
-
- ^ self asOrderedDitheredMonochromeFormOn:aDevice
+ "/ for monochrome, there is highly specialized
+ "/ monochrome dither code available
+
+ ^ self asOrderedDitheredMonochromeFormOn:aDevice
].
bits := self
- orderedDitheredGrayBitsWithDitherMatrix:(self class orderedDitherMatrixOfSize:8)
- ditherWidth:8
- depth:depth.
+ orderedDitheredGrayBitsWithDitherMatrix:(self class orderedDitherMatrixOfSize:8)
+ ditherWidth:8
+ depth:depth.
^ self makeDeviceGrayPixmapOn:aDevice depth:depth fromArray:bits
@@ -4203,26 +4203,26 @@
dither := self class orderedDitherMatrixOfSize:8.
(depth == 1) ifTrue:[
- "/ for monochrome, there is highly specialized
- "/ monochrome dither code available
-
- ^ Depth1Image
- width:width
- height:height
- fromArray:(
- self
- orderedDitheredMonochromeBitsWithDitherMatrix:dither
- ditherWidth:8)
+ "/ for monochrome, there is highly specialized
+ "/ monochrome dither code available
+
+ ^ Depth1Image
+ width:width
+ height:height
+ fromArray:(
+ self
+ orderedDitheredMonochromeBitsWithDitherMatrix:dither
+ ditherWidth:8)
].
^ (self class implementorForDepth:depth)
- width:width
- height:height
- fromArray:(
- self
- orderedDitheredGrayBitsWithDitherMatrix:dither
- ditherWidth:8
- depth:depth)
+ width:width
+ height:height
+ fromArray:(
+ self
+ orderedDitheredGrayBitsWithDitherMatrix:dither
+ ditherWidth:8
+ depth:depth)
"
|i i1 i2 i4 i8|
@@ -4277,9 +4277,9 @@
"/ 4x4 for small number of colors ...
^ self
- asOrderedDitheredMonochromeFormOn:aDevice
- ditherMatrix:(self class orderedDitherMatrixOfSize:4)
- ditherWidth:4
+ asOrderedDitheredMonochromeFormOn:aDevice
+ ditherMatrix:(self class orderedDitherMatrixOfSize:4)
+ ditherWidth:4
"/ ^ self
"/ asOrderedDitheredMonochromeFormOn:aDevice
@@ -4367,8 +4367,8 @@
"/ 4x4 for small number of colors ...
^ self
- asOrderedDitheredMonochromeImageWithDitherMatrix:(self class orderedDitherMatrixOfSize:4)
- ditherWidth:4
+ asOrderedDitheredMonochromeImageWithDitherMatrix:(self class orderedDitherMatrixOfSize:4)
+ ditherWidth:4
"/ ^ self
"/ asOrderedDitheredMonochromeImageWithDitherMatrix:(self class orderedDitherMatrixOfSize:8)
@@ -4704,16 +4704,16 @@
|depth|
(depth := aDevice depth) == 1 ifTrue:[
- ^ self asThresholdMonochromeFormOn:aDevice
+ ^ self asThresholdMonochromeFormOn:aDevice
].
^ self
- makeDeviceGrayPixmapOn:aDevice
- depth:depth
- fromArray:(self
- orderedDitheredGrayBitsWithDitherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
- ditherWidth:4
- depth:depth)
+ makeDeviceGrayPixmapOn:aDevice
+ depth:depth
+ fromArray:(self
+ orderedDitheredGrayBitsWithDitherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
+ ditherWidth:4
+ depth:depth)
"
|i|
@@ -4730,26 +4730,26 @@
"return a thresholded depth-x grey image from the receiver image."
(depth == 1) ifTrue:[
- "/ for monochrome, there is highly specialized
- "/ monochrome dither code available
-
- ^ Depth1Image
- width:width
- height:height
- fromArray:(
- self
- orderedDitheredMonochromeBitsWithDitherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
- ditherWidth:4)
+ "/ for monochrome, there is highly specialized
+ "/ monochrome dither code available
+
+ ^ Depth1Image
+ width:width
+ height:height
+ fromArray:(
+ self
+ orderedDitheredMonochromeBitsWithDitherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
+ ditherWidth:4)
].
^ (self class implementorForDepth:depth)
- width:width
- height:height
- fromArray:(
- self
- orderedDitheredGrayBitsWithDitherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
- ditherWidth:4
- depth:depth)
+ width:width
+ height:height
+ fromArray:(
+ self
+ orderedDitheredGrayBitsWithDitherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
+ ditherWidth:4
+ depth:depth)
"
|i|
@@ -4779,9 +4779,9 @@
"return a threshold monochrome form from the image."
^ self
- asOrderedDitheredMonochromeFormOn:aDevice
- ditherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
- ditherWidth:4
+ asOrderedDitheredMonochromeFormOn:aDevice
+ ditherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
+ ditherWidth:4
"
|i|
@@ -4821,8 +4821,8 @@
Threshold means: brightness < 0.5 -> black / otherwise white"
^ self
- asOrderedDitheredMonochromeImageWithDitherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
- ditherWidth:4
+ asOrderedDitheredMonochromeImageWithDitherMatrix:#[8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8]
+ ditherWidth:4
"
|i i2|
@@ -4864,17 +4864,17 @@
ditherMatrix := ByteArray new:256 withAll:(value truncated).
^ self
- asOrderedDitheredMonochromeImageWithDitherMatrix:ditherMatrix
- ditherWidth:16
+ asOrderedDitheredMonochromeImageWithDitherMatrix:ditherMatrix
+ ditherWidth:16
"
|i|
i := Image width:4 height:4 depth:4
- fromArray:#[ 16r01 16r23
- 16r45 16r67
- 16r89 16rab
- 16rcd 16ref ].
+ fromArray:#[ 16r01 16r23
+ 16r45 16r67
+ 16r89 16rab
+ 16rcd 16ref ].
i := i magnifiedBy:30.
i inspect.
(i asThresholdMonochromeImage:0.125) inspect.
@@ -5024,43 +5024,43 @@
((self depth = anImage depth)
and:[samePhotometric]) ifTrue:[
- bytes := anImage bits copy.
- ^ self.
+ bytes := anImage bits copy.
+ ^ self.
].
bytes := ByteArray uninitializedNew:(self bytesPerRow * height).
self depth >= anImage depth ifTrue:[
- anImage depth <= 12 ifTrue:[
-
- "/ if my depth is greater, all colors can be represented,
- "/ and the loop can be done over pixel values ...
-
- (colorMap isNil or:[samePhotometric not]) ifTrue:[
- map := Array new:(1 bitShift:anImage depth).
- 1 to:map size do:[:i |
- clr := anImage colorFromValue:(i - 1).
- map at:i put:(self valueFromColor:clr).
- ].
- ].
- mappedRowPixels := self pixelArraySpecies new:width.
- h := height-1.
- w := width.
- 0 to:h do:[:row |
- anImage rowAt:row into:mappedRowPixels startingAt:1.
- map notNil ifTrue:[
- 1 to:w do:[:i |
- mappedRowPixels at:i put:(map at:(mappedRowPixels at:i)+1)
- ].
- ].
- self rowAt:row putAll:mappedRowPixels
- ].
- ^ self
- ].
+ anImage depth <= 12 ifTrue:[
+
+ "/ if my depth is greater, all colors can be represented,
+ "/ and the loop can be done over pixel values ...
+
+ (colorMap isNil or:[samePhotometric not]) ifTrue:[
+ map := Array new:(1 bitShift:anImage depth).
+ 1 to:map size do:[:i |
+ clr := anImage colorFromValue:(i - 1).
+ map at:i put:(self valueFromColor:clr).
+ ].
+ ].
+ mappedRowPixels := self pixelArraySpecies new:width.
+ h := height-1.
+ w := width.
+ 0 to:h do:[:row |
+ anImage rowAt:row into:mappedRowPixels startingAt:1.
+ map notNil ifTrue:[
+ 1 to:w do:[:i |
+ mappedRowPixels at:i put:(map at:(mappedRowPixels at:i)+1)
+ ].
+ ].
+ self rowAt:row putAll:mappedRowPixels
+ ].
+ ^ self
+ ].
].
anImage colorsFromX:0 y:0 toX:(width-1) y:(height-1) do:[:x :y :clr |
- self colorAtX:x y:y put:clr
+ self colorAtX:x y:y put:clr
].
"
@@ -5083,9 +5083,9 @@
i := Image fromFile:'goodies/bitmaps/gifImages/garfield.gif'.
Transcript showCR:(
- Time millisecondsToRun:[
- i24 := Depth24Image fromImage:i.
- ]
+ Time millisecondsToRun:[
+ i24 := Depth24Image fromImage:i.
+ ]
).
i24 inspect.
"
@@ -5094,7 +5094,7 @@
i := Image fromFile:'goodies/bitmaps/gifImages/garfield.gif'.
MessageTally spyOn:[
- i24 := Depth24Image fromImage:i.
+ i24 := Depth24Image fromImage:i.
]
"
@@ -5132,29 +5132,29 @@
((photometric == anImage photometric)
and:[self bitsPerPixel = anImage bitsPerPixel
and:[colorMap = anImage colorMap]]) ifTrue:[
- "/ can do it by value
- anImage
- valuesFromX:xL y:yT toX:xR y:yB
- do:[:x :y :pixelValue |
- self pixelAtX:x-xL y:y-yT put:pixelValue.
- ]
+ "/ can do it by value
+ anImage
+ valuesFromX:xL y:yT toX:xR y:yB
+ do:[:x :y :pixelValue |
+ self pixelAtX:x-xL y:y-yT put:pixelValue.
+ ]
] ifFalse:[
- "/ must do it by colors
- anImage
- colorsFromX:xL y:yT toX:xR y:yB
- do:[:x :y :clr |
- self colorAtX:x-xL y:y-yT put:clr.
- ]
+ "/ must do it by colors
+ anImage
+ colorsFromX:xL y:yT toX:xR y:yB
+ do:[:x :y :clr |
+ self colorAtX:x-xL y:y-yT put:clr.
+ ]
].
anImage mask notNil ifTrue:[
- anImage mask depth == 1 ifTrue:[
- maskClass := ImageMask
- ] ifFalse:[
- maskClass := anImage mask class.
- ].
- mask := maskClass new
- fromSubImage:anImage mask in:aRectangle
+ anImage mask depth == 1 ifTrue:[
+ maskClass := ImageMask
+ ] ifFalse:[
+ maskClass := anImage mask class.
+ ].
+ mask := maskClass new
+ fromSubImage:anImage mask in:aRectangle
].
"
@@ -5215,10 +5215,10 @@
((aDevice == device) and:[deviceForm notNil]) ifTrue:[^ self].
(device notNil and:[aDevice ~~ device]) ifTrue:[
- "oops, I am already accociated to another device
- - need a copy ...
- "
- ^ self copy onDevice:aDevice
+ "oops, I am already accociated to another device
+ - need a copy ...
+ "
+ ^ self copy onDevice:aDevice
].
deviceForm := self asFormOn:aDevice.
maskedPixelsAre0 := nil.
@@ -8767,8 +8767,8 @@
newImage := self copy.
newImage colorMap isNil ifTrue:[
- self error:'no colormap in image'.
- ^ nil
+ self error:'no colormap in image'.
+ ^ nil
].
"
@@ -8782,39 +8782,39 @@
leave red component only:
(Image fromFile:'goodies/bitmaps/gifImages/claus.gif')
- copyWithColorMapProcessing:[:clr | Color red:(clr red) green:0 blue:0]
+ copyWithColorMapProcessing:[:clr | Color red:(clr red) green:0 blue:0]
"
"
make it reddish:
(Image fromFile:'bitmaps/gifImages/claus.gif')
- copyWithColorMapProcessing:[:clr | Color red:((clr red * 2) min:100) green:clr green blue:clr blue]
+ copyWithColorMapProcessing:[:clr | Color red:((clr red * 2) min:100) green:clr green blue:clr blue]
"
"
invert:
(Image fromFile:'bitmaps/gifImages/claus.gif')
- copyWithColorMapProcessing:[:clr | Color red:(100 - clr red) green:(100 - clr green) blue:(100 - clr green)]
+ copyWithColorMapProcessing:[:clr | Color red:(100 - clr red) green:(100 - clr green) blue:(100 - clr green)]
"
"
lighter:
(Image fromFile:'bitmaps/gifImages/claus.gif')
- copyWithColorMapProcessing:[:clr | |r g b|
- r := clr red. g := clr green. b := clr blue.
- Color red:(r + (100-r//2))
- green:(g + (100-g//2))
- blue:(b + (100-b//2))]
+ copyWithColorMapProcessing:[:clr | |r g b|
+ r := clr red. g := clr green. b := clr blue.
+ Color red:(r + (100-r//2))
+ green:(g + (100-g//2))
+ blue:(b + (100-b//2))]
"
"
darker:
(Image fromFile:'bitmaps/gifImages/claus.gif')
- copyWithColorMapProcessing:[:clr | Color red:(clr red//2) green:(clr green // 2) blue:(clr blue // 2)]
+ copyWithColorMapProcessing:[:clr | Color red:(clr red//2) green:(clr green // 2) blue:(clr blue // 2)]
"
"Modified: 24.4.1997 / 18:28:05 / cg"
@@ -8908,13 +8908,13 @@
pixelArray := self pixelArraySpecies new:width.
0 to:h do:[:row |
- self rowAt:row into:pixelArray.
- pixelArray reverse.
- self rowAt:row putAll:pixelArray.
+ self rowAt:row into:pixelArray.
+ pixelArray reverse.
+ self rowAt:row putAll:pixelArray.
].
mask notNil ifTrue:[
- mask flipHorizontal
+ mask flipHorizontal
].
"/ flush device info
@@ -8945,14 +8945,14 @@
indexHi := bytesPerRow * h + 1.
0 to:(h // 2) do:[:row |
- buffer replaceFrom:1 to:bytesPerRow with:bytes startingAt:indexLow.
- bytes replaceFrom:indexLow to:(indexLow + bytesPerRow - 1) with:bytes startingAt:indexHi.
- bytes replaceFrom:indexHi to:(indexHi + bytesPerRow - 1) with:buffer startingAt:1.
- indexLow := indexLow + bytesPerRow.
- indexHi := indexHi - bytesPerRow.
+ buffer replaceFrom:1 to:bytesPerRow with:bytes startingAt:indexLow.
+ bytes replaceFrom:indexLow to:(indexLow + bytesPerRow - 1) with:bytes startingAt:indexHi.
+ bytes replaceFrom:indexHi to:(indexHi + bytesPerRow - 1) with:buffer startingAt:1.
+ indexLow := indexLow + bytesPerRow.
+ indexHi := indexHi - bytesPerRow.
].
mask notNil ifTrue:[
- mask flipVertical
+ mask flipVertical
].
"flush device info"
self restored
@@ -9004,19 +9004,19 @@
newBits := ByteArray uninitializedNew:(newBytesPerRow * newHeight).
mask notNil ifTrue:[
- newMask := (mask magnifiedBy:scalePoint)
+ newMask := (mask magnifiedBy:scalePoint)
].
newImage := self species new.
newImage
- width:newWidth
- height:newHeight
- photometric:photometric
- samplesPerPixel:samplesPerPixel
- bitsPerSample:bitsPerSample
- colorMap:colorMap copy
- bits:newBits
- mask:newMask.
+ width:newWidth
+ height:newHeight
+ photometric:photometric
+ samplesPerPixel:samplesPerPixel
+ bitsPerSample:bitsPerSample
+ colorMap:colorMap copy
+ bits:newBits
+ mask:newMask.
"walk over destination image fetching pixels from source image"
@@ -9025,12 +9025,12 @@
pixelArray := newImage pixelArraySpecies new:newWidth.
0 to:h do:[:row |
- srcRow := (row // mY).
- 0 to:w do:[:col |
- value := self pixelAtX:(col // mX) y:srcRow.
- pixelArray at:(col+1) put:value.
- ].
- newImage rowAt:row putAll:pixelArray.
+ srcRow := (row // mY).
+ 0 to:w do:[:col |
+ value := self pixelAtX:(col // mX) y:srcRow.
+ pixelArray at:(col+1) put:value.
+ ].
+ newImage rowAt:row putAll:pixelArray.
].
^ newImage
@@ -9039,7 +9039,7 @@
|i|
i := Image fromFile:'goodies/bitmaps/gifImages/claus.gif'.
Time millisecondsToRun:[
- i := i hardMagnifiedBy:0.5@0.5
+ i := i hardMagnifiedBy:0.5@0.5
].
i
"
@@ -9085,36 +9085,36 @@
maxX := minX := p1 x.
(t := p2 x) > maxX ifTrue:[
- maxX := t
+ maxX := t
] ifFalse:[
- t < minX ifTrue:[minX := t].
+ t < minX ifTrue:[minX := t].
].
(t := p3 x) > maxX ifTrue:[
- maxX := t
+ maxX := t
] ifFalse:[
- t < minX ifTrue:[minX := t].
+ t < minX ifTrue:[minX := t].
].
(t := p4 x) > maxX ifTrue:[
- maxX := t
+ maxX := t
] ifFalse:[
- t < minX ifTrue:[minX := t].
+ t < minX ifTrue:[minX := t].
].
maxY := minY := p1 y.
(t := p2 y) > maxY ifTrue:[
- maxY := t
+ maxY := t
] ifFalse:[
- t < minY ifTrue:[minY := t].
+ t < minY ifTrue:[minY := t].
].
(t := p3 y) > maxY ifTrue:[
- maxY := t
+ maxY := t
] ifFalse:[
- t < minY ifTrue:[minY := t].
+ t < minY ifTrue:[minY := t].
].
(t := p4 y) > maxY ifTrue:[
- maxY := t
+ maxY := t
] ifFalse:[
- t < minY ifTrue:[minY := t].
+ t < minY ifTrue:[minY := t].
].
@@ -9133,31 +9133,31 @@
newImage colorMap:colorMap copy.
newImage maskedPixelsAre0:maskedPixelsAre0.
mask notNil ifTrue:[
- newImage mask:(mask rotated:degrees)
+ newImage mask:(mask rotated:degrees)
] ifFalse:[
- self isMask ifFalse:[
- self depth ~~ 1 ifTrue:[
- m := ImageMask width:width height:height.
- m bits:(maskBits := ByteArray new:(m bytesPerRow * height)).
- maskBits atAllPut:16rFF.
- newImage mask:(m rotated:degrees)
- ]
- ]
+ self isMask ifFalse:[
+ self depth ~~ 1 ifTrue:[
+ m := ImageMask width:width height:height.
+ m bits:(maskBits := ByteArray new:(m bytesPerRow * height)).
+ maskBits atAllPut:16rFF.
+ newImage mask:(m rotated:degrees)
+ ]
+ ]
].
maskedPixelsAre0 ifTrue:[
- blackPixel := 0.
+ blackPixel := 0.
] ifFalse:[
- blackPixel := self valueFromColor:Color black.
- blackPixel isNil ifTrue:[
- blackPixel := self valueFromColor:Color white.
- blackPixel isNil ifTrue:[
- blackPixel := 0.
- ]
- ]
+ blackPixel := self valueFromColor:Color black.
+ blackPixel isNil ifTrue:[
+ blackPixel := self valueFromColor:Color white.
+ blackPixel isNil ifTrue:[
+ blackPixel := 0.
+ ]
+ ]
].
self isMask ifTrue:[
- blackPixel := 0.
+ blackPixel := 0.
].
myDepth := self depth.
@@ -9203,583 +9203,583 @@
&& __isFloat(halfH)
&& __isByteArray(newBits)
&& __isByteArray(__INST(bytes))) {
- __srcBytes = __ByteArrayInstPtr(__INST(bytes))->ba_element;
- __dstBytes = __ByteArrayInstPtr(newBits)->ba_element;
- __nSrcBytes = __byteArraySize(__INST(bytes));
- __nDstBytes = __byteArraySize(newBits);
- __blackPixel = __intVal(blackPixel);
-
- __radians = __floatVal(radians);
- __radians = -__radians; /* sigh: clock-wise */
- __sin = sin(__radians);
- __cos = cos(__radians);
- __minX = __floatVal(minX);
- __minY = __floatVal(minY);
- __halfW = __floatVal(halfW);
- __halfH = __floatVal(halfH);
-
- __dstRowPtr = __dstBytes;
- __dstEndPtr = __dstBytes + __nDstBytes;
+ __srcBytes = __ByteArrayInstPtr(__INST(bytes))->ba_element;
+ __dstBytes = __ByteArrayInstPtr(newBits)->ba_element;
+ __nSrcBytes = __byteArraySize(__INST(bytes));
+ __nDstBytes = __byteArraySize(newBits);
+ __blackPixel = __intVal(blackPixel);
+
+ __radians = __floatVal(radians);
+ __radians = -__radians; /* sigh: clock-wise */
+ __sin = sin(__radians);
+ __cos = cos(__radians);
+ __minX = __floatVal(minX);
+ __minY = __floatVal(minY);
+ __halfW = __floatVal(halfW);
+ __halfH = __floatVal(halfH);
+
+ __dstRowPtr = __dstBytes;
+ __dstEndPtr = __dstBytes + __nDstBytes;
# define EARLY_OUT
# define FAST_ADVANCE 5
# define FAST_ADVANCE2
- switch (__depth) {
- case 8:
- for (__dstY = 0; __dstY < __newHeight; __dstY++) {
- double __pY, __sinPY, __cosPY;
+ switch (__depth) {
+ case 8:
+ for (__dstY = 0; __dstY < __newHeight; __dstY++) {
+ double __pY, __sinPY, __cosPY;
#ifdef EARLY_OUT
- int didFetchInRow = 0;
+ int didFetchInRow = 0;
#endif
- __pY = (double)(__dstY + __minY);
-
- __sinPY = __sin * __pY;
- __cosPY = __cos * __pY;
-
- __dstPtr = __dstRowPtr;
- __dstRowPtr += __dstBytesPerRow;
-
- for (__dstX = 0; __dstX < __newWidth; __dstX++) {
- double __pX, __nX;
- unsigned __pix;
-
- /* translate X in destination (center to 0/0) */
- __pX = (double)(__dstX + __minX);
- /* rotate X */
- __nX = (__cos * __pX) - __sinPY;
-
- /* translate X in source (origin to 0/0) */
- __nX = __nX + __halfW + 0.5;
-
- /* inside ? */
- if (__nX < 0) {
+ __pY = (double)(__dstY + __minY);
+
+ __sinPY = __sin * __pY;
+ __cosPY = __cos * __pY;
+
+ __dstPtr = __dstRowPtr;
+ __dstRowPtr += __dstBytesPerRow;
+
+ for (__dstX = 0; __dstX < __newWidth; __dstX++) {
+ double __pX, __nX;
+ unsigned __pix;
+
+ /* translate X in destination (center to 0/0) */
+ __pX = (double)(__dstX + __minX);
+ /* rotate X */
+ __nX = (__cos * __pX) - __sinPY;
+
+ /* translate X in source (origin to 0/0) */
+ __nX = __nX + __halfW + 0.5;
+
+ /* inside ? */
+ if (__nX < 0) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
#ifdef FAST_ADVANCE
- if (__blackPixel == 0) {
- do {
- /* try advance by FAST_ADVANCE pixels ... */
- __dstX += FAST_ADVANCE; __dstPtr += FAST_ADVANCE;
- if (__dstX >= __newWidth) {
- break;
- }
- __pX = (double)(__dstX + __minX);
- __nX = (__cos * __pX) - __sinPY;
- __nX = __nX + __halfW + 0.5;
- } while (__nX < 0);
- __dstX -= FAST_ADVANCE; __dstPtr -= FAST_ADVANCE;
- }
+ if (__blackPixel == 0) {
+ do {
+ /* try advance by FAST_ADVANCE pixels ... */
+ __dstX += FAST_ADVANCE; __dstPtr += FAST_ADVANCE;
+ if (__dstX >= __newWidth) {
+ break;
+ }
+ __pX = (double)(__dstX + __minX);
+ __nX = (__cos * __pX) - __sinPY;
+ __nX = __nX + __halfW + 0.5;
+ } while (__nX < 0);
+ __dstX -= FAST_ADVANCE; __dstPtr -= FAST_ADVANCE;
+ }
#endif
- __pix = __blackPixel;
- } else {
- int __srcX;
-
- __srcX = (int)__nX;
- /* inside ? */
- if (__srcX >= __width) {
+ __pix = __blackPixel;
+ } else {
+ int __srcX;
+
+ __srcX = (int)__nX;
+ /* inside ? */
+ if (__srcX >= __width) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
#ifdef FAST_ADVANCE2
- if (__blackPixel == 0) {
- do {
- /* try advance by FAST_ADVANCE pixels ... */
- __dstX += FAST_ADVANCE; __dstPtr += FAST_ADVANCE;
- if (__dstX >= __newWidth) {
- break;
- }
- __pX = (double)(__dstX + __minX);
- __nX = (__cos * __pX) - __sinPY;
- __nX = __nX + __halfW + 0.5;
- __srcX = (int)__nX;
- } while (__srcX >= __width);
- __dstX -= FAST_ADVANCE; __dstPtr -= FAST_ADVANCE;
- }
+ if (__blackPixel == 0) {
+ do {
+ /* try advance by FAST_ADVANCE pixels ... */
+ __dstX += FAST_ADVANCE; __dstPtr += FAST_ADVANCE;
+ if (__dstX >= __newWidth) {
+ break;
+ }
+ __pX = (double)(__dstX + __minX);
+ __nX = (__cos * __pX) - __sinPY;
+ __nX = __nX + __halfW + 0.5;
+ __srcX = (int)__nX;
+ } while (__srcX >= __width);
+ __dstX -= FAST_ADVANCE; __dstPtr -= FAST_ADVANCE;
+ }
#endif
- __pix = __blackPixel;
- } else {
- double __nY;
-
- /* rotate Y */
- __nY = (__sin * __pX) + __cosPY;
- /* translate Y in source (origin to 0/0) */
- __nY = __nY + __halfH + 0.5;
-
- /* inside ? */
- if (__nY < 0) {
+ __pix = __blackPixel;
+ } else {
+ double __nY;
+
+ /* rotate Y */
+ __nY = (__sin * __pX) + __cosPY;
+ /* translate Y in source (origin to 0/0) */
+ __nY = __nY + __halfH + 0.5;
+
+ /* inside ? */
+ if (__nY < 0) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
#ifdef FAST_ADVANCE2
- if (__blackPixel == 0) {
- do {
- /* try advance by FAST_ADVANCE pixels ... */
- __dstX += FAST_ADVANCE; __dstPtr += FAST_ADVANCE;
- if (__dstX >= __newWidth) {
- break;
- }
- __pX = (double)(__dstX + __minX);
- __nY = (__sin * __pX) + __cosPY;
- __nY = __nY + __halfH + 0.5;
- } while (__nY < 0);
- __dstX -= FAST_ADVANCE; __dstPtr -= FAST_ADVANCE;
- }
+ if (__blackPixel == 0) {
+ do {
+ /* try advance by FAST_ADVANCE pixels ... */
+ __dstX += FAST_ADVANCE; __dstPtr += FAST_ADVANCE;
+ if (__dstX >= __newWidth) {
+ break;
+ }
+ __pX = (double)(__dstX + __minX);
+ __nY = (__sin * __pX) + __cosPY;
+ __nY = __nY + __halfH + 0.5;
+ } while (__nY < 0);
+ __dstX -= FAST_ADVANCE; __dstPtr -= FAST_ADVANCE;
+ }
#endif
- __pix = __blackPixel;
- } else {
- int __srcY;
-
- __srcY = (int)__nY;
- /* inside ? */
- if (__srcY >= __height) {
+ __pix = __blackPixel;
+ } else {
+ int __srcY;
+
+ __srcY = (int)__nY;
+ /* inside ? */
+ if (__srcY >= __height) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
#ifdef FAST_ADVANCE
- if (__blackPixel == 0) {
- do {
- /* try advance by FAST_ADVANCE pixels ... */
- __dstX += FAST_ADVANCE; __dstPtr += FAST_ADVANCE;
- if (__dstX >= __newWidth) {
- break;
- }
- __pX = (double)(__dstX + __minX);
- __nY = (__sin * __pX) + __cosPY;
- __nY = __nY + __halfH + 0.5;
- __srcY = (int)__nY;
- } while (__srcY >= __height);
- __dstX -= FAST_ADVANCE; __dstPtr -= FAST_ADVANCE;
- }
+ if (__blackPixel == 0) {
+ do {
+ /* try advance by FAST_ADVANCE pixels ... */
+ __dstX += FAST_ADVANCE; __dstPtr += FAST_ADVANCE;
+ if (__dstX >= __newWidth) {
+ break;
+ }
+ __pX = (double)(__dstX + __minX);
+ __nY = (__sin * __pX) + __cosPY;
+ __nY = __nY + __halfH + 0.5;
+ __srcY = (int)__nY;
+ } while (__srcY >= __height);
+ __dstX -= FAST_ADVANCE; __dstPtr -= FAST_ADVANCE;
+ }
#endif
- __pix = __blackPixel;
- } else {
- /* fetch source pixel */
-
- int idx;
+ __pix = __blackPixel;
+ } else {
+ /* fetch source pixel */
+
+ int idx;
#ifdef EARLY_OUT
- didFetchInRow = 1;
+ didFetchInRow = 1;
#endif
- idx = __srcY * __srcBytesPerRow + __srcX;
- if ((unsigned)idx < __nSrcBytes) {
- __pix = __srcBytes[idx];
- } else {
- __pix = __blackPixel;
- }
- }
- }
- }
- }
-
- if (__pix != 0) {
- *__dstPtr = __pix;
- }
- __dstPtr++;
- }
- }
- break;
-
- case 1:
- for (__dstY = 0; __dstY < __newHeight; __dstY++) {
- double __pY, __sinPY, __cosPY;
+ idx = __srcY * __srcBytesPerRow + __srcX;
+ if ((unsigned)idx < __nSrcBytes) {
+ __pix = __srcBytes[idx];
+ } else {
+ __pix = __blackPixel;
+ }
+ }
+ }
+ }
+ }
+
+ if (__pix != 0) {
+ *__dstPtr = __pix;
+ }
+ __dstPtr++;
+ }
+ }
+ break;
+
+ case 1:
+ for (__dstY = 0; __dstY < __newHeight; __dstY++) {
+ double __pY, __sinPY, __cosPY;
#ifdef EARLY_OUT
- int didFetchInRow = 0;
+ int didFetchInRow = 0;
#endif
- __pY = (double)(__dstY + __minY);
-
- __sinPY = __sin * __pY;
- __cosPY = __cos * __pY;
-
- __dstPtr = __dstRowPtr;
- __dstMask = 0x80;
- __dstRowPtr += __dstBytesPerRow;
-
- for (__dstX = 0; __dstX < __newWidth; __dstX++) {
- double __pX, __nX;
- int __pix;
-
- /* translate X in destination (center to 0/0) */
- __pX = (double)(__dstX + __minX);
- /* rotate X */
- __nX = (__cos * __pX) - __sinPY;
-
- /* translate X in source (origin to 0/0) */
- __nX = __nX + __halfW + 0.5;
-
- /* inside ? */
- if (__nX < 0) {
+ __pY = (double)(__dstY + __minY);
+
+ __sinPY = __sin * __pY;
+ __cosPY = __cos * __pY;
+
+ __dstPtr = __dstRowPtr;
+ __dstMask = 0x80;
+ __dstRowPtr += __dstBytesPerRow;
+
+ for (__dstX = 0; __dstX < __newWidth; __dstX++) {
+ double __pX, __nX;
+ int __pix;
+
+ /* translate X in destination (center to 0/0) */
+ __pX = (double)(__dstX + __minX);
+ /* rotate X */
+ __nX = (__cos * __pX) - __sinPY;
+
+ /* translate X in source (origin to 0/0) */
+ __nX = __nX + __halfW + 0.5;
+
+ /* inside ? */
+ if (__nX < 0) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
#ifdef FAST_ADVANCE
- if (__blackPixel == 0) {
- do {
- /* try advance by 8 pixels ... */
- __dstX += 8; __dstPtr ++;
- if (__dstX >= __newWidth) {
- break;
- }
- __pX = (double)(__dstX + __minX);
- __nX = (__cos * __pX) - __sinPY;
- __nX = __nX + __halfW + 0.5;
- } while (__nX < 0);
- __dstX -= 8; __dstPtr--;
- }
+ if (__blackPixel == 0) {
+ do {
+ /* try advance by 8 pixels ... */
+ __dstX += 8; __dstPtr ++;
+ if (__dstX >= __newWidth) {
+ break;
+ }
+ __pX = (double)(__dstX + __minX);
+ __nX = (__cos * __pX) - __sinPY;
+ __nX = __nX + __halfW + 0.5;
+ } while (__nX < 0);
+ __dstX -= 8; __dstPtr--;
+ }
#endif
- __pix = __blackPixel;
- } else {
- int __srcX;
-
- __srcX = (int)__nX;
- /* inside ? */
- if (__srcX >= __width) {
+ __pix = __blackPixel;
+ } else {
+ int __srcX;
+
+ __srcX = (int)__nX;
+ /* inside ? */
+ if (__srcX >= __width) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
#ifdef FAST_ADVANCE2
- if (__blackPixel == 0) {
- do {
- /* try advance by 8 pixels ... */
- __dstX += 8; __dstPtr++;
- if (__dstX >= __newWidth) {
- break;
- }
- __pX = (double)(__dstX + __minX);
- __nX = (__cos * __pX) - __sinPY;
- __nX = __nX + __halfW + 0.5;
- __srcX = (int)__nX;
- } while (__srcX >= __width);
- __dstX -= 8; __dstPtr--;
- }
+ if (__blackPixel == 0) {
+ do {
+ /* try advance by 8 pixels ... */
+ __dstX += 8; __dstPtr++;
+ if (__dstX >= __newWidth) {
+ break;
+ }
+ __pX = (double)(__dstX + __minX);
+ __nX = (__cos * __pX) - __sinPY;
+ __nX = __nX + __halfW + 0.5;
+ __srcX = (int)__nX;
+ } while (__srcX >= __width);
+ __dstX -= 8; __dstPtr--;
+ }
#endif
- __pix = __blackPixel;
- } else {
- double __nY;
-
- /* rotate Y */
- __nY = (__sin * __pX) + __cosPY;
- /* translate Y in source (origin to 0/0) */
- __nY = __nY + __halfH + 0.5;
-
- /* inside ? */
- if (__nY < 0) {
+ __pix = __blackPixel;
+ } else {
+ double __nY;
+
+ /* rotate Y */
+ __nY = (__sin * __pX) + __cosPY;
+ /* translate Y in source (origin to 0/0) */
+ __nY = __nY + __halfH + 0.5;
+
+ /* inside ? */
+ if (__nY < 0) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
#ifdef FAST_ADVANCE2
- if (__blackPixel == 0) {
- do {
- /* try advance by 8 pixels ... */
- __dstX += 8; __dstPtr++;
- if (__dstX >= __newWidth) {
- break;
- }
- __pX = (double)(__dstX + __minX);
- __nY = (__sin * __pX) + __cosPY;
- __nY = __nY + __halfH + 0.5;
- } while (__nY < 0);
- __dstX -= 8; __dstPtr--;
- }
+ if (__blackPixel == 0) {
+ do {
+ /* try advance by 8 pixels ... */
+ __dstX += 8; __dstPtr++;
+ if (__dstX >= __newWidth) {
+ break;
+ }
+ __pX = (double)(__dstX + __minX);
+ __nY = (__sin * __pX) + __cosPY;
+ __nY = __nY + __halfH + 0.5;
+ } while (__nY < 0);
+ __dstX -= 8; __dstPtr--;
+ }
#endif
- __pix = __blackPixel;
- } else {
- int __srcY;
-
- __srcY = (int)__nY;
- /* inside ? */
- if (__srcY >= __height) {
+ __pix = __blackPixel;
+ } else {
+ int __srcY;
+
+ __srcY = (int)__nY;
+ /* inside ? */
+ if (__srcY >= __height) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
#ifdef FAST_ADVANCE
- if (__blackPixel == 0) {
- do {
- /* try advance by 8 pixels ... */
- __dstX += 8; __dstPtr++;
- if (__dstX >= __newWidth) {
- break;
- }
- __pX = (double)(__dstX + __minX);
- __nY = (__sin * __pX) + __cosPY;
- __nY = __nY + __halfH + 0.5;
- __srcY = (int)__nY;
- } while (__srcY >= __height);
- __dstX -= 8; __dstPtr--;
- }
+ if (__blackPixel == 0) {
+ do {
+ /* try advance by 8 pixels ... */
+ __dstX += 8; __dstPtr++;
+ if (__dstX >= __newWidth) {
+ break;
+ }
+ __pX = (double)(__dstX + __minX);
+ __nY = (__sin * __pX) + __cosPY;
+ __nY = __nY + __halfH + 0.5;
+ __srcY = (int)__nY;
+ } while (__srcY >= __height);
+ __dstX -= 8; __dstPtr--;
+ }
#endif
- __pix = __blackPixel;
- } else {
- /* fetch source pixel */
-
- int idx, pV;
+ __pix = __blackPixel;
+ } else {
+ /* fetch source pixel */
+
+ int idx, pV;
#ifdef EARLY_OUT
- didFetchInRow = 1;
+ didFetchInRow = 1;
#endif
- idx = __srcY * __srcBytesPerRow + (__srcX >> 3);
- if ((unsigned)idx < __nSrcBytes) {
- pV = __srcBytes[idx];
- __pix = (pV & (0x80 >> (__srcX & 7))) ? 1 : 0;
- } else {
- __pix = __blackPixel;
- }
- }
- }
- }
- }
-
- /* store pixel */
- if (__pix != 0) {
- *__dstPtr |= __dstMask;
- }
- __dstMask >>= 1;
- if (__dstMask == 0) {
- __dstMask = 0x80;
- __dstPtr++;
- }
- }
- }
- break;
-
- case 24:
- for (__dstY = 0; __dstY < __newHeight; __dstY++) {
- double __pY, __sinPY, __cosPY;
+ idx = __srcY * __srcBytesPerRow + (__srcX >> 3);
+ if ((unsigned)idx < __nSrcBytes) {
+ pV = __srcBytes[idx];
+ __pix = (pV & (0x80 >> (__srcX & 7))) ? 1 : 0;
+ } else {
+ __pix = __blackPixel;
+ }
+ }
+ }
+ }
+ }
+
+ /* store pixel */
+ if (__pix != 0) {
+ *__dstPtr |= __dstMask;
+ }
+ __dstMask >>= 1;
+ if (__dstMask == 0) {
+ __dstMask = 0x80;
+ __dstPtr++;
+ }
+ }
+ }
+ break;
+
+ case 24:
+ for (__dstY = 0; __dstY < __newHeight; __dstY++) {
+ double __pY, __sinPY, __cosPY;
#ifdef EARLY_OUT
- int didFetchInRow = 0;
+ int didFetchInRow = 0;
#endif
- __pY = (double)(__dstY + __minY);
-
- __sinPY = __sin * __pY;
- __cosPY = __cos * __pY;
-
- __dstPtr = __dstRowPtr;
- __dstRowPtr += __dstBytesPerRow;
-
- for (__dstX = 0; __dstX < __newWidth; __dstX++) {
- double __pX, __nX;
- unsigned __pix;
-
- /* translate X in destination (center to 0/0) */
- __pX = (double)(__dstX + __minX);
- /* rotate X */
- __nX = (__cos * __pX) - __sinPY;
-
- /* translate X in source (origin to 0/0) */
- __nX = __nX + __halfW + 0.5;
-
- /* inside ? */
- if (__nX < 0) {
+ __pY = (double)(__dstY + __minY);
+
+ __sinPY = __sin * __pY;
+ __cosPY = __cos * __pY;
+
+ __dstPtr = __dstRowPtr;
+ __dstRowPtr += __dstBytesPerRow;
+
+ for (__dstX = 0; __dstX < __newWidth; __dstX++) {
+ double __pX, __nX;
+ unsigned __pix;
+
+ /* translate X in destination (center to 0/0) */
+ __pX = (double)(__dstX + __minX);
+ /* rotate X */
+ __nX = (__cos * __pX) - __sinPY;
+
+ /* translate X in source (origin to 0/0) */
+ __nX = __nX + __halfW + 0.5;
+
+ /* inside ? */
+ if (__nX < 0) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
- __pix = __blackPixel;
- } else {
- int __srcX;
-
- __srcX = (int)__nX;
- /* inside ? */
- if (__srcX >= __width) {
+ __pix = __blackPixel;
+ } else {
+ int __srcX;
+
+ __srcX = (int)__nX;
+ /* inside ? */
+ if (__srcX >= __width) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
- __pix = __blackPixel;
- } else {
- double __nY;
-
- /* rotate Y */
- __nY = (__sin * __pX) + __cosPY;
- /* translate Y in source (origin to 0/0) */
- __nY = __nY + __halfH + 0.5;
-
- /* inside ? */
- if (__nY < 0) {
+ __pix = __blackPixel;
+ } else {
+ double __nY;
+
+ /* rotate Y */
+ __nY = (__sin * __pX) + __cosPY;
+ /* translate Y in source (origin to 0/0) */
+ __nY = __nY + __halfH + 0.5;
+
+ /* inside ? */
+ if (__nY < 0) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
- __pix = __blackPixel;
- } else {
- int __srcY;
-
- __srcY = (int)__nY;
- /* inside ? */
- if (__srcY >= __height) {
+ __pix = __blackPixel;
+ } else {
+ int __srcY;
+
+ __srcY = (int)__nY;
+ /* inside ? */
+ if (__srcY >= __height) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
- __pix = __blackPixel;
- } else {
- /* fetch source pixel */
-
- int idx;
+ __pix = __blackPixel;
+ } else {
+ /* fetch source pixel */
+
+ int idx;
#ifdef EARLY_OUT
- didFetchInRow = 1;
+ didFetchInRow = 1;
#endif
- idx = __srcY * __srcBytesPerRow + __srcX + __srcX + __srcX;
- if ((unsigned)idx < __nSrcBytes) {
- __pix = __srcBytes[idx];
- __pix = (__pix<<8) | __srcBytes[idx+1];
- __pix = (__pix<<8) | __srcBytes[idx+2];
- } else {
- __pix = __blackPixel;
- }
- }
- }
- }
- }
-
- /* store pixel */
- if (__pix != 0) {
- __dstPtr[0] = (__pix >> 16 & 0xFF);
- __dstPtr[1] = (__pix >> 8) & 0xFF;
- __dstPtr[2] = __pix & 0xFF;
- }
- __dstPtr += 3;
- }
- }
- break;
-
- default:
- for (__dstY = 0; __dstY < __newHeight; __dstY++) {
- double __pY, __sinPY, __cosPY;
+ idx = __srcY * __srcBytesPerRow + __srcX + __srcX + __srcX;
+ if ((unsigned)idx < __nSrcBytes) {
+ __pix = __srcBytes[idx];
+ __pix = (__pix<<8) | __srcBytes[idx+1];
+ __pix = (__pix<<8) | __srcBytes[idx+2];
+ } else {
+ __pix = __blackPixel;
+ }
+ }
+ }
+ }
+ }
+
+ /* store pixel */
+ if (__pix != 0) {
+ __dstPtr[0] = (__pix >> 16 & 0xFF);
+ __dstPtr[1] = (__pix >> 8) & 0xFF;
+ __dstPtr[2] = __pix & 0xFF;
+ }
+ __dstPtr += 3;
+ }
+ }
+ break;
+
+ default:
+ for (__dstY = 0; __dstY < __newHeight; __dstY++) {
+ double __pY, __sinPY, __cosPY;
#ifdef EARLY_OUT
- int didFetchInRow = 0;
+ int didFetchInRow = 0;
#endif
- __pY = (double)(__dstY + __minY);
-
- __sinPY = __sin * __pY;
- __cosPY = __cos * __pY;
-
- __dstPtr = __dstRowPtr;
- __dstMask = 0x80;
- __dstRowPtr += __dstBytesPerRow;
-
- for (__dstX = 0; __dstX < __newWidth; __dstX++) {
- double __pX, __nX;
- OBJ __pix;
-
- /* translate X in destination (center to 0/0) */
- __pX = (double)(__dstX + __minX);
- /* rotate X */
- __nX = (__cos * __pX) - __sinPY;
-
- /* translate X in source (origin to 0/0) */
- __nX = __nX + __halfW + 0.5;
-
- /* inside ? */
- if (__nX < 0) {
+ __pY = (double)(__dstY + __minY);
+
+ __sinPY = __sin * __pY;
+ __cosPY = __cos * __pY;
+
+ __dstPtr = __dstRowPtr;
+ __dstMask = 0x80;
+ __dstRowPtr += __dstBytesPerRow;
+
+ for (__dstX = 0; __dstX < __newWidth; __dstX++) {
+ double __pX, __nX;
+ OBJ __pix;
+
+ /* translate X in destination (center to 0/0) */
+ __pX = (double)(__dstX + __minX);
+ /* rotate X */
+ __nX = (__cos * __pX) - __sinPY;
+
+ /* translate X in source (origin to 0/0) */
+ __nX = __nX + __halfW + 0.5;
+
+ /* inside ? */
+ if (__nX < 0) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
- __pix = blackPixel;
- } else {
- int __srcX;
-
- __srcX = (int)__nX;
- /* inside ? */
- if (__srcX >= __width) {
+ __pix = blackPixel;
+ } else {
+ int __srcX;
+
+ __srcX = (int)__nX;
+ /* inside ? */
+ if (__srcX >= __width) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
- __pix = blackPixel;
- } else {
- double __nY;
-
- /* rotate Y */
- __nY = (__sin * __pX) + __cosPY;
- /* translate Y in source (origin to 0/0) */
- __nY = __nY + __halfH + 0.5;
-
- /* inside ? */
- if (__nY < 0) {
+ __pix = blackPixel;
+ } else {
+ double __nY;
+
+ /* rotate Y */
+ __nY = (__sin * __pX) + __cosPY;
+ /* translate Y in source (origin to 0/0) */
+ __nY = __nY + __halfH + 0.5;
+
+ /* inside ? */
+ if (__nY < 0) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
- __pix = blackPixel;
- } else {
- int __srcY;
-
- __srcY = (int)__nY;
- /* inside ? */
- if (__srcY >= __height) {
+ __pix = blackPixel;
+ } else {
+ int __srcY;
+
+ __srcY = (int)__nY;
+ /* inside ? */
+ if (__srcY >= __height) {
#ifdef EARLY_OUT
- if (didFetchInRow) {
- break;
- }
+ if (didFetchInRow) {
+ break;
+ }
#endif
- __pix = blackPixel;
- } else {
- /* fetch source pixel */
-
- static struct inlineCache valAt = _ILC2;
+ __pix = blackPixel;
+ } else {
+ /* fetch source pixel */
+
+ static struct inlineCache valAt = _ILC2;
#ifdef EARLY_OUT
- didFetchInRow = 1;
+ didFetchInRow = 1;
#endif
- __pix = (*valAt.ilc_func)(self,
- @symbol(pixelAtX:y:),
- nil, &valAt,
- __MKSMALLINT(__srcX),
- __MKSMALLINT(__srcY));
- }
- }
- }
- }
-
- /* store pixel */
- {
- static struct inlineCache atPutVal = _ILC3;
-
- if (__pix != __MKSMALLINT(0)) {
- (*atPutVal.ilc_func)(newImage,
- @symbol(pixelAtX:y:put:),
- nil, &atPutVal,
- __MKSMALLINT(__dstX),
- __MKSMALLINT(__dstY),
- __pix
- );
- }
- }
- }
- }
- break;
- }
-
- bad = false;
+ __pix = (*valAt.ilc_func)(self,
+ @symbol(pixelAtX:y:),
+ nil, &valAt,
+ __MKSMALLINT(__srcX),
+ __MKSMALLINT(__srcY));
+ }
+ }
+ }
+ }
+
+ /* store pixel */
+ {
+ static struct inlineCache atPutVal = _ILC3;
+
+ if (__pix != __MKSMALLINT(0)) {
+ (*atPutVal.ilc_func)(newImage,
+ @symbol(pixelAtX:y:put:),
+ nil, &atPutVal,
+ __MKSMALLINT(__dstX),
+ __MKSMALLINT(__dstY),
+ __pix
+ );
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ bad = false;
}
%}.
bad ifTrue:[
- "/ should not happen
- self primitiveFailed
+ "/ should not happen
+ self primitiveFailed
"/ sinRot := radians negated sin.
"/ cosRot := radians negated cos.
@@ -9846,9 +9846,9 @@
i := Image fromFile:'goodies/bitmaps/gifImages/garfield.gif'.
Transcript showCR:(
- Time millisecondsToRun:[
- i rotated:45.
- ]
+ Time millisecondsToRun:[
+ i rotated:45.
+ ]
).
"
"
@@ -9859,12 +9859,12 @@
v openAndWait.
rot := 0.
[true] whileTrue:[
- rI := i rotated:rot.
- rI := rI on:v device.
- v clear.
- v displayForm:rI x:v width//2-(rI width//2) y:v height//2-(rI height // 2).
- rot := rot + 5.
- rI close.
+ rI := i rotated:rot.
+ rI := rI on:v device.
+ v clear.
+ v displayForm:rI x:v width//2-(rI width//2) y:v height//2-(rI height // 2).
+ rot := rot + 5.
+ rI close.
]
"
"
@@ -9875,12 +9875,12 @@
v openAndWait.
rot := 0.
[true] whileTrue:[
- rI := i rotated:rot.
- rI := rI on:v device.
- v clear.
- v displayForm:rI x:v width//2-(rI width//2) y:v height//2-(rI height // 2).
- rot := rot + 5.
- rI close.
+ rI := i rotated:rot.
+ rI := rI on:v device.
+ v clear.
+ v displayForm:rI x:v width//2-(rI width//2) y:v height//2-(rI height // 2).
+ rot := rot + 5.
+ rI close.
]
"
@@ -9929,7 +9929,7 @@
((mX = 1) and:[mY = 1]) ifTrue:[^ self].
((mX isMemberOf:SmallInteger) and:[mY isMemberOf:SmallInteger]) ifFalse:[
- ^ self hardMagnifiedBy:scalePoint
+ ^ self hardMagnifiedBy:scalePoint
].
bitsPerPixel := self depth.
@@ -9946,60 +9946,60 @@
newBits := ByteArray uninitializedNew:(newBytesPerRow * newHeight).
mask notNil ifTrue:[
- newMask := (mask magnifiedBy:scalePoint)
+ newMask := (mask magnifiedBy:scalePoint)
].
newImage := self species new.
newImage
- width:newWidth
- height:newHeight
- photometric:photometric
- samplesPerPixel:samplesPerPixel
- bitsPerSample:bitsPerSample
- colorMap:colorMap copy
- bits:newBits
- mask:newMask.
+ width:newWidth
+ height:newHeight
+ photometric:photometric
+ samplesPerPixel:samplesPerPixel
+ bitsPerSample:bitsPerSample
+ colorMap:colorMap copy
+ bits:newBits
+ mask:newMask.
mX = 1 ifTrue:[
- "expand rows only"
- srcOffset := 1.
- dstOffset := 1.
-
- 1 to:h do:[:row |
- 1 to:magY do:[:i |
- newBits replaceFrom:dstOffset
- to:(dstOffset + oldBytesPerRow - 1)
- with:bytes
- startingAt:srcOffset.
- dstOffset := dstOffset + newBytesPerRow
- ].
- srcOffset := srcOffset + oldBytesPerRow.
- ].
+ "expand rows only"
+ srcOffset := 1.
+ dstOffset := 1.
+
+ 1 to:h do:[:row |
+ 1 to:magY do:[:i |
+ newBits replaceFrom:dstOffset
+ to:(dstOffset + oldBytesPerRow - 1)
+ with:bytes
+ startingAt:srcOffset.
+ dstOffset := dstOffset + newBytesPerRow
+ ].
+ srcOffset := srcOffset + oldBytesPerRow.
+ ].
] ifFalse:[
- "expand cols"
- (mX > 1) ifTrue:[
- dstOffset := 1.
- srcOffset := 1.
- 1 to:h do:[:row |
- self magnifyRowFrom:bytes
- offset:srcOffset
- into:newBits
- offset:dstOffset
- factor:mX.
-
- first := dstOffset.
- dstOffset := dstOffset + newBytesPerRow.
- " and copy for row expansion "
- 2 to:magY do:[:i |
- newBits replaceFrom:dstOffset
- to:(dstOffset + newBytesPerRow - 1)
- with:newBits
- startingAt:first.
- dstOffset := dstOffset + newBytesPerRow
- ].
- srcOffset := srcOffset + oldBytesPerRow.
- ].
- ]
+ "expand cols"
+ (mX > 1) ifTrue:[
+ dstOffset := 1.
+ srcOffset := 1.
+ 1 to:h do:[:row |
+ self magnifyRowFrom:bytes
+ offset:srcOffset
+ into:newBits
+ offset:dstOffset
+ factor:mX.
+
+ first := dstOffset.
+ dstOffset := dstOffset + newBytesPerRow.
+ " and copy for row expansion "
+ 2 to:magY do:[:i |
+ newBits replaceFrom:dstOffset
+ to:(dstOffset + newBytesPerRow - 1)
+ with:newBits
+ startingAt:first.
+ dstOffset := dstOffset + newBytesPerRow
+ ].
+ srcOffset := srcOffset + oldBytesPerRow.
+ ].
+ ]
].
^ newImage
@@ -10081,28 +10081,28 @@
|newImage|
colorMap isNil ifTrue:[
- photometric == #blackIs0 ifTrue:[
- newImage := self copy.
- newImage photometric:#whiteIs0.
- ^ newImage
- ].
- photometric == #whiteIs0 ifTrue:[
- newImage := self copy.
- newImage photometric:#blackIs0.
- ^ newImage
- ].
- ^ nil
+ photometric == #blackIs0 ifTrue:[
+ newImage := self copy.
+ newImage photometric:#whiteIs0.
+ ^ newImage
+ ].
+ photometric == #whiteIs0 ifTrue:[
+ newImage := self copy.
+ newImage photometric:#blackIs0.
+ ^ newImage
+ ].
+ ^ nil
].
^ self
- copyWithColorMapProcessing:[:clr |
- |newColor|
-
- newColor := Color
- redByte:(255 - clr redByte)
- greenByte:(255 - clr greenByte)
- blueByte:(255 - clr blueByte)
- ]
+ copyWithColorMapProcessing:[:clr |
+ |newColor|
+
+ newColor := Color
+ redByte:(255 - clr redByte)
+ greenByte:(255 - clr greenByte)
+ blueByte:(255 - clr blueByte)
+ ]
"
(Image fromFile:'goodies/bitmaps/gifImages/claus.gif') inspect
@@ -10129,15 +10129,15 @@
d := d truncated.
d = 0 ifTrue:[^ self].
((d ~= 90) and:[(d ~= 270) and:[d ~= 180]]) ifTrue:[
- ^ self hardRotated:d
+ ^ self hardRotated:d
].
d = 180 ifTrue:[
- nW := width.
- nH := height.
+ nW := width.
+ nH := height.
] ifFalse:[
- nW := height.
- nH := width.
+ nW := height.
+ nH := width.
].
newImage := self species new.
@@ -10151,7 +10151,7 @@
newImage bitsPerSample:bitsPerSample.
newImage colorMap:colorMap copy.
mask notNil ifTrue:[
- newImage mask:(mask rotated:degrees)
+ newImage mask:(mask rotated:degrees)
].
self easyRotateBitsInto:newImage angle:d.
@@ -10188,7 +10188,7 @@
(#withPixelFunctionAppliedToPixels:) or redefine this method in
a concrete subclass.
(read `Behond photography, by Gerard J. Holzmann;
- ISBM 0-13-074410-7)
+ ISBM 0-13-074410-7)
See blurred / oilPointed as examples ...)"
|w "{Class: SmallInteger }"
@@ -10211,13 +10211,13 @@
h := height - 1.
0 to:h do:[:y |
- 0 to:w do:[:x |
- newImage colorAtX:x y:y put:(pixelFunctionBlock
- value:self
- value:(self colorAtX:x y:y)
- value:x
- value:y)
- ]
+ 0 to:w do:[:x |
+ newImage colorAtX:x y:y put:(pixelFunctionBlock
+ value:self
+ value:(self colorAtX:x y:y)
+ value:x
+ value:y)
+ ]
].
^ newImage
@@ -10230,13 +10230,13 @@
black := Color black.
(i withPixelFunctionApplied:[:oldImage :oldColor :x :y |
- ((x between:100 and:200)
- and:[y between:100 and:200]) ifTrue:[
- oldColor
- ] ifFalse:[
- black.
- ]
- ]) inspect.
+ ((x between:100 and:200)
+ and:[y between:100 and:200]) ifTrue:[
+ oldColor
+ ] ifFalse:[
+ black.
+ ]
+ ]) inspect.
"
"brighten a frame:
@@ -10248,15 +10248,15 @@
w := i width.
h := i height.
(i withPixelFunctionApplied:[:oldImage :oldColor :x :y |
- ((x between:0 and:10)
- or:[(y between:0 and:10)
- or:[(x between:w-10 and:w)
- or:[y between:h-10 and:h]]]) ifTrue:[
- oldColor lightened nearestIn:i colorMap
- ] ifFalse:[
- oldColor.
- ]
- ]) inspect.
+ ((x between:0 and:10)
+ or:[(y between:0 and:10)
+ or:[(x between:w-10 and:w)
+ or:[y between:h-10 and:h]]]) ifTrue:[
+ oldColor lightened nearestIn:i colorMap
+ ] ifFalse:[
+ oldColor.
+ ]
+ ]) inspect.
"
"Modified: 24.4.1997 / 18:36:59 / cg"
@@ -10266,7 +10266,7 @@
"return a new image from the old one, by applying a pixel processor
on the pixel values.
(read `Behond photography, by Gerard J. Holzmann;
- ISBM 0-13-074410-7)
+ ISBM 0-13-074410-7)
See blurred / oilPointed as examples ...)"
|newImage newBits newBytesPerRow|
@@ -10295,27 +10295,27 @@
w := i width - 1.
h := i height - 1.
(i withPixelFunctionAppliedToPixels:[:oldImage :oldPixel :x :y |
- |b p max xMin xMax yMin yMax|
-
- b := Bag identityNew:10.
- xMin := x-3 max:0.
- xMax := x+3 min:w.
- yMin := y-3 max:0.
- yMax := y+3 min:h.
- xMin to:xMax do:[:tx|
- yMin to:yMax do:[:ty|
- b add:(oldImage pixelAtX:tx y:ty)
- ]
- ].
- max := 0.
- b contents keysAndValuesDo:[:pixel :n |
- n > max ifTrue:[
- p := pixel.
- max := n
- ]
- ].
- p
- ]) inspect.
+ |b p max xMin xMax yMin yMax|
+
+ b := Bag identityNew:10.
+ xMin := x-3 max:0.
+ xMax := x+3 min:w.
+ yMin := y-3 max:0.
+ yMax := y+3 min:h.
+ xMin to:xMax do:[:tx|
+ yMin to:yMax do:[:ty|
+ b add:(oldImage pixelAtX:tx y:ty)
+ ]
+ ].
+ max := 0.
+ b contents keysAndValuesDo:[:pixel :n |
+ n > max ifTrue:[
+ p := pixel.
+ max := n
+ ]
+ ].
+ p
+ ]) inspect.
"
"fisheye effect:
@@ -10331,25 +10331,25 @@
R := w2.
white := i valueFromColor:Color white.
(i withPixelFunctionAppliedToPixels:[:oldImage :oldPixel :x :y |
- |p r a nR nP nX nY|
-
- p := (x-w2)@(y-h2).
- r := p r.
- a := p theta.
- nR := r * r / R.
- nP := Point r:nR theta:a.
- nX := ((nP x+w2) rounded max:0) min:w.
- nY := ((nP y+h2) rounded max:0) min:h.
- (nX > w or:[nX < 0]) ifTrue:[
- white
- ] ifFalse:[
- (nY > h or:[nY < 0]) ifTrue:[
- white
- ] ifFalse:[
- oldImage pixelAtX:nX y:nY
- ]
- ]
- ]) inspect.
+ |p r a nR nP nX nY|
+
+ p := (x-w2)@(y-h2).
+ r := p r.
+ a := p theta.
+ nR := r * r / R.
+ nP := Point r:nR theta:a.
+ nX := ((nP x+w2) rounded max:0) min:w.
+ nY := ((nP y+h2) rounded max:0) min:h.
+ (nX > w or:[nX < 0]) ifTrue:[
+ white
+ ] ifFalse:[
+ (nY > h or:[nY < 0]) ifTrue:[
+ white
+ ] ifFalse:[
+ oldImage pixelAtX:nX y:nY
+ ]
+ ]
+ ]) inspect.
"
"fisheye effect:
@@ -10364,25 +10364,25 @@
R := w2.
white := i valueFromColor:Color white.
(i withPixelFunctionAppliedToPixels:[:oldImage :oldPixel :x :y |
- |p r a nR nP nX nY|
-
- p := (x-w2)@(y-h2).
- r := p r.
- a := p theta.
- nR := r * r / R.
- nP := Point r:nR theta:a.
- nX := (nP x+w2) rounded.
- nY := (nP y+h2) rounded.
- (nX > w or:[nX < 0]) ifTrue:[
- white
- ] ifFalse:[
- (nY > h or:[nY < 0]) ifTrue:[
- white
- ] ifFalse:[
- oldImage pixelAtX:nX y:nY
- ]
- ]
- ]) inspect.
+ |p r a nR nP nX nY|
+
+ p := (x-w2)@(y-h2).
+ r := p r.
+ a := p theta.
+ nR := r * r / R.
+ nP := Point r:nR theta:a.
+ nX := (nP x+w2) rounded.
+ nY := (nP y+h2) rounded.
+ (nX > w or:[nX < 0]) ifTrue:[
+ white
+ ] ifFalse:[
+ (nY > h or:[nY < 0]) ifTrue:[
+ white
+ ] ifFalse:[
+ oldImage pixelAtX:nX y:nY
+ ]
+ ]
+ ]) inspect.
"
"Created: 24.4.1997 / 18:37:17 / cg"
@@ -10512,34 +10512,34 @@
((photometric == anImage photometric)
and:[self bitsPerPixel == anImage bitsPerPixel
and:[colorMap = anImage colorMap]]) ifTrue:[
- "/ can loop over values
- anImage valuesFromX:srcX y:srcY
- toX:srcX+w-1 y:srcY+h-1
- do:[:x :y :pixelValue |
- self pixelAtX:x-dX y:y-dY put:pixelValue.
- ]
+ "/ can loop over values
+ anImage valuesFromX:srcX y:srcY
+ toX:srcX+w-1 y:srcY+h-1
+ do:[:x :y :pixelValue |
+ self pixelAtX:x-dX y:y-dY put:pixelValue.
+ ]
] ifFalse:[
- "/ must loop over colors - horribly slow
- anImage colorsFromX:srcX y:srcY
- toX:srcX+w-1 y:srcY+h-1
- do:[:x :y :clr |
- self colorAtX:x-dX y:y-dY put:clr.
- ]
+ "/ must loop over colors - horribly slow
+ anImage colorsFromX:srcX y:srcY
+ toX:srcX+w-1 y:srcY+h-1
+ do:[:x :y :clr |
+ self colorAtX:x-dX y:y-dY put:clr.
+ ]
].
(mask isNil and:[anImage mask notNil]) ifTrue:[
- "/ I have no mask; copied image has
- self createMask.
+ "/ I have no mask; copied image has
+ self createMask.
].
mask notNil ifTrue:[
- anImage mask notNil ifTrue:[
- "/ both have a mask
- mask copyFrom:anImage mask x:srcX y:srcY toX:dstX y:dstY width:w height:h
- ] ifFalse:[
- "/ I have a mask - copied image has not
- mask fillRectangleX:dstX y:dstY width:w height:h withValue:1
- ]
+ anImage mask notNil ifTrue:[
+ "/ both have a mask
+ mask copyFrom:anImage mask x:srcX y:srcY toX:dstX y:dstY width:w height:h
+ ] ifFalse:[
+ "/ I have a mask - copied image has not
+ mask fillRectangleX:dstX y:dstY width:w height:h withValue:1
+ ]
"/ ] ifFalse:[
"/ anImage mask notNil ifTrue:[
"/ "/ I have no mask; copied image has (already handled)
@@ -10999,13 +10999,13 @@
|redBits greenBits blueBits alphaBits|
samplesPerPixel >= 4 ifTrue:[
- redBits := bitsPerSample at:1.
- greenBits := bitsPerSample at:2.
- blueBits := bitsPerSample at:3.
- alphaBits := bitsPerSample at:4.
-
- ^ (pixel bitShift:(redBits + greenBits + blueBits) negated)
- bitAnd:(1 bitShift:alphaBits)-1
+ redBits := bitsPerSample at:1.
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+ alphaBits := bitsPerSample at:4.
+
+ ^ (pixel bitShift:(redBits + greenBits + blueBits) negated)
+ bitAnd:(1 bitShift:alphaBits)-1
].
self subclassResponsibility
@@ -11020,8 +11020,8 @@
|alphaBits|
samplesPerPixel >= 4 ifTrue:[
- alphaBits := bitsPerSample at:4.
- ^ (1 bitShift:alphaBits)-1
+ alphaBits := bitsPerSample at:4.
+ ^ (1 bitShift:alphaBits)-1
].
self subclassResponsibility
@@ -11033,11 +11033,11 @@
|redBits greenBits blueBits|
samplesPerPixel >= 3 ifTrue:[
- redBits := bitsPerSample at:1.
- greenBits := bitsPerSample at:2.
- blueBits := bitsPerSample at:3.
-
- ^ (greenBits + blueBits + redBits) negated
+ redBits := bitsPerSample at:1.
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+
+ ^ (greenBits + blueBits + redBits) negated
].
self subclassResponsibility
@@ -11119,8 +11119,8 @@
|blueBits|
samplesPerPixel >= 3 ifTrue:[
- blueBits := bitsPerSample at:3.
- ^ pixel bitAnd:(1 bitShift:blueBits)-1
+ blueBits := bitsPerSample at:3.
+ ^ pixel bitAnd:(1 bitShift:blueBits)-1
].
self subclassResponsibility
@@ -11160,8 +11160,8 @@
|blueBits|
samplesPerPixel >= 3 ifTrue:[
- blueBits := bitsPerSample at:3.
- ^ (1 bitShift:blueBits)-1
+ blueBits := bitsPerSample at:3.
+ ^ (1 bitShift:blueBits)-1
].
self subclassResponsibility
@@ -11171,7 +11171,7 @@
"return the shift amount used with translation from pixelValues to blueBits"
samplesPerPixel >= 3 ifTrue:[
- ^ 0
+ ^ 0
].
self subclassResponsibility
@@ -11336,10 +11336,10 @@
|blueBits greenBits|
samplesPerPixel >= 3 ifTrue:[
- greenBits := bitsPerSample at:2.
- blueBits := bitsPerSample at:3.
-
- ^ (pixel bitShift:blueBits negated) bitAnd:(1 bitShift:greenBits)-1
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+
+ ^ (pixel bitShift:blueBits negated) bitAnd:(1 bitShift:greenBits)-1
].
self subclassResponsibility
@@ -11381,8 +11381,8 @@
|greenBits|
samplesPerPixel >= 3 ifTrue:[
- greenBits := bitsPerSample at:2.
- ^ (1 bitShift:greenBits)-1
+ greenBits := bitsPerSample at:2.
+ ^ (1 bitShift:greenBits)-1
].
self subclassResponsibility
@@ -11394,9 +11394,9 @@
|greenBits blueBits|
samplesPerPixel >= 3 ifTrue:[
- blueBits := bitsPerSample at:3.
-
- ^ (blueBits) negated
+ blueBits := bitsPerSample at:3.
+
+ ^ (blueBits) negated
].
self subclassResponsibility
@@ -11538,10 +11538,10 @@
set := IdentitySet new.
self valuesFromX:0 y:0 toX:(self width-1) y:(self height-1) do:[:x :y :pixel |
- pixel ~~ last ifTrue:[
- set add:pixel.
- last := pixel.
- ]
+ pixel ~~ last ifTrue:[
+ set add:pixel.
+ last := pixel.
+ ]
].
^ set
@@ -11564,12 +11564,12 @@
|redBits greenBits blueBits|
samplesPerPixel >= 3 ifTrue:[
- redBits := bitsPerSample at:1.
- greenBits := bitsPerSample at:2.
- blueBits := bitsPerSample at:3.
-
- ^ (pixel bitShift:(greenBits + blueBits) negated)
- bitAnd:(1 bitShift:redBits)-1
+ redBits := bitsPerSample at:1.
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+
+ ^ (pixel bitShift:(greenBits + blueBits) negated)
+ bitAnd:(1 bitShift:redBits)-1
].
self subclassResponsibility
@@ -11616,8 +11616,8 @@
|redBits|
samplesPerPixel >= 3 ifTrue:[
- redBits := bitsPerSample at:1.
- ^ (1 bitShift:redBits)-1
+ redBits := bitsPerSample at:1.
+ ^ (1 bitShift:redBits)-1
].
self subclassResponsibility
@@ -11632,10 +11632,10 @@
|greenBits blueBits|
samplesPerPixel >= 3 ifTrue:[
- greenBits := bitsPerSample at:2.
- blueBits := bitsPerSample at:3.
-
- ^ (greenBits + blueBits) negated
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+
+ ^ (greenBits + blueBits) negated
].
self subclassResponsibility
@@ -11648,7 +11648,7 @@
colors := self usedColorsMax:4096.
colors isNil ifTrue:[
- self error:'too many colors in image'.
+ self error:'too many colors in image'.
].
^ colors
@@ -11669,40 +11669,40 @@
|usedValues max colors|
photometric == #rgb ifTrue:[
- usedValues := IdentitySet new.
- self valuesFromX:0 y:0 toX:(width-1) y:(height-1)
- do:[:x :y :pixel |
- usedValues add:pixel.
- usedValues size > nMax ifTrue:[
- "/ too many to be returned here (think of the mass of
- "/ data to be returned by a 24bit image ... ;-)
- ^ nil
- ]
- ].
- "/ code below is slightly faster ...
- "/ colors := usedValues collect:[:pixel | self colorFromValue:pixel].
- colors := usedValues collect:[:pixel | |r g b|
- r := self redBitsOf:pixel.
- g := self greenBitsOf:pixel.
- b := self blueBitsOf:pixel.
- "/ must scale to byte value...
- r := r bitShift:(8 - (bitsPerSample at:1)).
- g := g bitShift:(8 - (bitsPerSample at:2)).
- b := b bitShift:(8 - (bitsPerSample at:3)).
- Color redByte:r greenByte:g blueByte:b
- ].
- ^ colors.
+ usedValues := IdentitySet new.
+ self valuesFromX:0 y:0 toX:(width-1) y:(height-1)
+ do:[:x :y :pixel |
+ usedValues add:pixel.
+ usedValues size > nMax ifTrue:[
+ "/ too many to be returned here (think of the mass of
+ "/ data to be returned by a 24bit image ... ;-)
+ ^ nil
+ ]
+ ].
+ "/ code below is slightly faster ...
+ "/ colors := usedValues collect:[:pixel | self colorFromValue:pixel].
+ colors := usedValues collect:[:pixel | |r g b|
+ r := self redBitsOf:pixel.
+ g := self greenBitsOf:pixel.
+ b := self blueBitsOf:pixel.
+ "/ must scale to byte value...
+ r := r bitShift:(8 - (bitsPerSample at:1)).
+ g := g bitShift:(8 - (bitsPerSample at:2)).
+ b := b bitShift:(8 - (bitsPerSample at:3)).
+ Color redByte:r greenByte:g blueByte:b
+ ].
+ ^ colors.
].
usedValues := self usedValues asArray.
photometric == #palette ifTrue:[
- colors := usedValues collect:[:val | (colorMap at:val+1 ifAbsent:[Color black])].
+ colors := usedValues collect:[:val | (colorMap at:val+1 ifAbsent:[Color black])].
] ifFalse:[
- "/ (photometric == #blackIs0 or:[photometric == #whiteIs0])
-
- max := (1 bitShift:self depth) - 1.
- colors := usedValues collect:[:val | (Color gray:(100 * val / max ))].
+ "/ (photometric == #blackIs0 or:[photometric == #whiteIs0])
+
+ max := (1 bitShift:self depth) - 1.
+ colors := usedValues collect:[:val | (Color gray:(100 * val / max ))].
].
^ colors asSet
@@ -11867,7 +11867,7 @@
suffix := aFileName asFilename suffix.
readerClass := MIMETypes imageReaderForSuffix:suffix.
readerClass notNil ifTrue:[
- ^ self saveOn:aFileName using:readerClass
+ ^ self saveOn:aFileName using:readerClass
].
"/
@@ -11918,9 +11918,9 @@
anImage := Image fromFile:'goodies/bitmaps/gifImages/garfield.gif'.
Image cannotRepresentImageSignal handle:[:ex |
- self warn:'cannot save the image in this format'
+ self warn:'cannot save the image in this format'
] do:[
- anImage saveOn:'myImage.xbm' using:XBMReader.
+ anImage saveOn:'myImage.xbm' using:XBMReader.
]
"
@@ -11989,52 +11989,52 @@
device := aDrawable graphicsDevice.
(aDrawable isForm and:[aDrawable depth == 1]) ifTrue:[
- "/ a monochrome bitmap ?
- visType := #StaticGray.
- ddepth := 1.
+ "/ a monochrome bitmap ?
+ visType := #StaticGray.
+ ddepth := 1.
] ifFalse:[
- "
- get some attributes of the display device
- "
- visType := device visualType.
- ddepth := device depth.
+ "
+ get some attributes of the display device
+ "
+ visType := device visualType.
+ ddepth := device depth.
].
"/ kludge for 15bit XFree server
ddepth == 15 ifTrue:[
- ddepth := 16
+ ddepth := 16
].
(visType == #StaticGray) ifTrue:[
- (device blackpixel == 0) ifTrue:[
- photometric := #blackIs0
- ] ifFalse:[
- photometric := #whiteIs0
- ].
- samplesPerPixel := 1.
- bitsPerPixel := ddepth.
- bitsPerSample := Array with:bitsPerPixel.
+ (device blackpixel == 0) ifTrue:[
+ photometric := #blackIs0
+ ] ifFalse:[
+ photometric := #whiteIs0
+ ].
+ samplesPerPixel := 1.
+ bitsPerPixel := ddepth.
+ bitsPerSample := Array with:bitsPerPixel.
] ifFalse:[
- ((visType == #PseudoColor) or:[(visType == #StaticColor) or:[visType == #GrayScale]]) ifTrue:[
- photometric := #palette.
- samplesPerPixel := 1.
- bitsPerPixel := ddepth.
- bitsPerSample := Array with:bitsPerPixel.
- ] ifFalse:[
- ((visType == #TrueColor) or:[visType == #DirectColor]) ifTrue:[
- photometric := #rgb.
- samplesPerPixel := 3.
+ ((visType == #PseudoColor) or:[(visType == #StaticColor) or:[visType == #GrayScale]]) ifTrue:[
+ photometric := #palette.
+ samplesPerPixel := 1.
+ bitsPerPixel := ddepth.
+ bitsPerSample := Array with:bitsPerPixel.
+ ] ifFalse:[
+ ((visType == #TrueColor) or:[visType == #DirectColor]) ifTrue:[
+ photometric := #rgb.
+ samplesPerPixel := 3.
"/ bitsPerPixel := depth.
"/ bitsPerSample := Array with:device bitsRed
"/ with:device bitsGreen
"/ with:device bitsBlue
- bitsPerPixel := 24.
- bitsPerSample := #(8 8 8).
- ] ifFalse:[
- self error:'screen visual not supported'.
- ^ nil
- ]
- ]
+ bitsPerPixel := 24.
+ bitsPerSample := #(8 8 8).
+ ] ifFalse:[
+ self error:'screen visual not supported'.
+ ^ nil
+ ]
+ ]
].
"
@@ -12052,13 +12052,13 @@
"
spaceBitsPerPixel := bitsPerPixel.
(bitsPerPixel > 8) ifTrue:[
- spaceBitsPerPixel := 16.
- (bitsPerPixel > 16) ifTrue:[
- spaceBitsPerPixel := 32.
- (bitsPerPixel > 32) ifTrue:[
- spaceBitsPerPixel := bitsPerPixel.
- ]
- ]
+ spaceBitsPerPixel := 16.
+ (bitsPerPixel > 16) ifTrue:[
+ spaceBitsPerPixel := 32.
+ (bitsPerPixel > 32) ifTrue:[
+ spaceBitsPerPixel := bitsPerPixel.
+ ]
+ ]
].
bytesPerLine := (w * spaceBitsPerPixel + 31) // 32 * 4.
@@ -12069,9 +12069,9 @@
get the pixels
"
aDrawable isForm ifTrue:[
- info := device getBitsFromPixmapId:aDrawable id x:x y:y width:w height:h into:inData.
+ info := device getBitsFromPixmapId:aDrawable id x:x y:y width:w height:h into:inData.
] ifFalse:[
- info := device getBitsFromViewId:aDrawable id x:x y:y width:w height:h into:inData.
+ info := device getBitsFromViewId:aDrawable id x:x y:y width:w height:h into:inData.
].
bitsPerPixelIn := info at:#bitsPerPixel.
@@ -12082,11 +12082,11 @@
Note: bit- and byte ordering doesn't matter for palette images!!
"
photometric ~~ #palette ifTrue:[
- "/
- "/ check if byteorder is what I like (msbFirst)
- "/
-
- "/ now done on-the-fly (see isMSB arg)
+ "/
+ "/ check if byteorder is what I like (msbFirst)
+ "/
+
+ "/ now done on-the-fly (see isMSB arg)
"/ (info at:#byteOrder) ~~ #msbFirst ifTrue:[
"/ bitsPerPixelIn == 16 ifTrue:[
@@ -12100,10 +12100,10 @@
"/ ]
"/ ].
- "/
- "/ check if bitorder is what I like (msbFirst)
- "/
- "/ mhmh - thats not needed
+ "/
+ "/ check if bitorder is what I like (msbFirst)
+ "/
+ "/ mhmh - thats not needed
"/ bitOrder := info at:#bitOrder.
"/ bitOrder ~~ #msbFirst ifTrue:[
@@ -12122,15 +12122,15 @@
"/ mhmh - thats not needed
bitsPerPixelIn < 8 ifTrue:[
- bitOrder := info at:#bitOrder.
- bitOrder ~~ #msbFirst ifTrue:[
- inData
- expandPixels:8
- width:(inData size)
- height:1
- into:inData
- mapping:(ImageReader reverseBits "TODO: reverseBitsForDepth:bitsPerPixelIn").
- ].
+ bitOrder := info at:#bitOrder.
+ bitOrder ~~ #msbFirst ifTrue:[
+ inData
+ expandPixels:8
+ width:(inData size)
+ height:1
+ into:inData
+ mapping:(ImageReader reverseBits "TODO: reverseBitsForDepth:bitsPerPixelIn").
+ ].
].
"
@@ -12140,120 +12140,120 @@
bytesPerLineIn := (info at:#bytesPerLine). "what I got"
bytesPerLine := (w * bitsPerPixel + 7) // 8. "what I want"
- maskR := info at:#redMask ifAbsent:nil.
- maskG := info at:#greenMask ifAbsent:nil.
- maskB := info at:#blueMask ifAbsent:nil.
+ maskR := info at:#redMask ifAbsent:0.
+ maskG := info at:#greenMask ifAbsent:0.
+ maskB := info at:#blueMask ifAbsent:0.
((bytesPerLine ~~ bytesPerLineIn)
or:[bitsPerPixelIn ~~ bitsPerPixel]) ifTrue:[
- tmpData := inData.
- inData := ByteArray uninitializedNew:(bytesPerLine * height).
-
- srcRow := 1.
- dstRow := 1.
-
- bitsPerPixelIn ~~ bitsPerPixel ifTrue:[
- "/ for now, only 32 -> 24 is supported
+ tmpData := inData.
+ inData := ByteArray uninitializedNew:(bytesPerLine * height).
+
+ srcRow := 1.
+ dstRow := 1.
+
+ bitsPerPixelIn ~~ bitsPerPixel ifTrue:[
+ "/ for now, only 32 -> 24 is supported
- maskR isNil ifTrue:[
- bitsR := device bitsRed.
- bitsG := device bitsGreen.
- bitsB := device bitsBlue.
- maskR := (1 bitShift:bitsR) - 1.
- maskG := (1 bitShift:bitsG) - 1.
- maskB := (1 bitShift:bitsB) - 1.
- shR := device shiftRed negated.
- shG := device shiftGreen negated.
- shB := device shiftBlue negated.
- ] ifFalse:[
- shR := (maskR lowBit - 1) negated.
- bitsR := maskR highBit - maskR lowBit + 1.
- maskR := maskR bitShift:shR.
- shG := (maskG lowBit - 1) negated.
- bitsG := maskG highBit - maskG lowBit + 1.
- maskG := maskG bitShift:shG.
- shB := (maskB lowBit - 1) negated.
- bitsB := maskB highBit - maskB lowBit + 1.
- maskB := maskB bitShift:shB.
- ].
- shR2 := (8 - bitsR).
- shG2 := (8 - bitsG).
- shB2 := (8 - bitsB).
-
- ((bitsPerPixelIn == 32) and:[bitsPerPixel == 24]) ifTrue:[
- "/ 'reformatting 32->24...' printNL.
- 1 to:h do:[:hi |
- srcIndex := srcRow.
- dstIndex := dstRow.
-
- 1 to:w do:[:wi |
- lword := tmpData doubleWordAt:srcIndex MSB:isMSB.
- r := (lword bitShift:shR) bitAnd:maskR.
- g := (lword bitShift:shG) bitAnd:maskG.
- b := (lword bitShift:shB) bitAnd:maskB.
-
- inData at:dstIndex put:r.
- inData at:dstIndex+1 put:g.
- inData at:dstIndex+2 put:b.
- srcIndex := srcIndex + 4.
- dstIndex := dstIndex + 3.
- ].
- dstRow := dstRow + bytesPerLine.
- srcRow := srcRow + bytesPerLineIn
- ]
- ] ifFalse:[
- ((bitsPerPixelIn == 16) and:[bitsPerPixel == 24]) ifTrue:[
- "/ 'reformatting 16->24...' printNL.
- 1 to:h do:[:hi |
- srcIndex := srcRow.
- dstIndex := dstRow.
-
- 1 to:w do:[:wi |
- word := tmpData wordAt:srcIndex MSB:isMSB.
- r := (word bitShift:shR) bitAnd:maskR.
- g := (word bitShift:shG) bitAnd:maskG.
- b := (word bitShift:shB) bitAnd:maskB.
-
- inData at:dstIndex put:(r bitShift:shR2).
- inData at:dstIndex+1 put:(g bitShift:shG2).
- inData at:dstIndex+2 put:(b bitShift:shB2).
+ maskR == 0 ifTrue:[
+ bitsR := device bitsRed.
+ bitsG := device bitsGreen.
+ bitsB := device bitsBlue.
+ maskR := (1 bitShift:bitsR) - 1.
+ maskG := (1 bitShift:bitsG) - 1.
+ maskB := (1 bitShift:bitsB) - 1.
+ shR := device shiftRed negated.
+ shG := device shiftGreen negated.
+ shB := device shiftBlue negated.
+ ] ifFalse:[
+ shR := (maskR lowBit - 1) negated.
+ bitsR := maskR highBit - maskR lowBit + 1.
+ maskR := maskR bitShift:shR.
+ shG := (maskG lowBit - 1) negated.
+ bitsG := maskG highBit - maskG lowBit + 1.
+ maskG := maskG bitShift:shG.
+ shB := (maskB lowBit - 1) negated.
+ bitsB := maskB highBit - maskB lowBit + 1.
+ maskB := maskB bitShift:shB.
+ ].
+ shR2 := (8 - bitsR).
+ shG2 := (8 - bitsG).
+ shB2 := (8 - bitsB).
+
+ ((bitsPerPixelIn == 32) and:[bitsPerPixel == 24]) ifTrue:[
+ "/ 'reformatting 32->24...' printNL.
+ 1 to:h do:[:hi |
+ srcIndex := srcRow.
+ dstIndex := dstRow.
+
+ 1 to:w do:[:wi |
+ lword := tmpData doubleWordAt:srcIndex MSB:isMSB.
+ r := (lword bitShift:shR) bitAnd:maskR.
+ g := (lword bitShift:shG) bitAnd:maskG.
+ b := (lword bitShift:shB) bitAnd:maskB.
+
+ inData at:dstIndex put:r.
+ inData at:dstIndex+1 put:g.
+ inData at:dstIndex+2 put:b.
+ srcIndex := srcIndex + 4.
+ dstIndex := dstIndex + 3.
+ ].
+ dstRow := dstRow + bytesPerLine.
+ srcRow := srcRow + bytesPerLineIn
+ ]
+ ] ifFalse:[
+ ((bitsPerPixelIn == 16) and:[bitsPerPixel == 24]) ifTrue:[
+ "/ 'reformatting 16->24...' printNL.
+ 1 to:h do:[:hi |
+ srcIndex := srcRow.
+ dstIndex := dstRow.
+
+ 1 to:w do:[:wi |
+ word := tmpData wordAt:srcIndex MSB:isMSB.
+ r := (word bitShift:shR) bitAnd:maskR.
+ g := (word bitShift:shG) bitAnd:maskG.
+ b := (word bitShift:shB) bitAnd:maskB.
+
+ inData at:dstIndex put:(r bitShift:shR2).
+ inData at:dstIndex+1 put:(g bitShift:shG2).
+ inData at:dstIndex+2 put:(b bitShift:shB2).
"/ word print.
"/ ' -> ' print.
"/ (r bitShift:shR2) print.
"/ ' ' print. (g bitShift:shG2) print.
"/ ' ' print. (b bitShift:shB2) printCR.
- srcIndex := srcIndex + 2.
- dstIndex := dstIndex + 3.
- ].
- dstRow := dstRow + bytesPerLine.
- srcRow := srcRow + bytesPerLineIn
- ]
- ] ifFalse:[
- ('Image [warning]: unsupported depth combination: ' , bitsPerPixelIn printString , ' -> ' ,
- bitsPerPixel printString) errorPrintCR.
+ srcIndex := srcIndex + 2.
+ dstIndex := dstIndex + 3.
+ ].
+ dstRow := dstRow + bytesPerLine.
+ srcRow := srcRow + bytesPerLineIn
+ ]
+ ] ifFalse:[
+ ('Image [warning]: unsupported depth combination: ' , bitsPerPixelIn printString , ' -> ' ,
+ bitsPerPixel printString) errorPrintCR.
self halt.
- ^ nil
- ]
- ].
- ] ifFalse:[
- "
- repad in the buffer
- "
- 1 to:h do:[:hi |
- inData replaceFrom:dstRow to:(dstRow + bytesPerLine - 1)
- with:tmpData startingAt:srcRow.
- dstRow := dstRow + bytesPerLine.
- srcRow := srcRow + bytesPerLineIn
- ]
- ]
+ ^ nil
+ ]
+ ].
+ ] ifFalse:[
+ "
+ repad in the buffer
+ "
+ 1 to:h do:[:hi |
+ inData replaceFrom:dstRow to:(dstRow + bytesPerLine - 1)
+ with:tmpData startingAt:srcRow.
+ dstRow := dstRow + bytesPerLine.
+ srcRow := srcRow + bytesPerLineIn
+ ]
+ ]
] ifFalse:[
- (bytesPerLine * height) ~~ inData size ifTrue:[
- tmpData := inData.
- inData := ByteArray uninitializedNew:(bytesPerLine * height).
- inData replaceFrom:1 to:bytesPerLine * height with:tmpData startingAt:1
- ]
+ (bytesPerLine * height) ~~ inData size ifTrue:[
+ tmpData := inData.
+ inData := ByteArray uninitializedNew:(bytesPerLine * height).
+ inData replaceFrom:1 to:bytesPerLine * height with:tmpData startingAt:1
+ ]
].
bytes := inData.
@@ -12263,24 +12263,24 @@
if not #palette we are done, the pixel values are the rgb/grey values
"
photometric == #palette ifTrue:[
- "
- what we have now are the color numbers - still need the r/g/b values.
- find out, which colors are in the picture
- "
- usedPixels := inData usedValues.
- mapSize := usedPixels max + 1.
-
- "get the palette"
- map := Array new:mapSize.
- usedPixels do:[:colorIndex |
- |i|
-
- i := colorIndex + 1.
- device getRGBFrom:colorIndex into:[:r :g :b |
- map at:i put:(Color red:r green:g blue:b)
- ]
- ].
- colorMap := map.
+ "
+ what we have now are the color numbers - still need the r/g/b values.
+ find out, which colors are in the picture
+ "
+ usedPixels := inData usedValues.
+ mapSize := usedPixels max + 1.
+
+ "get the palette"
+ map := Array new:mapSize.
+ usedPixels do:[:colorIndex |
+ |i|
+
+ i := colorIndex + 1.
+ device getRGBFrom:colorIndex into:[:r :g :b |
+ map at:i put:(Color red:r green:g blue:b)
+ ]
+ ].
+ colorMap := map.
].
"Modified: / 9.1.1998 / 21:32:36 / stefan"
@@ -12334,8 +12334,8 @@
(especially True- and DirectColor may be wrong).
Late note: 24bit rgb now also works.
WARNING: with doGrab true, this temporarily grabs the display
- and it may not work from within a buttonMotion
- (use with a false grabArg then)."
+ and it may not work from within a buttonMotion
+ (use with a false grabArg then)."
|curs cid rootView prevGrab|
@@ -12353,22 +12353,22 @@
"
rootView := aDevice rootView.
doGrab ifTrue:[
- prevGrab := aDevice activePointerGrab.
- aDevice grabPointerInView:rootView withCursor:curs.
+ prevGrab := aDevice activePointerGrab.
+ aDevice grabPointerInView:rootView withCursor:curs.
].
"
get the pixels
"
[
- self from:rootView in:aRectangle.
+ self from:rootView in:aRectangle.
] valueNowOrOnUnwindDo:[
- doGrab ifTrue:[
- aDevice ungrabPointer.
- prevGrab notNil ifTrue:[
- aDevice grabPointerInView:prevGrab.
- ]
- ]
+ doGrab ifTrue:[
+ aDevice ungrabPointer.
+ prevGrab notNil ifTrue:[
+ aDevice grabPointerInView:prevGrab.
+ ]
+ ]
]
"
@@ -12453,6 +12453,6 @@
!Image class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.314 2001-11-26 21:01:40 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.315 2001-11-28 13:24:51 cg Exp $'
! !
Image initialize!