# HG changeset patch # User Jan Vrany # Date 1485987478 0 # Node ID 46203abe7d575ddd1aaa4cf052c52df2f23ccfa1 # Parent 295325696e0d85c6ebafaaa0608023885602515c# Parent 92c02d941b76f6a7428e91374534319a21c18e43 Merge diff -r 295325696e0d -r 46203abe7d57 .hgtags --- a/.hgtags Wed Feb 01 21:42:41 2017 +0000 +++ b/.hgtags Wed Feb 01 22:17:58 2017 +0000 @@ -12,6 +12,7 @@ 1a378821a380aacc4266bafcd478cd09cfd0fda4 rel5_1_4 1ed049b57dc0d21a7efebc3cc87dc6b37a5208c2 expecco_1_7_0b1 1ed049b57dc0d21a7efebc3cc87dc6b37a5208c2 expecco_1_7_0b2 +204ddab3ac425e1a1a8f257b3d27216623c586de expecco_ALM_1_10_0 21319eb4135fdc2573a000047bca32ac7d99ff15 expecco_2_0_0 21319eb4135fdc2573a000047bca32ac7d99ff15 expecco_2_0_0_0 28bccabea00a97d561d12f6fcb53293d71521678 expecco_2_5_1 @@ -32,6 +33,7 @@ 54bc091ff809f42587cef04385614459b2314536 rel5_2_2 56b1620d8db582ff666fab545823666b334b1cac rel2_10_8_6_last2 58448da4dcf2883d0cc8039219ddc54c9b018453 expeccoNET_1_8_0_0 +5931d9c5714830d912f75c603b1ef9afb986647a expecco_2_11_0 5afcace584e4cf94003dc3745674fe4870dda11e rel5_2_8 5d89b40aae34cc4ad6997b262ce9d5c9f23e62db expecco_2_7_0 5d89b40aae34cc4ad6997b262ce9d5c9f23e62db expecco_2_7_0_49 @@ -72,7 +74,6 @@ c3c7f362b4c35e2b58e987c9822e82a41c69c57f expecco_1_9_1_1 c3fba5c459930feda0311527e36275065f5f8f3c expecco_2_6_0rc1 ccae8e4abae1a5c79c82c5846c3a38eb2dd4e29b expecco_2_10_0 -ccae8e4abae1a5c79c82c5846c3a38eb2dd4e29b expecco_2_11_0 dc5f5e9764d37107a45809b8e156bfbd64fc205e expecco_1_7_0b3 e35961f7892ae885c956df6bf8e52688beb2a923 stable eb14c247272c8f8c82cb6deda9bf62962d721d33 expecco_1_7_0rc5 diff -r 295325696e0d -r 46203abe7d57 Color.st --- a/Color.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Color.st Wed Feb 01 22:17:58 2017 +0000 @@ -3214,78 +3214,78 @@ "get hls (since we dither anyway, round them a bit" - Color withHLSFromScaledRed:rV scaledGreen:gV scaledBlue:bV do:[:h :l :s | - h notNil ifTrue:[ - rh := (h * 3.0) rounded / 3.0. - ]. - rl := (l * 3.0) rounded / 3.0. - rs := (s * 3.0) rounded / 3.0. + Color withHLSFromScaledRed:rV scaledGreen:gV scaledBlue:bV do:[:hue :light :saturation | + hue notNil ifTrue:[ + rh := (hue * 3.0) rounded / 3.0. + ]. + rl := (light * 3.0) rounded / 3.0. + rs := (saturation * 3.0) rounded / 3.0. ]. rh isNil ifTrue:[ - "achromatic, dither between achromatic colors" - - lowL := nil. - hiL := nil. - - "find the 2 bounding colors" - aDevice deviceColors do:[:aColor | - aColor colorId notNil ifTrue:[ - - Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:h :l :s | - | cl | - - h isNil ifTrue:[ - cl := (l * 3.0) rounded / 3.0. - - cl > rl ifTrue:[ - hiL isNil ifTrue:[ - hiL := aColor. - hiValL := cl. - ] ifFalse:[ - cl < hiValL ifTrue:[ - hiL := aColor. - hiValL := cl. - ] - ] - ] ifFalse:[ - lowL isNil ifTrue:[ - lowL := aColor. - lowValL := cl - ] ifFalse:[ - cl > lowValL ifTrue:[ - lowL := aColor. - lowValL := cl - ] - ] - ] - ] - ] - ] - ]. - - (lowL notNil and:[hiL notNil]) ifTrue:[ - ^ self - monoDitherFor:1.0 / (hiValL - lowValL) * (rl - lowValL) - between:lowL and:hiL - on:aDevice - into:aBlock - ]. - "cannot happen, should always find at least black and white" - 'Color [info]: oops - color to dither is not bound by b&w' infoPrintCR. - - ^ aBlock value:nil value:nil + "achromatic, dither between achromatic colors" + + lowL := nil. + hiL := nil. + + "find the 2 bounding colors" + aDevice deviceColors do:[:aColor | + aColor colorId notNil ifTrue:[ + + Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:hue :light :saturation | + | cl | + + hue isNil ifTrue:[ + cl := (light * 3.0) rounded / 3.0. + + cl > rl ifTrue:[ + hiL isNil ifTrue:[ + hiL := aColor. + hiValL := cl. + ] ifFalse:[ + cl < hiValL ifTrue:[ + hiL := aColor. + hiValL := cl. + ] + ] + ] ifFalse:[ + lowL isNil ifTrue:[ + lowL := aColor. + lowValL := cl + ] ifFalse:[ + cl > lowValL ifTrue:[ + lowL := aColor. + lowValL := cl + ] + ] + ] + ] + ] + ] + ]. + + (lowL notNil and:[hiL notNil]) ifTrue:[ + ^ self + monoDitherFor:1.0 / (hiValL - lowValL) * (rl - lowValL) + between:lowL and:hiL + on:aDevice + into:aBlock + ]. + "cannot happen, should always find at least black and white" + 'Color [info]: oops - color to dither is not bound by b&w' infoPrintCR. + + ^ aBlock value:nil value:nil ]. "chromatic case" aDevice hasColors ifFalse:[ - "no chance, return nil values" - ^ aBlock value:nil value:nil + "no chance, return nil values" + ^ aBlock value:nil value:nil ]. (Red isNil or:[Green isNil or:[Blue isNil]]) ifTrue:[ - "if we where not able to get primary colors: no chance" - ^ aBlock value:nil value:nil + "if we where not able to get primary colors: no chance" + ^ aBlock value:nil value:nil ]. "try to find two bounding colors with same hue and saturation; @@ -3299,139 +3299,139 @@ hiH := nil. aDevice deviceColors do:[:aColor | - aColor colorId notNil ifTrue:[ - Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:h :l :s | - | cl ch cs| - - h notNil ifTrue:[ - ch := (h * 3.0) rounded / 3.0. - ] ifFalse:[ - ch := nil - ]. - cl := (l * 3.0) rounded / 3.0. - cs := (s * 3.0) rounded / 3.0. - - ((ch = rh) and:[cs = rs]) ifTrue:[ - "found a color with same saturation and same hue, keep for light" - - cl > rl ifTrue:[ - hiL isNil ifTrue:[ - hiL := aColor. - hiValL := cl - ] ifFalse:[ - cl < hiValL ifTrue:[ - hiL := aColor. - hiValL := cl - ] - ]. - ] ifFalse:[ - lowL isNil ifTrue:[ - lowL := aColor. - lowValL := cl - ] ifFalse:[ - cl > lowValL ifTrue:[ - lowL := aColor. - lowValL := cl - ] - ] - ] - ]. - - (((ch = rh) or:[ch == nil]) and:[cl = rl]) ifTrue:[ - "found a color with same light and same hue, keep for saturation" - - cs > rs ifTrue:[ - hiS isNil ifTrue:[ - hiS := aColor. - hiValS := cs - ] ifFalse:[ - cs < hiValS ifTrue:[ - hiS := aColor. - hiValS := cs - ] - ]. - ] ifFalse:[ - lowS isNil ifTrue:[ - lowS := aColor. - lowValS := cs - ] ifFalse:[ - cs > lowValS ifTrue:[ - lowS := aColor. - lowValS := cs - ] - ] - ] - ]. - - rh notNil ifTrue:[ - cl = rl ifTrue:[ - cs = rs ifTrue:[ - ch notNil ifTrue:[ - d := (ch - rh) abs. - d > 300 ifTrue:[ - rh > 180 ifTrue:[ - ch := ch + 360 - ] ifFalse:[ - ch := ch - 360 - ]. - ]. - ch > rh ifTrue:[ - hiH isNil ifTrue:[ - hiH := aColor. - hiValH := ch - ] ifFalse:[ - ch < hiValH ifTrue:[ - hiH := aColor. - hiValH := ch - ] - ] - ] ifFalse:[ - lowH isNil ifTrue:[ - lowH := aColor. - lowValH := ch - ] ifFalse:[ - ch > lowValH ifTrue:[ - lowH := aColor. - lowValH := ch - ] - ] - ] - ] - ] - ] - ] - ] - ] + aColor colorId notNil ifTrue:[ + Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:hue :light :saturation | + | cl ch cs| + + hue notNil ifTrue:[ + ch := (hue * 3.0) rounded / 3.0. + ] ifFalse:[ + ch := nil + ]. + cl := (light * 3.0) rounded / 3.0. + cs := (saturation * 3.0) rounded / 3.0. + + ((ch = rh) and:[cs = rs]) ifTrue:[ + "found a color with same saturation and same hue, keep for light" + + cl > rl ifTrue:[ + hiL isNil ifTrue:[ + hiL := aColor. + hiValL := cl + ] ifFalse:[ + cl < hiValL ifTrue:[ + hiL := aColor. + hiValL := cl + ] + ]. + ] ifFalse:[ + lowL isNil ifTrue:[ + lowL := aColor. + lowValL := cl + ] ifFalse:[ + cl > lowValL ifTrue:[ + lowL := aColor. + lowValL := cl + ] + ] + ] + ]. + + (((ch = rh) or:[ch isNil]) and:[cl = rl]) ifTrue:[ + "found a color with same light and same hue, keep for saturation" + + cs > rs ifTrue:[ + hiS isNil ifTrue:[ + hiS := aColor. + hiValS := cs + ] ifFalse:[ + cs < hiValS ifTrue:[ + hiS := aColor. + hiValS := cs + ] + ]. + ] ifFalse:[ + lowS isNil ifTrue:[ + lowS := aColor. + lowValS := cs + ] ifFalse:[ + cs > lowValS ifTrue:[ + lowS := aColor. + lowValS := cs + ] + ] + ] + ]. + + rh notNil ifTrue:[ + cl = rl ifTrue:[ + cs = rs ifTrue:[ + ch notNil ifTrue:[ + d := (ch - rh) abs. + d > 300 ifTrue:[ + rh > 180 ifTrue:[ + ch := ch + 360 + ] ifFalse:[ + ch := ch - 360 + ]. + ]. + ch > rh ifTrue:[ + hiH isNil ifTrue:[ + hiH := aColor. + hiValH := ch + ] ifFalse:[ + ch < hiValH ifTrue:[ + hiH := aColor. + hiValH := ch + ] + ] + ] ifFalse:[ + lowH isNil ifTrue:[ + lowH := aColor. + lowValH := ch + ] ifFalse:[ + ch > lowValH ifTrue:[ + lowH := aColor. + lowValH := ch + ] + ] + ] + ] + ] + ] + ] + ] + ] ]. "found bounds for light ?" lowL notNil ifTrue:[ - rl = lowValL ifTrue:[ - ^ aBlock value:lowL value:nil - ]. - hiL notNil ifTrue:[ - ^ self - monoDitherFor:1.0 / (hiValL - lowValL) / (rl - lowValL) - between:lowL and:hiL - on:aDevice - into:aBlock - ]. - "found bound for light - dither with white" - ^ self - monoDitherFor:1.0 / (100 - lowValL) / (rl - lowValL) - between:lowL and:White - on:aDevice - into:aBlock + rl = lowValL ifTrue:[ + ^ aBlock value:lowL value:nil + ]. + hiL notNil ifTrue:[ + ^ self + monoDitherFor:1.0 / (hiValL - lowValL) / (rl - lowValL) + between:lowL and:hiL + on:aDevice + into:aBlock + ]. + "found bound for light - dither with white" + ^ self + monoDitherFor:1.0 / (100 - lowValL) / (rl - lowValL) + between:lowL and:White + on:aDevice + into:aBlock ]. "found bound for light - dither with black" hiL notNil ifTrue:[ - ^ self - monoDitherFor:1.0 / (hiValL) / (rl) - between:Black and:hiL - on:aDevice - into:aBlock + ^ self + monoDitherFor:1.0 / (hiValL) / (rl) + between:Black and:hiL + on:aDevice + into:aBlock ]. @@ -3439,32 +3439,32 @@ (lowS notNil and:[hiS notNil]) ifTrue:[ " - 'saturation dither' printNewline. + 'saturation dither' printNewline. " - ^ self - monoDitherFor:1.0 / (hiValS - lowValS) / (rs - lowValS) - between:lowS and:hiS - on:aDevice - into:aBlock + ^ self + monoDitherFor:1.0 / (hiValS - lowValS) / (rs - lowValS) + between:lowS and:hiS + on:aDevice + into:aBlock ]. "found bounds for hue ?" (lowH notNil and:[hiH notNil]) ifTrue:[ " - 'hue dither' printNewline. + 'hue dither' printNewline. " - hiValH < lowValH ifTrue:[ - hiValH := hiValH + 360 - ]. - - d := hiValH - lowValH. - - ^ self - monoDitherFor:1.0 / (d / (rh - lowValH)) - between:lowH and:hiH - on:aDevice - into:aBlock + hiValH < lowValH ifTrue:[ + hiValH := hiValH + 360 + ]. + + d := hiValH - lowValH. + + ^ self + monoDitherFor:1.0 / (d / (rh - lowValH)) + between:lowH and:hiH + on:aDevice + into:aBlock ]. ^ aBlock value:nil value:nil diff -r 295325696e0d -r 46203abe7d57 Colormap.st --- a/Colormap.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Colormap.st Wed Feb 01 22:17:58 2017 +0000 @@ -632,6 +632,12 @@ "Modified: 23.4.1996 / 22:13:43 / cg" ! ! +!Colormap methodsFor:'testing'! + +isColormap + ^ true +! ! + !Colormap class methodsFor:'documentation'! version diff -r 295325696e0d -r 46203abe7d57 Depth16Image.st --- a/Depth16Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Depth16Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -139,9 +139,10 @@ initialize super initialize. samplesPerPixel := 3. - bitsPerSample := #(5 5 5). + bitsPerSample := #[5 5 5]. "Created: / 27-05-2007 / 14:09:46 / cg" + "Modified: / 30-01-2017 / 18:24:16 / stefan" ! ! !Depth16Image methodsFor:'magnification'! diff -r 295325696e0d -r 46203abe7d57 Depth1Image.st --- a/Depth1Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Depth1Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -155,7 +155,7 @@ "left pixel is in high bit" byte := bytes at:index. - mask := #(16r80 16r40 16r20 16r10 16r08 16r04 16r02 16r01) at:((x \\ 8) + 1). + mask := #[16r80 16r40 16r20 16r10 16r08 16r04 16r02 16r01] at:((x \\ 8) + 1). aPixelValue == 0 ifTrue:[ byte := byte bitAnd:(mask bitInvert) ] ifFalse:[ @@ -740,14 +740,16 @@ bits isEmptyOrNil ifTrue:[^ #() ]. first := bits at:1. - ((first == 0) or:[(first == 2r11111111)]) ifFalse:[ ^ #(0 1) ]. + ((first == 0) or:[(first == 2r11111111)]) ifFalse:[ ^ #[0 1] ]. bits do:[:eachByte | - (first bitXor:eachByte) ~~ 0 ifTrue:[ - ^ #(0 1) - ]. + (first bitXor:eachByte) ~~ 0 ifTrue:[ + ^ #[0 1] + ]. ]. - ^ first == 0 ifTrue:[ #(0) ] ifFalse:[ #(1) ]. + ^ first == 0 ifTrue:[ #[0] ] ifFalse:[ #[1] ]. + + "Modified: / 30-01-2017 / 19:21:52 / stefan" ! valueFromColor:aColor diff -r 295325696e0d -r 46203abe7d57 Depth24Image.st --- a/Depth24Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Depth24Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " COPYRIGHT (c) 1993 by Claus Gittinger All Rights Reserved @@ -1609,61 +1611,61 @@ "/ collect valid ditherColors ... aMapOrNil isNil ifTrue:[ - ditherColors := colors select:[:clr | clr notNil]. + ditherColors := colors select:[:clr | clr notNil]. ] ifFalse:[ - ditherColors := colors + ditherColors := colors ]. "/ ... and sort by manhatten distance from black qScramble := #( - "/ 2rX00X00X00X00 - - 2r000000000000 "/ 0 - 2r000000000100 "/ 1 - 2r000000100000 "/ 2 - 2r000000100100 "/ 3 - 2r000100000000 "/ 4 - 2r000100000100 "/ 5 - 2r000100100000 "/ 6 - 2r000100100100 "/ 7 - 2r100000000000 "/ 8 - 2r100000000100 "/ 9 - 2r100000100000 "/ a - 2r100000100100 "/ b - 2r100100000000 "/ c - 2r100100000100 "/ d - 2r100100100000 "/ e - 2r100100100100 "/ f - ). + "/ 2rX00X00X00X00 + + 2r000000000000 "/ 0 + 2r000000000100 "/ 1 + 2r000000100000 "/ 2 + 2r000000100100 "/ 3 + 2r000100000000 "/ 4 + 2r000100000100 "/ 5 + 2r000100100000 "/ 6 + 2r000100100100 "/ 7 + 2r100000000000 "/ 8 + 2r100000000100 "/ 9 + 2r100000100000 "/ a + 2r100000100100 "/ b + 2r100100000000 "/ c + 2r100100000100 "/ d + 2r100100100000 "/ e + 2r100100100100 "/ f + ). ditherColors := ditherColors sort:[:a :b | - |cr "{Class: SmallInteger }" - cg "{Class: SmallInteger }" - cb "{Class: SmallInteger }" - i1 "{Class: SmallInteger }" - i2 "{Class: SmallInteger }"| - - cr := a redByte. - cg := a greenByte. - cb := a blueByte. - i1 := qScramble at:((cr bitShift:-4) bitAnd:16r0F) + 1. - i1 := i1 + ((qScramble at:((cg bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). - i1 := i1 + ((qScramble at:((cb bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). - - cr := b redByte. - cg := b greenByte. - cb := b blueByte. - i2 := qScramble at:((cr bitShift:-4) bitAnd:16r0F) + 1. - i2 := i2 + ((qScramble at:((cg bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). - i2 := i2 + ((qScramble at:((cb bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). - - i1 < i2 - ]. + |cr "{Class: SmallInteger }" + cg "{Class: SmallInteger }" + cb "{Class: SmallInteger }" + i1 "{Class: SmallInteger }" + i2 "{Class: SmallInteger }"| + + cr := a redByte. + cg := a greenByte. + cb := a blueByte. + i1 := qScramble at:((cr bitShift:-4) bitAnd:16r0F) + 1. + i1 := i1 + ((qScramble at:((cg bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). + i1 := i1 + ((qScramble at:((cb bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). + + cr := b redByte. + cg := b greenByte. + cb := b blueByte. + i2 := qScramble at:((cr bitShift:-4) bitAnd:16r0F) + 1. + i2 := i2 + ((qScramble at:((cg bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). + i2 := i2 + ((qScramble at:((cb bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). + + i1 < i2 + ]. aMapOrNil isNil ifTrue:[ - ditherIds := (ditherColors asArray collect:[:clr | clr colorId]) asByteArray. + ditherIds := (ditherColors asArray collect:[:clr | clr colorId]) asByteArray. ] ifFalse:[ - ditherIds := aMapOrNil asByteArray + ditherIds := aMapOrNil asByteArray ]. "/ build an index table, for fast lookup from manhatten-r-g-b distance @@ -1672,20 +1674,20 @@ clrLookup := ByteArray new:(4096). index := 0. ditherColors keysAndValuesDo:[:clrPosition :clr | - |r g b i| - - r := clr redByte. - g := clr greenByte. - b := clr blueByte. - i := qScramble at:((r bitShift:-4) bitAnd:16r0F) + 1. - i := i + ((qScramble at:((g bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). - i := i + ((qScramble at:((b bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). - lookupPos := i. - - [index < lookupPos] whileTrue:[ - clrLookup at:(index+1) put:(clrPosition-1-1). - index := index + 1 - ] + |r g b i| + + r := clr redByte. + g := clr greenByte. + b := clr blueByte. + i := qScramble at:((r bitShift:-4) bitAnd:16r0F) + 1. + i := i + ((qScramble at:((g bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). + i := i + ((qScramble at:((b bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). + lookupPos := i. + + index+1 to:lookupPos do:[:idx| + clrLookup at:idx put:(clrPosition-1-1). + ]. + index := lookupPos. ]. clrLookup from:index+1 to:4096 put:(ditherColors size - 1). @@ -1701,16 +1703,16 @@ ditherRGBBytes := ByteArray uninitializedNew:(lastColor * 3). index := 1. 1 to:lastColor do:[:pix | - clr := ditherColors at:pix. - ditherRGBBytes at:index put:(clr redByte). - ditherRGBBytes at:index+1 put:(clr greenByte). - ditherRGBBytes at:index+2 put:(clr blueByte). - aMapOrNil isNil ifTrue:[ - ditherIds at:pix put:clr colorId. - ] ifFalse:[ - ditherIds at:pix put:(aMapOrNil at:pix). - ]. - index := index + 3. + clr := ditherColors at:pix. + ditherRGBBytes at:index put:(clr redByte). + ditherRGBBytes at:index+1 put:(clr greenByte). + ditherRGBBytes at:index+2 put:(clr blueByte). + aMapOrNil isNil ifTrue:[ + ditherIds at:pix put:clr colorId. + ] ifFalse:[ + ditherIds at:pix put:(aMapOrNil at:pix). + ]. + index := index + 3. ]. pseudoBits := ByteArray uninitializedNew:(width * height). @@ -1732,23 +1734,23 @@ int __nColors = __intVal(lastColor); int __wR = -1, __wG, __wB; static int __qScramble[16] = { - 0x000 /* 2r000000000000 0 */, - 0x004 /* 2r000000000100 1 */, - 0x020 /* 2r000000100000 2 */, - 0x024 /* 2r000000100100 3 */, - 0x100 /* 2r000100000000 4 */, - 0x104 /* 2r000100000100 5 */, - 0x120 /* 2r000100100000 6 */, - 0x124 /* 2r000100100100 7 */, - 0x800 /* 2r100000000000 8 */, - 0x804 /* 2r100000000100 9 */, - 0x820 /* 2r100000100000 a */, - 0x824 /* 2r100000100100 b */, - 0x900 /* 2r100100000000 c */, - 0x904 /* 2r100100000100 d */, - 0x920 /* 2r100100100000 e */, - 0x924 /* 2r100100100100 f */, - }; + 0x000 /* 2r000000000000 0 */, + 0x004 /* 2r000000000100 1 */, + 0x020 /* 2r000000100000 2 */, + 0x024 /* 2r000000100100 3 */, + 0x100 /* 2r000100000000 4 */, + 0x104 /* 2r000100000100 5 */, + 0x120 /* 2r000100100000 6 */, + 0x124 /* 2r000100100100 7 */, + 0x800 /* 2r100000000000 8 */, + 0x804 /* 2r100000000100 9 */, + 0x820 /* 2r100000100000 a */, + 0x824 /* 2r100000100100 b */, + 0x900 /* 2r100100000000 c */, + 0x904 /* 2r100100000100 d */, + 0x920 /* 2r100100100000 e */, + 0x924 /* 2r100100100100 f */, + }; if (__isByteArrayLike(__INST(bytes)) && __isByteArray(pseudoBits) @@ -1756,54 +1758,54 @@ && __isByteArray(ditherIds) && __isByteArray(clrLookup) && __isByteArray(error)) { - failed = false; - - srcP = __ByteArrayInstPtr(__INST(bytes))->ba_element; - dstP = __ByteArrayInstPtr(pseudoBits)->ba_element; - idP = __ByteArrayInstPtr(ditherIds)->ba_element; - __clrLookup = __ByteArrayInstPtr(clrLookup)->ba_element; - errP = (short *) __ByteArrayInstPtr(error)->ba_element; - - /* - * clear error accumulator - */ - eP = errP; - bzero(eP, (__w+2) * 2 * 3); - - for (__y=__h; __y>0; __y--) { - unsigned char *dp; - int __eR, __eG, __eB; - - __eR = __eG = __eB = 0; - - eP = &(errP[3]); - __eR = eP[0]; - __eG = eP[1]; - __eB = eP[2]; - - for (__x=__w; __x>0; __x--) { - int __want; - int pix; - int __wantR, __wantG, __wantB; - int idx; - int tR, tG, tB; - int nR, nG, nB; - int dR, dG, dB; - int minDelta, bestIdx; - int cnt; - - __wantR = srcP[0]; - __wantG = srcP[1]; - __wantB = srcP[2]; - srcP += 3; - - /* - * wI are the wanted r/g/b values; - * eI are the error values; - */ - __wantR = __wantR + __eR; - __wantG = __wantG + __eG; - __wantB = __wantB + __eB; + failed = false; + + srcP = __ByteArrayInstPtr(__INST(bytes))->ba_element; + dstP = __ByteArrayInstPtr(pseudoBits)->ba_element; + idP = __ByteArrayInstPtr(ditherIds)->ba_element; + __clrLookup = __ByteArrayInstPtr(clrLookup)->ba_element; + errP = (short *) __ByteArrayInstPtr(error)->ba_element; + + /* + * clear error accumulator + */ + eP = errP; + bzero(eP, (__w+2) * 2 * 3); + + for (__y=__h; __y>0; __y--) { + unsigned char *dp; + int __eR, __eG, __eB; + + __eR = __eG = __eB = 0; + + eP = &(errP[3]); + __eR = eP[0]; + __eG = eP[1]; + __eB = eP[2]; + + for (__x=__w; __x>0; __x--) { + int __want; + int pix; + int __wantR, __wantG, __wantB; + int idx; + int tR, tG, tB; + int nR, nG, nB; + int dR, dG, dB; + int minDelta, bestIdx; + int cnt; + + __wantR = srcP[0]; + __wantG = srcP[1]; + __wantB = srcP[2]; + srcP += 3; + + /* + * wI are the wanted r/g/b values; + * eI are the error values; + */ + __wantR = __wantR + __eR; + __wantG = __wantG + __eG; + __wantB = __wantB + __eB; #define RED_SCALE 30 #define GREEN_SCALE 59 @@ -1815,237 +1817,237 @@ #define NPROBE 16 #ifndef FAST_LOOKUP - if ((__wantR == __wR) - && (__wantG == __wG) - && (__wantB == __wB)) { - /* - * same color again - reuse last bestMatch - */ - } else + if ((__wantR == __wR) + && (__wantG == __wG) + && (__wantB == __wB)) { + /* + * same color again - reuse last bestMatch + */ + } else #endif - { - __wR = __wantR; - __wG = __wantG; - __wB = __wantB; + { + __wR = __wantR; + __wG = __wantG; + __wB = __wantB; #ifdef FAST_LOOKUP - if(__wR > 255) __wR = 255; - else if (__wR < 0) __wR = 0; - if(__wG > 255) __wG = 255; - else if (__wG < 0) __wG = 0; - if(__wB > 255) __wB = 255; - else if (__wB < 0) __wB = 0; - - { - int lookupIndex; - int idx, idx0; - int d, delta; - unsigned char *dp0; - - dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; - lookupIndex = __qScramble[((__wR & 0xF0)>>4)]; - lookupIndex |= __qScramble[((__wG & 0xF0)>>4)] >> 1; - lookupIndex |= __qScramble[((__wB & 0xF0)>>4)] >> 2; - idx = bestIdx =__clrLookup[lookupIndex]; - dp += (idx+idx+idx); - - /* try color at lookupIndex */ - - d = dp[0]; - delta = (__wR - d) * RED_SCALE; - if (delta < 0) delta = -delta; - - d = dp[1]; - if (__wG > d) - delta += (__wG - d) * GREEN_SCALE; - else - delta += (d - __wG) * GREEN_SCALE; - d = dp[2]; - if (__wB > d) - delta += (__wB - d) * BLUE_SCALE; - else - delta += (d - __wB) * BLUE_SCALE; - - if (delta <= GOOD_DELTA) { - goto foundBest; - } - minDelta = delta; + if(__wR > 255) __wR = 255; + else if (__wR < 0) __wR = 0; + if(__wG > 255) __wG = 255; + else if (__wG < 0) __wG = 0; + if(__wB > 255) __wB = 255; + else if (__wB < 0) __wB = 0; + + { + int lookupIndex; + int idx, idx0; + int d, delta; + unsigned char *dp0; + + dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; + lookupIndex = __qScramble[((__wR & 0xF0)>>4)]; + lookupIndex |= __qScramble[((__wG & 0xF0)>>4)] >> 1; + lookupIndex |= __qScramble[((__wB & 0xF0)>>4)] >> 2; + idx = bestIdx =__clrLookup[lookupIndex]; + dp += (idx+idx+idx); + + /* try color at lookupIndex */ + + d = dp[0]; + delta = (__wR - d) * RED_SCALE; + if (delta < 0) delta = -delta; + + d = dp[1]; + if (__wG > d) + delta += (__wG - d) * GREEN_SCALE; + else + delta += (d - __wG) * GREEN_SCALE; + d = dp[2]; + if (__wB > d) + delta += (__wB - d) * BLUE_SCALE; + else + delta += (d - __wB) * BLUE_SCALE; + + if (delta <= GOOD_DELTA) { + goto foundBest; + } + minDelta = delta; # ifndef ONE_SHOT - idx0 = idx; dp0 = dp; - cnt = 0; - while ((++cnt <= NPROBE) && (idx > 0)) { - /* try previous color(s) */ - - idx--; dp -= 3; - d = dp[0]; - delta = (__wR - d) * RED_SCALE; - if (delta < 0) delta = -delta; - d = dp[1]; - if (__wG > d) - delta += (__wG - d) * GREEN_SCALE; - else - delta += (d - __wG) * GREEN_SCALE; - d = dp[2]; - if (__wB > d) - delta += (__wB - d) * BLUE_SCALE; - else - delta += (d - __wB) * BLUE_SCALE; - - if (delta < minDelta) { - bestIdx = idx; - if (delta <= GOOD_DELTA) { - goto foundBest; - } - minDelta = delta; - } - } - - idx = idx0; dp = dp0; - cnt = 0; - while ((++cnt <= NPROBE) && (++idx < __nColors)) { - /* try next color */ - - dp += 3; - d = dp[0]; - delta = (__wR - d) * RED_SCALE; - if (delta < 0) delta = -delta; - d = dp[1]; - if (__wG > d) - delta += (__wG - d) * GREEN_SCALE; - else - delta += (d - __wG) * GREEN_SCALE; - d = dp[2]; - if (__wB > d) - delta += (__wB - d) * BLUE_SCALE; - else - delta += (d - __wB) * BLUE_SCALE; - - if (delta < minDelta) { - bestIdx = idx; - if (delta <= GOOD_DELTA) { - goto foundBest; - } - minDelta = delta; - } - } + idx0 = idx; dp0 = dp; + cnt = 0; + while ((++cnt <= NPROBE) && (idx > 0)) { + /* try previous color(s) */ + + idx--; dp -= 3; + d = dp[0]; + delta = (__wR - d) * RED_SCALE; + if (delta < 0) delta = -delta; + d = dp[1]; + if (__wG > d) + delta += (__wG - d) * GREEN_SCALE; + else + delta += (d - __wG) * GREEN_SCALE; + d = dp[2]; + if (__wB > d) + delta += (__wB - d) * BLUE_SCALE; + else + delta += (d - __wB) * BLUE_SCALE; + + if (delta < minDelta) { + bestIdx = idx; + if (delta <= GOOD_DELTA) { + goto foundBest; + } + minDelta = delta; + } + } + + idx = idx0; dp = dp0; + cnt = 0; + while ((++cnt <= NPROBE) && (++idx < __nColors)) { + /* try next color */ + + dp += 3; + d = dp[0]; + delta = (__wR - d) * RED_SCALE; + if (delta < 0) delta = -delta; + d = dp[1]; + if (__wG > d) + delta += (__wG - d) * GREEN_SCALE; + else + delta += (d - __wG) * GREEN_SCALE; + d = dp[2]; + if (__wB > d) + delta += (__wB - d) * BLUE_SCALE; + else + delta += (d - __wB) * BLUE_SCALE; + + if (delta < minDelta) { + bestIdx = idx; + if (delta <= GOOD_DELTA) { + goto foundBest; + } + minDelta = delta; + } + } # endif - } - foundBest: ; + } + foundBest: ; #else /* - if(__wR > 255) __wR = 255; - else if (__wR < 0) __wR = 0; - if(__wG > 255) __wG = 255; - else if (__wG < 0) __wG = 0; - if(__wB > 255) __wB = 255; - else if (__wB < 0) __wB = 0; + if(__wR > 255) __wR = 255; + else if (__wR < 0) __wR = 0; + if(__wG > 255) __wG = 255; + else if (__wG < 0) __wG = 0; + if(__wB > 255) __wB = 255; + else if (__wB < 0) __wB = 0; */ - /* find the best matching color */ - - minDelta = 99999; - bestIdx = -1; - dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; - for (idx = 0; idx<__nColors; idx++) { - int d, delta; - - d = dp[0]; - delta = (__wR - d) * RED_SCALE; - if (delta < 0) delta = -delta; - if (delta < minDelta) { - d = dp[1]; - if (__wG > d) - delta += (__wG - d) * GREEN_SCALE; - else - delta += (d - __wG) * GREEN_SCALE; - if (delta < minDelta) { - d = dp[2]; - if (__wB > d) - delta += (__wB - d) * BLUE_SCALE; - else - delta += (d - __wB) * BLUE_SCALE; - - if (delta < minDelta) { - bestIdx = idx; - if (delta <= GOOD_DELTA) { - break; - } - minDelta = delta; - } - } - } - dp += 3; - } + /* find the best matching color */ + + minDelta = 99999; + bestIdx = -1; + dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; + for (idx = 0; idx<__nColors; idx++) { + int d, delta; + + d = dp[0]; + delta = (__wR - d) * RED_SCALE; + if (delta < 0) delta = -delta; + if (delta < minDelta) { + d = dp[1]; + if (__wG > d) + delta += (__wG - d) * GREEN_SCALE; + else + delta += (d - __wG) * GREEN_SCALE; + if (delta < minDelta) { + d = dp[2]; + if (__wB > d) + delta += (__wB - d) * BLUE_SCALE; + else + delta += (d - __wB) * BLUE_SCALE; + + if (delta < minDelta) { + bestIdx = idx; + if (delta <= GOOD_DELTA) { + break; + } + minDelta = delta; + } + } + } + dp += 3; + } #endif - } - - dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; - dp += bestIdx * 3; - dR = dp[0]; - dG = dp[1]; - dB = dp[2]; + } + + dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; + dp += bestIdx * 3; + dR = dp[0]; + dG = dp[1]; + dB = dp[2]; /* console_fprintf(stderr, "want: %d/%d/%d (%d/%d/%d) got: %d/%d/%d\n", - __wantR, __wantG, __wantB, - __wR, __wG, __wB, - dR, dG, dB); + __wantR, __wantG, __wantB, + __wR, __wG, __wB, + dR, dG, dB); */ - /* - * store the corresponding dither colors colorId - */ - *dstP++ = idP[bestIdx]; - - /* - * the new error & distribute the error - */ - __eR = __wantR - dR; - if (__eR) { - tR = __eR >> 4; /* 16th of error */ - nR = eP[3] + (tR * 7);/* from accu: error for (x+1 / y) */ - eP[0] = tR*5; /* 5/16th for (x / y+1) */ - eP[-3] = tR*3; /* 3/16th for (x-1 / y+1) */ - eP[3] = __eR - (tR*15); /* 1/16th for (x+1 / y+1) */ - __eR = nR; - } else { - __eR = eP[3]; - eP[0] = eP[-3] = eP[3] = 0; - } - - __eG = __wantG - dG; - if (__eG) { - tG = __eG >> 4; - nG = eP[4] + (tG * 7);/* plus 7/16'th of this error */ - eP[1] = tG*5; - eP[-2] = tG*3; - eP[4] = __eG - (tG*15); - __eG = nG; - } else { - __eG = eP[4]; - eP[1] = eP[-2] = eP[4] = 0; - } - - __eB = __wantB - dB; - if (__eB) { - tB = __eB >> 4; - nB = eP[5] + (tB * 7); - eP[2] = tB*5; - eP[-1] = tB*3; - eP[5] = __eB - (tB*15); - __eB = nB; - } else { - __eB = eP[5]; - eP[2] = eP[-1] = eP[5] = 0; - } - - eP += 3; - } - } + /* + * store the corresponding dither colors colorId + */ + *dstP++ = idP[bestIdx]; + + /* + * the new error & distribute the error + */ + __eR = __wantR - dR; + if (__eR) { + tR = __eR >> 4; /* 16th of error */ + nR = eP[3] + (tR * 7);/* from accu: error for (x+1 / y) */ + eP[0] = tR*5; /* 5/16th for (x / y+1) */ + eP[-3] = tR*3; /* 3/16th for (x-1 / y+1) */ + eP[3] = __eR - (tR*15); /* 1/16th for (x+1 / y+1) */ + __eR = nR; + } else { + __eR = eP[3]; + eP[0] = eP[-3] = eP[3] = 0; + } + + __eG = __wantG - dG; + if (__eG) { + tG = __eG >> 4; + nG = eP[4] + (tG * 7);/* plus 7/16'th of this error */ + eP[1] = tG*5; + eP[-2] = tG*3; + eP[4] = __eG - (tG*15); + __eG = nG; + } else { + __eG = eP[4]; + eP[1] = eP[-2] = eP[4] = 0; + } + + __eB = __wantB - dB; + if (__eB) { + tB = __eB >> 4; + nB = eP[5] + (tB * 7); + eP[2] = tB*5; + eP[-1] = tB*3; + eP[5] = __eB - (tB*15); + __eB = nB; + } else { + __eB = eP[5]; + eP[2] = eP[-1] = eP[5] = 0; + } + + eP += 3; + } + } } %}. failed ifTrue:[ - self primitiveFailed. - ^ nil + self primitiveFailed. + ^ nil ]. ^ pseudoBits @@ -2071,9 +2073,9 @@ eR eRB eB eLB bytes| (samplesPerPixel ~~ 3 - or:[bitsPerSample ~= #(8 8 8) - or:[depth > 8]]) ifTrue:[ - ^ super floydSteinbergDitheredGrayBitsDepth:depth + or:[(#[8 8 8] isSameSequenceAs:bitsPerSample) not + or:[depth > 8]]) ifTrue:[ + ^ super floydSteinbergDitheredGrayBitsDepth:depth ]. bytes := self bits. @@ -2086,22 +2088,22 @@ outBits := ByteArray uninitializedNew:(bytesPerOutRow * h). depth ~~ 8 ifTrue:[ - greyLevels := (1 bitShift:depth) - 1. - greyMap1 := Array new:256. - greyMap2 := Array new:256. - 1 to:256 do:[:i | - v := (greyLevels / 255 * (i-1)). - greyMap1 at:i put:v. - greyMap2 at:i put:v. - ]. - greyMap1 := (greyMap1 collect:[:b | b truncated]) asByteArray. - - greyMap2 := (greyMap2 collect:[:el | - ((el - el truncated) "/ the error (0..1) - * 255) rounded]) asByteArray. - - errorArray := ByteArray new:(w + 2) * 2. - errorArray1 := ByteArray new:(w + 2) * 2. + greyLevels := (1 bitShift:depth) - 1. + greyMap1 := Array new:256. + greyMap2 := Array new:256. + 1 to:256 do:[:i | + v := (greyLevels / 255 * (i-1)). + greyMap1 at:i put:v. + greyMap2 at:i put:v. + ]. + greyMap1 := (greyMap1 collect:[:b | b truncated]) asByteArray. + + greyMap2 := (greyMap2 collect:[:el | + ((el - el truncated) "/ the error (0..1) + * 255) rounded]) asByteArray. + + errorArray := ByteArray new:(w + 2) * 2. + errorArray1 := ByteArray new:(w + 2) * 2. ]. %{ @@ -2132,97 +2134,98 @@ short *__t; if (__depth == 8) { - /* - * special code for destination depth 8 - */ - for (__y=0; __y<__h; __y++) { - __nextDst = __dstIdx + __bytesPerOutRow; - __nextSrc = __srcIdx + __bytesPerRow; - for (__x=0; __x<__w; __x++) { - __grey = (__bytes[__srcIdx] * 3) /* 0.3*r + 0.6*g + b -> 0..2550 */ - + (__bytes[__srcIdx+1] * 6) - + __bytes[__srcIdx+2]; - __pixel = __grey / 10; /* 0 .. 255 */ - - __srcIdx += 3; - __outBits[__dstIdx] = __pixel; - __dstIdx++; - } - __srcIdx = __nextSrc; - __dstIdx = __nextDst; - } + /* + * special code for destination depth 8 + */ + for (__y=0; __y<__h; __y++) { + __nextDst = __dstIdx + __bytesPerOutRow; + __nextSrc = __srcIdx + __bytesPerRow; + for (__x=0; __x<__w; __x++) { + __grey = (__bytes[__srcIdx] * 3) /* 0.3*r + 0.6*g + b -> 0..2550 */ + + (__bytes[__srcIdx+1] * 6) + + __bytes[__srcIdx+2]; + __pixel = __grey / 10; /* 0 .. 255 */ + + __srcIdx += 3; + __outBits[__dstIdx] = __pixel; + __dstIdx++; + } + __srcIdx = __nextSrc; + __dstIdx = __nextDst; + } } else { - bzero(errorArray1, (__w+2) * 2); - - __bitCnt = 8; - for (__y=0; __y<__h; __y++) { - __nextDst = __dstIdx + __bytesPerOutRow; - __nextSrc = __srcIdx + __bytesPerRow; - - __byte = 0; - - __t = __errorArray; - __errorArray = __errorArray1; - __errorArray1 = __t; - bzero(errorArray1, (__w+2) * 2); - - for (__x=0; __x<__w; __x++) { - __grey = (__bytes[__srcIdx] * 3) /* 0.3*r + 0.6*g + b -> 0..2550 */ - + (__bytes[__srcIdx+1] * 6) - + __bytes[__srcIdx+2]; - __grey = __grey / 10; /* 0 .. 255 */ - - __pixel = __greyMap1[__grey]; /* 0..(greyLevels-1) */ - __err = __greyMap2[__grey]; /* 0.. 255 - error) */ - __err += __errorArray[__x+1]; - - if (__err > 127) { /* dither says: next pixel */ - if ( __pixel != __greyLevels) - __pixel++; - __err = __err - 255; - } else { - } - if (__err) { - __e16 = __err >> 4; - __eR = __e16 * 7; /* 7/16 -> right pixel */ - __eRB = __e16 * 1; /* 1/16 -> right below */ - __eB = __e16 * 5; /* 5/16 -> below */ - __eLB = __err - __eR - __eRB - __eB; /* 3/16 -> left below */ - - __errorArray [__x+1+1] += __eR; - __errorArray1[__x+1+1] += __eRB; - __errorArray1[__x+1 ] += __eB; - __errorArray1[__x+1-1] += __eLB; - } - - __srcIdx += 3; - - __byte = (__byte << __depth) | __pixel; - - __bitCnt = __bitCnt - __depth; - if (__bitCnt == 0) { - __outBits[__dstIdx] = __byte; - __dstIdx++; - __byte = 0; - __bitCnt = 8; - } - } - - if (__bitCnt != 8) { - __byte = __byte << __bitCnt; - __outBits[__dstIdx] = __byte; - __bitCnt = 8; - } - __srcIdx = __nextSrc; - __dstIdx = __nextDst; - } + bzero(errorArray1, (__w+2) * 2); + + __bitCnt = 8; + for (__y=0; __y<__h; __y++) { + __nextDst = __dstIdx + __bytesPerOutRow; + __nextSrc = __srcIdx + __bytesPerRow; + + __byte = 0; + + __t = __errorArray; + __errorArray = __errorArray1; + __errorArray1 = __t; + bzero(errorArray1, (__w+2) * 2); + + for (__x=0; __x<__w; __x++) { + __grey = (__bytes[__srcIdx] * 3) /* 0.3*r + 0.6*g + b -> 0..2550 */ + + (__bytes[__srcIdx+1] * 6) + + __bytes[__srcIdx+2]; + __grey = __grey / 10; /* 0 .. 255 */ + + __pixel = __greyMap1[__grey]; /* 0..(greyLevels-1) */ + __err = __greyMap2[__grey]; /* 0.. 255 - error) */ + __err += __errorArray[__x+1]; + + if (__err > 127) { /* dither says: next pixel */ + if ( __pixel != __greyLevels) + __pixel++; + __err = __err - 255; + } else { + } + if (__err) { + __e16 = __err >> 4; + __eR = __e16 * 7; /* 7/16 -> right pixel */ + __eRB = __e16 * 1; /* 1/16 -> right below */ + __eB = __e16 * 5; /* 5/16 -> below */ + __eLB = __err - __eR - __eRB - __eB; /* 3/16 -> left below */ + + __errorArray [__x+1+1] += __eR; + __errorArray1[__x+1+1] += __eRB; + __errorArray1[__x+1 ] += __eB; + __errorArray1[__x+1-1] += __eLB; + } + + __srcIdx += 3; + + __byte = (__byte << __depth) | __pixel; + + __bitCnt = __bitCnt - __depth; + if (__bitCnt == 0) { + __outBits[__dstIdx] = __byte; + __dstIdx++; + __byte = 0; + __bitCnt = 8; + } + } + + if (__bitCnt != 8) { + __byte = __byte << __bitCnt; + __outBits[__dstIdx] = __byte; + __bitCnt = 8; + } + __srcIdx = __nextSrc; + __dstIdx = __nextDst; + } } %}. ^ outBits - "Created: 10.6.1996 / 13:28:22 / cg" - "Modified: 10.6.1996 / 15:09:07 / cg" + "Created: / 10-06-1996 / 13:28:22 / cg" + "Modified: / 10-06-1996 / 15:09:07 / cg" + "Modified: / 31-01-2017 / 12:39:31 / stefan" ! floydSteinbergDitheredMonochromeBits @@ -2956,9 +2959,10 @@ initialize super initialize. samplesPerPixel := 3. - bitsPerSample := #(8 8 8). + bitsPerSample := #[8 8 8]. "Created: / 27-05-2007 / 14:09:34 / cg" + "Modified: / 30-01-2017 / 18:29:01 / stefan" ! ! !Depth24Image methodsFor:'magnification'! @@ -3154,19 +3158,19 @@ newBytes := ByteArray uninitializedNew:(newWidth * 3 * 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:#(8 8 8) - colorMap:nil - bits:newBytes - mask:newMask. + width:newWidth + height:newHeight + photometric:photometric + samplesPerPixel:samplesPerPixel + bitsPerSample:#[8 8 8] + colorMap:nil + bits:newBytes + mask:newMask. "walk over destination image fetching pixels from source image" @@ -3184,14 +3188,14 @@ double _mY = __floatVal(mY); for (_row = 0; _row <= _h; _row++) { - _srcRowP = _srcP + (_width3 * (int)((double)_row / _mY)); - for (_col = 0; _col <= _w; _col++) { - sP = _srcRowP + (((int)((double)_col / _mX)) * 3); - _dstP[0] = sP[0]; - _dstP[1] = sP[1]; - _dstP[2] = sP[2]; - _dstP += 3; - } + _srcRowP = _srcP + (_width3 * (int)((double)_row / _mY)); + for (_col = 0; _col <= _w; _col++) { + sP = _srcRowP + (((int)((double)_col / _mX)) * 3); + _dstP[0] = sP[0]; + _dstP[1] = sP[1]; + _dstP[2] = sP[2]; + _dstP += 3; + } } %} . @@ -3201,17 +3205,17 @@ w := newWidth - 1. h := newHeight - 1. 0 to:h do:[:row | - srcRowIdx := (width * 3 * (row // mY)) + 1. - 0 to:w do:[:col | - srcIndex := srcRowIdx + ((col // mX) * 3). - value := bytes at:srcIndex. - newBytes at:dstIndex put:value. - value := bytes at:(srcIndex + 1). - newBytes at:(dstIndex + 1) put:value. - value := bytes at:(srcIndex + 2). - newBytes at:(dstIndex + 2) put:value. - dstIndex := dstIndex + 3 - ] + srcRowIdx := (width * 3 * (row // mY)) + 1. + 0 to:w do:[:col | + srcIndex := srcRowIdx + ((col // mX) * 3). + value := bytes at:srcIndex. + newBytes at:dstIndex put:value. + value := bytes at:(srcIndex + 1). + newBytes at:(dstIndex + 1) put:value. + value := bytes at:(srcIndex + 2). + newBytes at:(dstIndex + 2) put:value. + dstIndex := dstIndex + 3 + ] ]. " ^ newImage @@ -3277,9 +3281,10 @@ The return value is an array of bits-per-plane." bitsPerSample notNil ifTrue:[^ bitsPerSample]. - ^ #(8 8 8) - - "Modified: 10.6.1996 / 18:02:33 / cg" + ^ #[8 8 8] + + "Modified: / 10-06-1996 / 18:02:33 / cg" + "Modified: / 30-01-2017 / 18:27:45 / stefan" ! blueBitsOf:pixel diff -r 295325696e0d -r 46203abe7d57 Depth2Image.st --- a/Depth2Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Depth2Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -107,11 +107,12 @@ "left pixel is in high bits" index := lineIndex + (x // 4). byte := bytes at:index. - shift := #(6 4 2 0) at:((x \\ 4) + 1). + shift := #[6 4 2 0] at:((x \\ 4) + 1). byte := (byte bitAnd:(3 bitShift:shift) bitInvert) bitOr:(aPixelValue bitShift:shift). bytes at:index put:byte - "Created: 24.4.1997 / 17:06:36 / cg" + "Created: / 24-04-1997 / 17:06:36 / cg" + "Modified: / 30-01-2017 / 19:22:33 / stefan" ! ! !Depth2Image methodsFor:'converting images'! @@ -996,9 +997,10 @@ really used. However, assume that we don't care for those extra colors here ..." - ^ #(0 1 2 3) + ^ #[0 1 2 3] - "Modified: / 28.7.1998 / 22:23:15 / cg" + "Modified: / 28-07-1998 / 22:23:15 / cg" + "Modified: / 30-01-2017 / 19:23:07 / stefan" ! ! !Depth2Image class methodsFor:'documentation'! diff -r 295325696e0d -r 46203abe7d57 Depth32Image.st --- a/Depth32Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Depth32Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -862,9 +862,10 @@ initialize super initialize. samplesPerPixel := 4. - bitsPerSample := #(8 8 8 8). + bitsPerSample := #[8 8 8 8]. "Created: / 27-05-2007 / 14:09:16 / cg" + "Modified: / 30-01-2017 / 19:32:13 / stefan" ! ! !Depth32Image methodsFor:'magnification'! @@ -980,7 +981,9 @@ The return value is an array of bits-per-plane." bitsPerSample notNil ifTrue:[^ bitsPerSample]. - ^ #(8 8 8 8) + ^ #[8 8 8 8] + + "Modified: / 30-01-2017 / 19:23:31 / stefan" ! blueBitsOf:pixel diff -r 295325696e0d -r 46203abe7d57 Depth48Image.st --- a/Depth48Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Depth48Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -111,7 +111,9 @@ initialize super initialize. samplesPerPixel := 3. - bitsPerSample := #(16 16 16). + bitsPerSample := #[16 16 16]. + + "Modified: / 30-01-2017 / 19:32:29 / stefan" ! ! !Depth48Image methodsFor:'queries'! diff -r 295325696e0d -r 46203abe7d57 Depth4Image.st --- a/Depth4Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Depth4Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -137,26 +137,24 @@ |lineIndex "{ Class: SmallInteger }" byte "{ Class: SmallInteger }" w "{ Class: SmallInteger }" - pixel dstIdx bytes| + pixel bytes| bytes := self bits. - dstIdx := 1. w := width - 1. - lineIndex := (self bytesPerRow * y). + lineIndex := self bytesPerRow * y. 0 to:w do:[:x | - x even ifTrue:[ - lineIndex := lineIndex + 1. - byte := bytes at:lineIndex. - pixel := (byte bitShift:-4) bitAnd:16rF. - ] ifFalse:[ - pixel := byte bitAnd:16rF. - ]. - aPixelBuffer at:dstIdx put:pixel. - dstIdx := dstIdx + 1 + x even ifTrue:[ + lineIndex := lineIndex + 1. + byte := bytes at:lineIndex. + pixel := (byte bitShift:-4) bitAnd:16rF. + ] ifFalse:[ + pixel := byte bitAnd:16rF. + ]. + aPixelBuffer at:x+1 put:pixel. ]. - "Created: 21.7.1997 / 18:04:00 / cg" - "Modified: 21.7.1997 / 18:05:47 / cg" + "Created: / 21-07-1997 / 18:04:00 / cg" + "Modified: / 30-01-2017 / 18:51:24 / stefan" ! ! !Depth4Image methodsFor:'converting images'! @@ -857,7 +855,6 @@ real image processing, specialized methods should be written." |srcIndex "{ Class: SmallInteger }" - byte "{ Class: SmallInteger }" shift "{ Class: SmallInteger }" pixelValue "{ Class: SmallInteger }" x1 "{ Class: SmallInteger }" @@ -871,26 +868,25 @@ srcIndex := (self bytesPerRow * y) + 1. srcIndex := srcIndex + (x1 // 2). x1 even ifTrue:[ - shift := -4 + shift := -4 ] ifFalse:[ - shift := 0 + shift := 0 ]. x1 to:x2 do:[:x | - shift == 0 ifTrue:[ - byte := bytes at:srcIndex. - pixelValue := byte bitAnd:16rF. - shift := -4. - srcIndex := srcIndex + 1. - ] ifFalse:[ - byte := bytes at:srcIndex. - pixelValue := (byte bitShift:-4) bitAnd:16rF. - shift := 0 - ]. - aBlock value:x value:pixelValue. + pixelValue := bytes at:srcIndex. + shift == 0 ifTrue:[ + shift := -4. + srcIndex := srcIndex + 1. + ] ifFalse:[ + pixelValue := pixelValue bitShift:-4. + shift := 0 + ]. + aBlock value:x value:(pixelValue bitAnd:16rF). ] - "Created: 7.6.1996 / 19:09:45 / cg" + "Created: / 07-06-1996 / 19:09:45 / cg" + "Modified (format): / 30-01-2017 / 20:41:31 / stefan" ! ! !Depth4Image methodsFor:'magnification'! diff -r 295325696e0d -r 46203abe7d57 Depth64Image.st --- a/Depth64Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Depth64Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -113,7 +113,9 @@ initialize super initialize. samplesPerPixel := 4. - bitsPerSample := #(16 16 16 16). + bitsPerSample := #[16 16 16 16]. + + "Modified: / 31-01-2017 / 13:11:33 / stefan" ! ! !Depth64Image methodsFor:'queries'! diff -r 295325696e0d -r 46203abe7d57 Depth8Image.st --- a/Depth8Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Depth8Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " COPYRIGHT (c) 1993 by Claus Gittinger All Rights Reserved @@ -196,8 +198,8 @@ srcDepth map bytes| srcDepth := anImage depth. - (#(1 2 4) includes:srcDepth) ifFalse:[ - ^ super fromImage:anImage + (#[1 2 4] includes:srcDepth) ifFalse:[ + ^ super fromImage:anImage ]. width := w := anImage width. @@ -208,14 +210,14 @@ self colormapFromImage:anImage. colorMap isNil ifTrue:[ - "/ if source has no colorMap, more work is needed ... - map := #( - #[0 16rFF] - #[0 16r55 16rAA 16rFF] - nil - #[16r00 16r11 16r22 16r33 16r44 16r55 16r66 16r77 - 16r88 16r99 16rAA 16rBB 16rCC 16rDD 16rEE 16rFF] - ) at:srcDepth. + "/ if source has no colorMap, more work is needed ... + map := #( + #[0 16rFF] + #[0 16r55 16rAA 16rFF] + nil + #[16r00 16r11 16r22 16r33 16r44 16r55 16r66 16r77 + 16r88 16r99 16rAA 16rBB 16rCC 16rDD 16rEE 16rFF] + ) at:srcDepth. ]. self mask:anImage mask. @@ -231,14 +233,14 @@ dstIdx := 1. bytes := self bits. bytes isNil ifTrue:[ - self bits:(bytes := ByteArray new:(self bytesPerRow * self height)). + self bits:(bytes := ByteArray new:(self bytesPerRow * self height)). ]. 1 to:h do:[:hi | - srcBuffer replaceFrom:1 to:srcBytesPerRow with:srcBytes startingAt:srcIdx. - srcBuffer expandPixels:srcDepth width:w height:1 into:dstBuffer mapping:map. - bytes replaceFrom:dstIdx to:dstIdx+w-1 with:dstBuffer startingAt:1. - dstIdx := dstIdx + w. - srcIdx := srcIdx + srcBytesPerRow. + srcBuffer replaceFrom:1 to:srcBytesPerRow with:srcBytes startingAt:srcIdx. + srcBuffer expandPixels:srcDepth width:w height:1 into:dstBuffer mapping:map. + bytes replaceFrom:dstIdx to:dstIdx+w-1 with:dstBuffer startingAt:1. + dstIdx := dstIdx + w. + srcIdx := srcIdx + srcBytesPerRow. ] " @@ -256,7 +258,8 @@ i8 inspect. " - "Modified: 24.4.1997 / 14:01:14 / cg" + "Modified: / 24-04-1997 / 14:01:14 / cg" + "Modified: / 30-01-2017 / 19:33:25 / stefan" ! ! !Depth8Image methodsFor:'converting images'! @@ -334,9 +337,6 @@ usedColors do:[:aColorIndex | |devColor color - r "{Class: SmallInteger }" - g "{Class: SmallInteger }" - b "{Class: SmallInteger }" mapIndex "{Class: SmallInteger }"| fit ifTrue:[ @@ -601,8 +601,9 @@ ^ f - "Modified: 15.10.1997 / 01:48:20 / cg" - "Created: 19.10.1997 / 04:57:05 / cg" + "Modified: / 15-10-1997 / 01:48:20 / cg" + "Created: / 19-10-1997 / 04:57:05 / cg" + "Modified (comment): / 30-01-2017 / 21:00:08 / stefan" ! anyImageAsTrueColorFormOn:aDevice @@ -1096,9 +1097,9 @@ w "{Class: SmallInteger }" h "{Class: SmallInteger }" index "{Class: SmallInteger }" + lookupPos "{Class: SmallInteger }" ditherIds failed lastColor qScramble - clrLookup lookupPos - error clr| + clrLookup error clr| "/ "/ collect color components as integer values (for integer arithmetic) @@ -1106,77 +1107,77 @@ rgbBytes := ByteArray uninitializedNew:256 * 3. photometric == #palette ifTrue:[ - lastColor := colorMap size - 1 + lastColor := colorMap size - 1 ] ifFalse:[ - lastColor := 255. + lastColor := 255. ]. index := 1. 0 to:lastColor do:[:pix | - clr := self colorFromValue:pix. - rgbBytes at:index put:(clr redByte). - rgbBytes at:index+1 put:(clr greenByte). - rgbBytes at:index+2 put:(clr blueByte). - - index := index + 3. + clr := self colorFromValue:pix. + rgbBytes at:index put:(clr redByte). + rgbBytes at:index+1 put:(clr greenByte). + rgbBytes at:index+2 put:(clr blueByte). + + index := index + 3. ]. "/ collect valid ditherColors ... aMapOrNil isNil ifTrue:[ - ditherColors := colors select:[:clr | clr notNil]. + ditherColors := colors select:[:clr | clr notNil]. ] ifFalse:[ - ditherColors := colors + ditherColors := colors ]. "/ ... and sort by manhatten distance from black qScramble := #( - "/ 2rX00X00X00X00 - - 2r000000000000 "/ 0 - 2r000000000100 "/ 1 - 2r000000100000 "/ 2 - 2r000000100100 "/ 3 - 2r000100000000 "/ 4 - 2r000100000100 "/ 5 - 2r000100100000 "/ 6 - 2r000100100100 "/ 7 - 2r100000000000 "/ 8 - 2r100000000100 "/ 9 - 2r100000100000 "/ a - 2r100000100100 "/ b - 2r100100000000 "/ c - 2r100100000100 "/ d - 2r100100100000 "/ e - 2r100100100100 "/ f - ). + "/ 2rX00X00X00X00 + + 2r000000000000 "/ 0 + 2r000000000100 "/ 1 + 2r000000100000 "/ 2 + 2r000000100100 "/ 3 + 2r000100000000 "/ 4 + 2r000100000100 "/ 5 + 2r000100100000 "/ 6 + 2r000100100100 "/ 7 + 2r100000000000 "/ 8 + 2r100000000100 "/ 9 + 2r100000100000 "/ a + 2r100000100100 "/ b + 2r100100000000 "/ c + 2r100100000100 "/ d + 2r100100100000 "/ e + 2r100100100100 "/ f + ). ditherColors := ditherColors sort:[:a :b | - |cr "{Class: SmallInteger }" - cg "{Class: SmallInteger }" - cb "{Class: SmallInteger }" - i1 "{Class: SmallInteger }" - i2 "{Class: SmallInteger }"| - - cr := a redByte. - cg := a greenByte. - cb := a blueByte. - i1 := qScramble at:((cr bitShift:-4) bitAnd:16r0F) + 1. - i1 := i1 + ((qScramble at:((cg bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). - i1 := i1 + ((qScramble at:((cb bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). - - cr := b redByte. - cg := b greenByte. - cb := b blueByte. - i2 := qScramble at:((cr bitShift:-4) bitAnd:16r0F) + 1. - i2 := i2 + ((qScramble at:((cg bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). - i2 := i2 + ((qScramble at:((cb bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). - - i1 < i2 - ]. + |cr "{Class: SmallInteger }" + cg "{Class: SmallInteger }" + cb "{Class: SmallInteger }" + i1 "{Class: SmallInteger }" + i2 "{Class: SmallInteger }"| + + cr := a redByte. + cg := a greenByte. + cb := a blueByte. + i1 := qScramble at:((cr bitShift:-4) bitAnd:16r0F) + 1. + i1 := i1 + ((qScramble at:((cg bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). + i1 := i1 + ((qScramble at:((cb bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). + + cr := b redByte. + cg := b greenByte. + cb := b blueByte. + i2 := qScramble at:((cr bitShift:-4) bitAnd:16r0F) + 1. + i2 := i2 + ((qScramble at:((cg bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). + i2 := i2 + ((qScramble at:((cb bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). + + i1 < i2 + ]. aMapOrNil isNil ifTrue:[ - ditherIds := (ditherColors asArray collect:[:clr | clr colorId]) asByteArray. + ditherIds := (ditherColors asArray collect:[:clr | clr colorId]) asByteArray. ] ifFalse:[ - ditherIds := aMapOrNil asByteArray + ditherIds := aMapOrNil asByteArray ]. "/ build an index table, for fast lookup from manhatten-r-g-b distance @@ -1185,20 +1186,20 @@ clrLookup := ByteArray new:(4096). index := 0. ditherColors keysAndValuesDo:[:clrPosition :clr | - |r g b i| - - r := clr redByte. - g := clr greenByte. - b := clr blueByte. - i := qScramble at:((r bitShift:-4) bitAnd:16r0F) + 1. - i := i + ((qScramble at:((g bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). - i := i + ((qScramble at:((b bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). - lookupPos := i. - - [index < lookupPos] whileTrue:[ - clrLookup at:(index+1) put:(clrPosition-1-1). - index := index + 1 - ] + |r g b i| + + r := clr redByte. + g := clr greenByte. + b := clr blueByte. + i := qScramble at:((r bitShift:-4) bitAnd:16r0F) + 1. + i := i + ((qScramble at:((g bitShift:-4) bitAnd:16r0F) + 1) bitShift:-1). + i := i + ((qScramble at:((b bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). + lookupPos := i. + + index+1 to:lookupPos do:[:idx| + clrLookup at:idx put:(clrPosition-1-1). + ]. + index := lookupPos. ]. clrLookup from:index+1 to:4096 put:(ditherColors size - 1). @@ -1214,16 +1215,16 @@ ditherRGBBytes := ByteArray uninitializedNew:(lastColor * 3). index := 1. 1 to:lastColor do:[:pix | - clr := ditherColors at:pix. - ditherRGBBytes at:index put:(clr redByte). - ditherRGBBytes at:index+1 put:(clr greenByte). - ditherRGBBytes at:index+2 put:(clr blueByte). - aMapOrNil isNil ifTrue:[ - ditherIds at:pix put:clr colorId. - ] ifFalse:[ - ditherIds at:pix put:(aMapOrNil at:pix). - ]. - index := index + 3. + clr := ditherColors at:pix. + ditherRGBBytes at:index put:(clr redByte). + ditherRGBBytes at:index+1 put:(clr greenByte). + ditherRGBBytes at:index+2 put:(clr blueByte). + aMapOrNil isNil ifTrue:[ + ditherIds at:pix put:clr colorId. + ] ifFalse:[ + ditherIds at:pix put:(aMapOrNil at:pix). + ]. + index := index + 3. ]. pseudoBits := ByteArray uninitializedNew:(width * height). @@ -1253,23 +1254,23 @@ int __nColors = __intVal(lastColor); int __wR = -1, __wG, __wB; static int __qScramble[16] = { - 0x000 /* 2r000000000000 0 */, - 0x004 /* 2r000000000100 1 */, - 0x020 /* 2r000000100000 2 */, - 0x024 /* 2r000000100100 3 */, - 0x100 /* 2r000100000000 4 */, - 0x104 /* 2r000100000100 5 */, - 0x120 /* 2r000100100000 6 */, - 0x124 /* 2r000100100100 7 */, - 0x800 /* 2r100000000000 8 */, - 0x804 /* 2r100000000100 9 */, - 0x820 /* 2r100000100000 a */, - 0x824 /* 2r100000100100 b */, - 0x900 /* 2r100100000000 c */, - 0x904 /* 2r100100000100 d */, - 0x920 /* 2r100100100000 e */, - 0x924 /* 2r100100100100 f */, - }; + 0x000 /* 2r000000000000 0 */, + 0x004 /* 2r000000000100 1 */, + 0x020 /* 2r000000100000 2 */, + 0x024 /* 2r000000100100 3 */, + 0x100 /* 2r000100000000 4 */, + 0x104 /* 2r000100000100 5 */, + 0x120 /* 2r000100100000 6 */, + 0x124 /* 2r000100100100 7 */, + 0x800 /* 2r100000000000 8 */, + 0x804 /* 2r100000000100 9 */, + 0x820 /* 2r100000100000 a */, + 0x824 /* 2r100000100100 b */, + 0x900 /* 2r100100000000 c */, + 0x904 /* 2r100100000100 d */, + 0x920 /* 2r100100100000 e */, + 0x924 /* 2r100100100100 f */, + }; if (__isByteArrayLike(__INST(bytes)) && __isByteArray(pseudoBits) @@ -1278,50 +1279,50 @@ && __isByteArray(ditherIds) && __isByteArray(clrLookup) && __isByteArray(error)) { - failed = false; - - srcP = __ByteArrayInstPtr(__INST(bytes))->ba_element; - dstP = __ByteArrayInstPtr(pseudoBits)->ba_element; - rgbP = __ByteArrayInstPtr(rgbBytes)->ba_element; - idP = __ByteArrayInstPtr(ditherIds)->ba_element; - __clrLookup = __ByteArrayInstPtr(clrLookup)->ba_element; - errP = (short *) __ByteArrayInstPtr(error)->ba_element; - - /* - * clear error accumulator - */ - eP = errP; - bzero(eP, (__w+2) * 2 * 3); - - for (__y=__h; __y>0; __y--) { - __eR = __eG = __eB = 0; - - eP = &(errP[3]); - __eR = eP[0]; - __eG = eP[1]; - __eB = eP[2]; - - for (__x=__w; __x>0; __x--) { - int __want; - int pix; - int __wantR, __wantG, __wantB; - int idx; - int tR, tG, tB; - int nR, nG, nB; - int dR, dG, dB; - int minDelta, bestIdx; - int cnt; - - pix = *srcP++; - - /* - * wR, wG and wB is the wanted r/g/b value; - */ - idx = pix+pix+pix; /* pix * 3 */ - - __wantR = rgbP[idx] + __eR; - __wantG = rgbP[idx+1] + __eG; - __wantB = rgbP[idx+2] + __eB; + failed = false; + + srcP = __ByteArrayInstPtr(__INST(bytes))->ba_element; + dstP = __ByteArrayInstPtr(pseudoBits)->ba_element; + rgbP = __ByteArrayInstPtr(rgbBytes)->ba_element; + idP = __ByteArrayInstPtr(ditherIds)->ba_element; + __clrLookup = __ByteArrayInstPtr(clrLookup)->ba_element; + errP = (short *) __ByteArrayInstPtr(error)->ba_element; + + /* + * clear error accumulator + */ + eP = errP; + bzero(eP, (__w+2) * 2 * 3); + + for (__y=__h; __y>0; __y--) { + __eR = __eG = __eB = 0; + + eP = &(errP[3]); + __eR = eP[0]; + __eG = eP[1]; + __eB = eP[2]; + + for (__x=__w; __x>0; __x--) { + int __want; + int pix; + int __wantR, __wantG, __wantB; + int idx; + int tR, tG, tB; + int nR, nG, nB; + int dR, dG, dB; + int minDelta, bestIdx; + int cnt; + + pix = *srcP++; + + /* + * wR, wG and wB is the wanted r/g/b value; + */ + idx = pix+pix+pix; /* pix * 3 */ + + __wantR = rgbP[idx] + __eR; + __wantG = rgbP[idx+1] + __eG; + __wantB = rgbP[idx+2] + __eB; #define RED_SCALE 30 #define GREEN_SCALE 59 @@ -1338,236 +1339,236 @@ #define NPROBE 8 #ifndef FAST_LOOKUP - if ((__wantR == __wR) - && (__wantG == __wG) - && (__wantB == __wB)) { - /* - * same color again - reuse last bestMatch - */ - } else + if ((__wantR == __wR) + && (__wantG == __wG) + && (__wantB == __wB)) { + /* + * same color again - reuse last bestMatch + */ + } else #endif - { - __wR = __wantR; - __wG = __wantG; - __wB = __wantB; + { + __wR = __wantR; + __wG = __wantG; + __wB = __wantB; #ifdef FAST_LOOKUP - if(__wR > 255) __wR = 255; - else if (__wR < 0) __wR = 0; - if(__wG > 255) __wG = 255; - else if (__wG < 0) __wG = 0; - if(__wB > 255) __wB = 255; - else if (__wB < 0) __wB = 0; - - { - int lookupIndex; - int idx, idx0; - int d, delta; - unsigned char *dp0; - - dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; - lookupIndex = __qScramble[((__wR & 0xF0)>>4)]; - lookupIndex |= __qScramble[((__wG & 0xF0)>>4)] >> 1; - lookupIndex |= __qScramble[((__wB & 0xF0)>>4)] >> 2; - idx = bestIdx =__clrLookup[lookupIndex]; - dp += (idx+idx+idx); - - /* try color at lookupIndex */ - - d = dp[0]; - delta = (__wR - d) * RED_SCALE; - if (delta < 0) delta = -delta; - - d = dp[1]; - if (__wG > d) - delta += (__wG - d) * GREEN_SCALE; - else - delta += (d - __wG) * GREEN_SCALE; - d = dp[2]; - if (__wB > d) - delta += (__wB - d) * BLUE_SCALE; - else - delta += (d - __wB) * BLUE_SCALE; - - if (delta <= GOOD_DELTA) { - goto foundBest; - } - minDelta = delta; + if(__wR > 255) __wR = 255; + else if (__wR < 0) __wR = 0; + if(__wG > 255) __wG = 255; + else if (__wG < 0) __wG = 0; + if(__wB > 255) __wB = 255; + else if (__wB < 0) __wB = 0; + + { + int lookupIndex; + int idx, idx0; + int d, delta; + unsigned char *dp0; + + dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; + lookupIndex = __qScramble[((__wR & 0xF0)>>4)]; + lookupIndex |= __qScramble[((__wG & 0xF0)>>4)] >> 1; + lookupIndex |= __qScramble[((__wB & 0xF0)>>4)] >> 2; + idx = bestIdx =__clrLookup[lookupIndex]; + dp += (idx+idx+idx); + + /* try color at lookupIndex */ + + d = dp[0]; + delta = (__wR - d) * RED_SCALE; + if (delta < 0) delta = -delta; + + d = dp[1]; + if (__wG > d) + delta += (__wG - d) * GREEN_SCALE; + else + delta += (d - __wG) * GREEN_SCALE; + d = dp[2]; + if (__wB > d) + delta += (__wB - d) * BLUE_SCALE; + else + delta += (d - __wB) * BLUE_SCALE; + + if (delta <= GOOD_DELTA) { + goto foundBest; + } + minDelta = delta; # ifndef ONE_SHOT - idx0 = idx; dp0 = dp; - cnt = 0; - while ((++cnt <= NPROBE) && (idx > 0)) { - /* try previous color(s) */ - - idx--; dp -= 3; - d = dp[0]; - delta = (__wR - d) * RED_SCALE; - if (delta < 0) delta = -delta; - d = dp[1]; - if (__wG > d) - delta += (__wG - d) * GREEN_SCALE; - else - delta += (d - __wG) * GREEN_SCALE; - d = dp[2]; - if (__wB > d) - delta += (__wB - d) * BLUE_SCALE; - else - delta += (d - __wB) * BLUE_SCALE; - - if (delta < minDelta) { - bestIdx = idx; - if (delta <= GOOD_DELTA) { - goto foundBest; - } - minDelta = delta; - } - } - - idx = idx0; dp = dp0; - cnt = 0; - while ((++cnt <= NPROBE) && (++idx < __nColors)) { - /* try next color */ - - dp += 3; - d = dp[0]; - delta = (__wR - d) * RED_SCALE; - if (delta < 0) delta = -delta; - d = dp[1]; - if (__wG > d) - delta += (__wG - d) * GREEN_SCALE; - else - delta += (d - __wG) * GREEN_SCALE; - d = dp[2]; - if (__wB > d) - delta += (__wB - d) * BLUE_SCALE; - else - delta += (d - __wB) * BLUE_SCALE; - - if (delta < minDelta) { - bestIdx = idx; - if (delta <= GOOD_DELTA) { - goto foundBest; - } - minDelta = delta; - } - } + idx0 = idx; dp0 = dp; + cnt = 0; + while ((++cnt <= NPROBE) && (idx > 0)) { + /* try previous color(s) */ + + idx--; dp -= 3; + d = dp[0]; + delta = (__wR - d) * RED_SCALE; + if (delta < 0) delta = -delta; + d = dp[1]; + if (__wG > d) + delta += (__wG - d) * GREEN_SCALE; + else + delta += (d - __wG) * GREEN_SCALE; + d = dp[2]; + if (__wB > d) + delta += (__wB - d) * BLUE_SCALE; + else + delta += (d - __wB) * BLUE_SCALE; + + if (delta < minDelta) { + bestIdx = idx; + if (delta <= GOOD_DELTA) { + goto foundBest; + } + minDelta = delta; + } + } + + idx = idx0; dp = dp0; + cnt = 0; + while ((++cnt <= NPROBE) && (++idx < __nColors)) { + /* try next color */ + + dp += 3; + d = dp[0]; + delta = (__wR - d) * RED_SCALE; + if (delta < 0) delta = -delta; + d = dp[1]; + if (__wG > d) + delta += (__wG - d) * GREEN_SCALE; + else + delta += (d - __wG) * GREEN_SCALE; + d = dp[2]; + if (__wB > d) + delta += (__wB - d) * BLUE_SCALE; + else + delta += (d - __wB) * BLUE_SCALE; + + if (delta < minDelta) { + bestIdx = idx; + if (delta <= GOOD_DELTA) { + goto foundBest; + } + minDelta = delta; + } + } # endif - } - foundBest: ; + } + foundBest: ; #else /* - if(__wR > 255) __wR = 255; - else if (__wR < 0) __wR = 0; - if(__wG > 255) __wG = 255; - else if (__wG < 0) __wG = 0; - if(__wB > 255) __wB = 255; - else if (__wB < 0) __wB = 0; + if(__wR > 255) __wR = 255; + else if (__wR < 0) __wR = 0; + if(__wG > 255) __wG = 255; + else if (__wG < 0) __wG = 0; + if(__wB > 255) __wB = 255; + else if (__wB < 0) __wB = 0; */ - /* find the best matching color */ - - minDelta = 99999; - bestIdx = -1; - dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; - for (idx = 0; idx<__nColors; idx++) { - int d, delta; - - d = dp[0]; - delta = (__wR - d) * RED_SCALE; - if (delta < 0) delta = -delta; - if (delta < minDelta) { - d = dp[1]; - if (__wG > d) - delta += (__wG - d) * GREEN_SCALE; - else - delta += (d - __wG) * GREEN_SCALE; - if (delta < minDelta) { - d = dp[2]; - if (__wB > d) - delta += (__wB - d) * BLUE_SCALE; - else - delta += (d - __wB) * BLUE_SCALE; - - if (delta < minDelta) { - bestIdx = idx; - if (delta <= GOOD_DELTA) { - break; - } - minDelta = delta; - } - } - } - dp += 3; - } + /* find the best matching color */ + + minDelta = 99999; + bestIdx = -1; + dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; + for (idx = 0; idx<__nColors; idx++) { + int d, delta; + + d = dp[0]; + delta = (__wR - d) * RED_SCALE; + if (delta < 0) delta = -delta; + if (delta < minDelta) { + d = dp[1]; + if (__wG > d) + delta += (__wG - d) * GREEN_SCALE; + else + delta += (d - __wG) * GREEN_SCALE; + if (delta < minDelta) { + d = dp[2]; + if (__wB > d) + delta += (__wB - d) * BLUE_SCALE; + else + delta += (d - __wB) * BLUE_SCALE; + + if (delta < minDelta) { + bestIdx = idx; + if (delta <= GOOD_DELTA) { + break; + } + minDelta = delta; + } + } + } + dp += 3; + } #endif - } - dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; - dp += bestIdx * 3; - dR = dp[0]; - dG = dp[1]; - dB = dp[2]; + } + dp = __ByteArrayInstPtr(ditherRGBBytes)->ba_element; + dp += bestIdx * 3; + dR = dp[0]; + dG = dp[1]; + dB = dp[2]; /* console_fprintf(stderr, "want: %d/%d/%d (%d/%d/%d) got: %d/%d/%d\n", - __wantR, __wantG, __wantB, - __wR, __wG, __wB, - dR, dG, dB); + __wantR, __wantG, __wantB, + __wR, __wG, __wB, + dR, dG, dB); */ - /* - * store the corresponding dither colors colorId - */ - *dstP++ = idP[bestIdx]; - - /* - * the new error & distribute the error - */ - __eR = __wantR - dR; - if (__eR) { - tR = __eR >> 4; /* 16th of error */ - nR = eP[3] + (tR * 7);/* from accu: error for (x+1 / y) */ - eP[0] = tR*5; /* 5/16th for (x / y+1) */ - eP[-3] = tR*3; /* 3/16th for (x-1 / y+1) */ - eP[3] = __eR - (tR*15); /* 1/16th for (x+1 / y+1) */ - __eR = nR; - } else { - __eR = eP[3]; - eP[0] = eP[-3] = eP[3] = 0; - } - - __eG = __wantG - dG; - if (__eG) { - tG = __eG >> 4; - nG = eP[4] + (tG * 7);/* plus 7/16'th of this error */ - eP[1] = tG*5; - eP[-2] = tG*3; - eP[4] = __eG - (tG*15); - __eG = nG; - } else { - __eG = eP[4]; - eP[1] = eP[-2] = eP[4] = 0; - } - - __eB = __wantB - dB; - if (__eB) { - tB = __eB >> 4; - nB = eP[5] + (tB * 7); - eP[2] = tB*5; - eP[-1] = tB*3; - eP[5] = __eB - (tB*15); - __eB = nB; - } else { - __eB = eP[5]; - eP[2] = eP[-1] = eP[5] = 0; - } - - eP += 3; - } - } + /* + * store the corresponding dither colors colorId + */ + *dstP++ = idP[bestIdx]; + + /* + * the new error & distribute the error + */ + __eR = __wantR - dR; + if (__eR) { + tR = __eR >> 4; /* 16th of error */ + nR = eP[3] + (tR * 7);/* from accu: error for (x+1 / y) */ + eP[0] = tR*5; /* 5/16th for (x / y+1) */ + eP[-3] = tR*3; /* 3/16th for (x-1 / y+1) */ + eP[3] = __eR - (tR*15); /* 1/16th for (x+1 / y+1) */ + __eR = nR; + } else { + __eR = eP[3]; + eP[0] = eP[-3] = eP[3] = 0; + } + + __eG = __wantG - dG; + if (__eG) { + tG = __eG >> 4; + nG = eP[4] + (tG * 7);/* plus 7/16'th of this error */ + eP[1] = tG*5; + eP[-2] = tG*3; + eP[4] = __eG - (tG*15); + __eG = nG; + } else { + __eG = eP[4]; + eP[1] = eP[-2] = eP[4] = 0; + } + + __eB = __wantB - dB; + if (__eB) { + tB = __eB >> 4; + nB = eP[5] + (tB * 7); + eP[2] = tB*5; + eP[-1] = tB*3; + eP[5] = __eB - (tB*15); + __eB = nB; + } else { + __eB = eP[5]; + eP[2] = eP[-1] = eP[5] = 0; + } + + eP += 3; + } + } } %}. failed ifTrue:[ - self primitiveFailed. - ^ nil + self primitiveFailed. + ^ nil ]. ^ pseudoBits @@ -1952,16 +1953,16 @@ x1 := xLow. x2 := xHigh. - srcIndex := (width * y) + 1 + x1. + srcIndex := (width * y) + 1. bytes := self bits. x1 to:x2 do:[:x | - pixelValue := bytes at:srcIndex. - srcIndex := srcIndex + 1. - aBlock value:x value:pixelValue + pixelValue := bytes at:srcIndex+x. + aBlock value:x value:pixelValue ] - "Created: 7.6.1996 / 19:09:47 / cg" + "Created: / 07-06-1996 / 19:09:47 / cg" + "Modified: / 30-01-2017 / 18:54:15 / stefan" ! valuesFromX:xStart y:yStart toX:xEnd y:yEnd do:aBlock @@ -1974,8 +1975,7 @@ However, for real high performance image processing, specialized methods should be written which know how to deal with specific photometric interpretations." - |srcIndex "{ Class: SmallInteger }" - srcNext "{ Class: SmallInteger }" + |srcIndex "{ Class: SmallInteger }" bytesPerRow "{ Class: SmallInteger }" value "{ Class: SmallInteger }" x1 "{ Class: SmallInteger }" @@ -1989,24 +1989,21 @@ y1 := yStart. y2 := yEnd. - srcIndex := (width * y1) + x1 + 1 . + srcIndex := (width * y1) + 1 . bytesPerRow := self bytesPerRow. bytes := self bits. y1 to:y2 do:[:y | - srcNext := srcIndex + bytesPerRow. - x1 to:x2 do:[:x | - value := bytes at:srcIndex. - srcIndex := srcIndex + 1. - - aBlock value:x value:y value:value - ]. - srcIndex := srcNext. + x1 to:x2 do:[:x | + value := bytes at:srcIndex+x. + aBlock value:x value:y value:value + ]. + srcIndex := srcIndex + bytesPerRow. ]. - ^ self - - "Modified: 11.7.1996 / 20:06:47 / cg" - "Created: 11.7.1996 / 20:08:11 / cg" + + "Created: / 11-07-1996 / 20:08:11 / cg" + "Modified: / 30-01-2017 / 19:04:05 / stefan" + "Modified (format): / 31-01-2017 / 12:44:04 / stefan" ! ! !Depth8Image methodsFor:'image manipulations'! @@ -2169,19 +2166,19 @@ newBytes := ByteArray uninitializedNew:(newWidth * 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:#(8) - colorMap:colorMap copy - bits:newBytes - mask:newMask. + width:newWidth + height:newHeight + photometric:photometric + samplesPerPixel:samplesPerPixel + bitsPerSample:#[8] + colorMap:colorMap copy + bits:newBytes + mask:newMask. "walk over destination image fetching pixels from source image" @@ -2199,10 +2196,10 @@ double __mY = __floatVal(mY); for (__row = 0; __row <= __h; __row++) { - __srcRowP = __srcP + (__width * (int)((double)__row / __mY)); - for (__col = 0; __col <= __w; __col++) { - *__dstP++ = __srcRowP[(int)((double)__col / __mX)]; - } + __srcRowP = __srcP + (__width * (int)((double)__row / __mY)); + for (__col = 0; __col <= __w; __col++) { + *__dstP++ = __srcRowP[(int)((double)__col / __mX)]; + } } %} . diff -r 295325696e0d -r 46203abe7d57 DeviceGraphicsContext.st --- a/DeviceGraphicsContext.st Wed Feb 01 21:42:41 2017 +0000 +++ b/DeviceGraphicsContext.st Wed Feb 01 22:17:58 2017 +0000 @@ -587,7 +587,7 @@ (aForm ~~ mask) ifTrue:[ mask := aForm. gcId notNil ifTrue:[ - (mask == nil) ifTrue:[ + mask isNil ifTrue:[ device setBitmapMask:nil in:gcId ] ifFalse:[ mask := mask asFormOn:device. diff -r 295325696e0d -r 46203abe7d57 GraphicsContext.st --- a/GraphicsContext.st Wed Feb 01 21:42:41 2017 +0000 +++ b/GraphicsContext.st Wed Feb 01 22:17:58 2017 +0000 @@ -1659,9 +1659,7 @@ left := origin x. top := origin y. - self displayRectangleX:left y:top - width:(corner x - left) - height:(corner y - top) + self displayRectangleX:left y:top width:(corner x - left) height:(corner y - top) "Modified: 13.4.1996 / 20:58:31 / cg" ! diff -r 295325696e0d -r 46203abe7d57 GraphicsMedium.st --- a/GraphicsMedium.st Wed Feb 01 21:42:41 2017 +0000 +++ b/GraphicsMedium.st Wed Feb 01 22:17:58 2017 +0000 @@ -1814,9 +1814,7 @@ left := origin x. top := origin y. - self displayRectangleX:left y:top - width:(corner x - left) - height:(corner y - top) + self displayRectangleX:left y:top width:(corner x - left) height:(corner y - top) ! displayRectangleOrigin:origin extent:extent @@ -2420,7 +2418,7 @@ "fill the receiver with something; something may be a Form, Color or colorIndex" - gc fillRectangle:self boundingBox color:something + gc fillRectangle:(self boundingBox) color:something ! fillArc:origin radius:r from:startAngle angle:angle diff -r 295325696e0d -r 46203abe7d57 Image.st --- a/Image.st Wed Feb 01 21:42:41 2017 +0000 +++ b/Image.st Wed Feb 01 22:17:58 2017 +0000 @@ -999,9 +999,8 @@ ! extent:ext depth:d antiAliasedPalette:aBasicColorArray bgColor:bgColor mixedArray:mixedArray - |colors colorMap colorIndex colorDictionary tmpDic newImage emptyBits| - - colors := OrderedCollection new. + |colorMap colorIndex colorDictionary tmpDic newImage| + colorMap := OrderedCollection new. colorIndex := 0. colorDictionary := Dictionary new. @@ -1057,13 +1056,15 @@ from:0 angle:360 withColor:Color blue - antiAliasedPalette:aaImgArray first - startWith:aaImgArray second. + colorDictionary:aaImgArray first + blendStart:aaImgArray second. aaImgArray last inspect. " "Modified: / 02-11-2010 / 20:57:41 / cg" + "Modified: / 31-01-2017 / 14:30:22 / stefan" + "Modified (comment): / 31-01-2017 / 15:47:39 / stefan" ! extent:ext depth:d bits:bits @@ -1095,7 +1096,7 @@ "create & return a blank image of the given size. ST-80 compatibility" - |newImage emptyBits| + |newImage| newImage := (self implementorForDepth:d) new. newImage width:ext x height:ext y depth:d palette:aColormap. @@ -1112,6 +1113,7 @@ "Created: / 06-03-1997 / 15:24:01 / cg" "Modified: / 02-11-2010 / 20:56:53 / cg" + "Modified (format): / 31-01-2017 / 14:51:03 / stefan" ! extent:ext depth:d palette:aColormap bits:bits @@ -1227,7 +1229,7 @@ depth := aForm depth. formsDevice := aForm device. - photometric := (depth > 8) ifTrue:#rgb ifFalse:#palette. + photometric := (depth > 8) ifTrue:[#rgb] ifFalse:[#palette]. (formsDevice notNil and:[depth == formsDevice depth]) ifTrue:[ "/ @@ -1274,6 +1276,8 @@ (Image fromForm:f) inspect. (Image fromSubForm:(5@5 corner:10@10) in:f) inspect " + + "Modified: / 31-01-2017 / 15:03:17 / stefan" ! fromSubImage:anImage in:aRectangle @@ -1286,7 +1290,7 @@ |cls| self == Image ifTrue:[ - cls := (self implementorForDepth:anImage depth). + cls := self implementorForDepth:anImage depth. ] ifFalse:[ cls := self. ]. @@ -1322,8 +1326,9 @@ i24 inspect " - "Created: 20.9.1995 / 01:05:43 / claus" - "Modified: 24.4.1997 / 23:13:02 / cg" + "Created: / 20-09-1995 / 01:05:43 / claus" + "Modified: / 24-04-1997 / 23:13:02 / cg" + "Modified (format): / 30-01-2017 / 19:45:54 / stefan" ! new @@ -1747,8 +1752,8 @@ inStream := fn readStream. zipStream := ZipStream readOpenOn:inStream suppressHeaderAndChecksum:true. zipStream notNil ifTrue:[ - [ - image := readerClass fromStream:zipStream. + image := [ + readerClass fromStream:zipStream. ] ensure:[ zipStream close. inStream close. @@ -1756,8 +1761,11 @@ ] ] ifFalse:[ BadImageFormatQuerySignal handle:[:ex | - BadImageFormatQuerySignal isHandled ifTrue:[ ex reject ]. - Transcript showCR:(readersErrorMsg := ex description). + BadImageFormatQuerySignal isHandled ifTrue:[ + ex reject + ]. + readersErrorMsg := ex description. + Logger warning:readersErrorMsg. image := nil. ex return. ] do:[ @@ -1835,6 +1843,7 @@ " "Modified: / 19-11-2007 / 15:50:52 / cg" + "Modified: / 31-01-2017 / 15:56:14 / stefan" ! fromFile:aFileName inPackage:aPackage @@ -1910,7 +1919,9 @@ ] ifFalse:[ dpiH := 90 ]. - ((dpi >= (dpiH * 0.75)) and:[dpi <= (dpiH * 1.5)]) ifTrue:[^ img]. + (dpi between:(dpiH * 0.75) and:(dpiH * 1.5)) ifTrue:[ + ^ img + ]. mag := (dpiH / dpi) rounded. mag = 0 ifTrue:[^ img]. mag = 1 ifTrue:[^ img]. @@ -1921,7 +1932,8 @@ ]. ^ img - "Modified: 1.2.1997 / 14:48:20 / cg" + "Modified: / 01-02-1997 / 14:48:20 / cg" + "Modified (format): / 31-01-2017 / 15:06:23 / stefan" ! fromStream:aStream @@ -2193,6 +2205,10 @@ "Modified: 24.4.1997 / 19:04:52 / cg" ! +isAbstract + ^ self == Image +! + isImageFileSuffix:aSuffix "return true, if the given suffix is known to be an image files suffix" @@ -2316,12 +2332,11 @@ with:aRectangle top with:aRectangle width with:aRectangle height). - [ - img := Image fromFile:tmpFile. + ^ [ + Image fromFile:tmpFile. ] ensure:[ tmpFile remove. ]. - ^ img. ]. ]. @@ -2342,7 +2357,8 @@ img := self newForDepth:depth. ^ img fromScreen:aRectangle on:aDisplay grab:doGrab - "Modified: / 26.1.1998 / 22:23:08 / cg" + "Modified: / 26-01-1998 / 22:23:08 / cg" + "Modified: / 30-01-2017 / 19:49:01 / stefan" ! fromScreenArea @@ -2780,8 +2796,7 @@ colorMap:aColorMap "set the colorMap; this also sets the photometric to a useful default." - |newSize "{ Class: SmallInteger }" - oldSize "{ Class: SmallInteger }" + |oldSize "{ Class: SmallInteger }" sameColors| (aColorMap isNil and:[colorMap isNil]) ifTrue:[^ self]. @@ -2790,7 +2805,8 @@ photometric == #palette ifTrue:[ "/ any change at all ? - (newSize := aColorMap size) >= (oldSize := colorMap size) ifTrue:[ + oldSize := colorMap size. + aColorMap size >= oldSize ifTrue:[ sameColors := true. 1 to:oldSize do:[:idx | @@ -2817,8 +2833,9 @@ self release ] - "Modified: / 31.8.1995 / 03:05:59 / claus" - "Modified: / 22.8.1998 / 12:29:58 / cg" + "Modified: / 31-08-1995 / 03:05:59 / claus" + "Modified: / 22-08-1998 / 12:29:58 / cg" + "Modified: / 31-01-2017 / 14:48:56 / stefan" ! colorMapFromArray: anArray @@ -3033,11 +3050,13 @@ ! setColorMap:aColorMap - (aColorMap isNil or:[aColorMap isKindOf:Colormap]) ifFalse:[ - colorMap := MappedPalette withColors:aColorMap - ] ifTrue:[ - colorMap := aColorMap - ] + colorMap isColormap ifTrue:[ + colorMap := aColorMap. + ] ifFalse:[ + colorMap := MappedPalette withColors:aColorMap. + ]. + + "Modified: / 30-01-2017 / 19:15:34 / stefan" ! width @@ -3753,15 +3772,15 @@ "/ bitsPerPixel := d. d == 24 ifTrue:[ samplesPerPixel := 3. - bitsPerSample := #(8 8 8) + bitsPerSample := #[8 8 8] ] ifFalse:[ d == 32 ifTrue:[ samplesPerPixel := 4. - bitsPerSample := #(8 8 8 8) + bitsPerSample := #[8 8 8 8] ] ifFalse:[ d == 16 ifTrue:[ samplesPerPixel := 3. - bitsPerSample := #(5 5 5). + bitsPerSample := #[5 5 5]. "/ bitsPerPixel := 15. ] ifFalse:[ samplesPerPixel := 1. @@ -3771,6 +3790,7 @@ ] "Modified: / 27-05-2007 / 16:59:47 / cg" + "Modified: / 30-01-2017 / 19:36:00 / stefan" ! extent:anExtent @@ -4102,8 +4122,9 @@ newBits isNil ifTrue:[ self error:'dithering failed' ]. - ^ (self class newForDepth:d) extent:(self extent); depth:d; palette:colors; bits:newBits - + ^ (self class newForDepth:d) extent:(self extent); depth:d; palette:colors; bits:newBits; yourself + + "Modified: / 30-01-2017 / 19:40:19 / stefan" ! asErrorDitheredMonochromeImage @@ -4741,24 +4762,27 @@ "Modified: 14.6.1996 / 15:17:28 / cg" ! -asGrayImageDepth:depth +asGrayImageDepth:depthArg "get a gray image from the receiver" - ((self colorMap notNil and:[depth <= 8 and:[depth >= self depth]]) - or:[ self depth >= 8 "do need for dither" ]) ifTrue:[ + ((self colorMap notNil and:[depthArg between:self depth and:8]) + or:[self depth >= 8 "do need for dither" ]) ifTrue:[ ^ self copyWithColorMapProcessing:[:clr | Color brightness:(clr brightness)]. ]. - ^ self asGrayImageDepth:depth dither:DitherAlgorithm. - - " - |i| - - i := Image fromFile:'goodies/bitmaps/claus.gif'. - (i asGrayFormOn:Display) inspect. - " - - "Modified: 10.6.1996 / 17:39:30 / cg" - "Created: 10.6.1996 / 19:07:08 / cg" + ^ self asGrayImageDepth:depthArg dither:DitherAlgorithm. + + " + |i| + + i := Image fromFile:'../../goodies/bitmaps/gifImages/claus.gif'. + (i asGrayImageDepth:16). + (i asGrayImageDepth:4). + " + + "Modified: / 10-06-1996 / 17:39:30 / cg" + "Created: / 10-06-1996 / 19:07:08 / cg" + "Modified: / 30-01-2017 / 20:13:06 / stefan" + "Modified (comment): / 31-01-2017 / 13:25:29 / stefan" ! asGrayImageDepth:depth dither:aDitherAlgorithm @@ -5022,7 +5046,9 @@ newBits isNil ifTrue:[ self error:'conversion failed' ]. - ^ (self class newForDepth:d) extent:(self extent); depth:d; palette:colors; bits:newBits + ^ (self class newForDepth:d) extent:(self extent); depth:d; palette:colors; bits:newBits; yourself + + "Modified: / 30-01-2017 / 19:40:28 / stefan" ! asOrderedDitheredGrayFormOn:aDevice @@ -5864,9 +5890,7 @@ |map clr mappedRowPixels samePhotometric h "{ Class: SmallInteger }" - w "{ Class: SmallInteger }" - a r g b rgbPixel - myDepth otherDepth| + w "{ Class: SmallInteger }" myDepth otherDepth| width := anImage width. height := anImage height. @@ -5889,7 +5913,7 @@ ]. self mask:anImage mask. - samePhotometric := (photometric == anImage photometric). + samePhotometric := photometric == anImage photometric. myDepth := self depth. otherDepth := anImage depth. @@ -5991,6 +6015,7 @@ " "Modified: / 22-11-2016 / 03:34:08 / cg" + "Modified (format): / 30-01-2017 / 20:46:22 / stefan" ! fromSubImage:anImage in:aRectangle @@ -6217,7 +6242,7 @@ pictureDepth := bitsPerSample at:1. - (#(2 4 8) includes:pictureDepth) ifFalse:[ + (#[2 4 8] includes:pictureDepth) ifFalse:[ self error:'currently only depth-2, 4 or 8 supported'. ^ nil ]. @@ -6328,15 +6353,15 @@ with:(f initGC). ^ f - "Modified: 19.10.1997 / 05:19:44 / cg" + "Modified: / 19-10-1997 / 05:19:44 / cg" + "Modified: / 30-01-2017 / 19:37:01 / stefan" ! greyImageAsTrueColorFormOn:aDevice "return a true-color device-form for the grey-image receiver. TODO: the pixel loops ought to be implemented as inline primitive code ..." - |depth - myDepth "{ Class: SmallInteger }" + |myDepth "{ Class: SmallInteger }" nColors "{ Class: SmallInteger }" colorValues scaleDown @@ -6355,7 +6380,6 @@ "/ this is a slow fallback method; this ought to be "/ redefined in DepthxImage for more performance. - depth := aDevice depth. myDepth := self depth. myDepth > 16 ifTrue:[ self error:'unsupported depth' mayProceed:true. @@ -6440,6 +6464,7 @@ "Created: / 20-10-1995 / 22:05:10 / cg" "Modified: / 05-02-2011 / 10:40:13 / cg" + "Modified (format): / 31-01-2017 / 14:42:05 / stefan" ! ! !Image methodsFor:'converting palette images'! @@ -6455,7 +6480,8 @@ ^ self asMonochromeFormOn:aDevice ]. - ((type := aDevice visualType) == #StaticGray) ifTrue:[ + type := aDevice visualType. + (type == #StaticGray) ifTrue:[ ddepth == 8 ifTrue:[ ^ self paletteImageAsGray8FormOn:aDevice ]. @@ -6480,7 +6506,8 @@ ^ self paletteImageAsPseudoFormOn:aDevice - "Modified: 14.6.1996 / 19:31:01 / cg" + "Modified: / 14-06-1996 / 19:31:01 / cg" + "Modified: / 30-01-2017 / 20:55:32 / stefan" ! paletteImageAsPseudoFormOn:aDevice @@ -6489,7 +6516,7 @@ |tempImage d temp8| d := self depth. - (#(1 2 4 8) includes:d) ifTrue:[ + (#[1 2 4 8] includes:d) ifTrue:[ " fallback code for some depth's: create a temporary Depth8Image and use its conversion method @@ -6507,13 +6534,14 @@ ^ tempImage paletteImageAsPseudoFormOn:aDevice ]. ^ self subclassResponsibility + + "Modified: / 30-01-2017 / 19:37:57 / stefan" ! paletteImageAsTrueColorFormOn:aDevice "return a true-color device-form for the palette-image receiver." - |depth - nColors "{ Class: SmallInteger }" + |nColors "{ Class: SmallInteger }" h "{ Class: SmallInteger }" pixel "{ Class: SmallInteger }" colorValues @@ -6525,8 +6553,6 @@ "/ this is a slow fallback method; this ought to be "/ redefined in DepthxImage for more performance. - depth := aDevice depth. - bestFormat := self bestSupportedImageFormatFor:aDevice. usedDeviceDepth := bestFormat at:#depth. usedDeviceDepth == 1 ifTrue:[ @@ -6593,7 +6619,7 @@ self rowAt:y into:pixelArray. 1 to:width do:[:x | pixel := pixelArray at:x. - newPixelArray at:x put:(colorValues at:pixel + 1 ifAbsent:0). + newPixelArray at:x put:(colorValues at:pixel + 1 ifAbsent:[0]). ]. i rowAt:y putAll:newPixelArray. ]. @@ -6637,7 +6663,8 @@ ^ form - "Modified: / 24.7.1998 / 00:56:14 / cg" + "Modified: / 24-07-1998 / 00:56:14 / cg" + "Modified: / 31-01-2017 / 15:01:05 / stefan" ! ! !Image methodsFor:'converting rgb images'! @@ -6660,9 +6687,9 @@ shiftGreen := aDevice shiftGreen. shiftBlue := aDevice shiftBlue. - nRed := (1 bitShift:aDevice bitsRed). - nGreen := (1 bitShift:aDevice bitsGreen). - nBlue := (1 bitShift:aDevice bitsBlue). + nRed := 1 bitShift:aDevice bitsRed. + nGreen := 1 bitShift:aDevice bitsGreen. + nBlue := 1 bitShift:aDevice bitsBlue. fixColors := Array new:(nRed * nGreen * nBlue). @@ -6673,7 +6700,7 @@ pixel := (sR bitShift:shiftRed) + (sG bitShift:shiftGreen) + (sB bitShift:shiftBlue). - fixColors at:dstIdx put:(Color colorId:(pixel)). + fixColors at:dstIdx put:(Color colorId:pixel). dstIdx := dstIdx + 1 ] ] @@ -6684,8 +6711,9 @@ colors:fixColors nRed:nRed nGreen:nGreen nBlue:nBlue - "Created: 14.6.1996 / 17:23:52 / cg" - "Modified: 23.6.1997 / 15:22:36 / cg" + "Created: / 14-06-1996 / 17:23:52 / cg" + "Modified: / 23-06-1997 / 15:22:36 / cg" + "Modified (format): / 30-01-2017 / 19:06:08 / stefan" ! compressColorMap @@ -6919,16 +6947,17 @@ and clear out any device handles in the copy." bytes := bytes copy. - (colorMap isNil or:[colorMap isKindOf:Colormap]) ifFalse:[ + colorMap isColormap ifTrue:[ + colorMap := colorMap copy. + ] ifFalse:[ colorMap := MappedPalette withColors:colorMap. - ] ifTrue:[ - colorMap := colorMap copy. ]. device := deviceForm := monoDeviceForm := fullColorDeviceForm := nil. mask := mask copy. maskedPixelsAre0 := false. - "Modified: / 22.8.1998 / 11:27:09 / cg" + "Modified: / 22-08-1998 / 11:27:09 / cg" + "Modified: / 30-01-2017 / 19:16:02 / stefan" ! skipInstvarIndexInDeepCopy:index @@ -6937,6 +6966,9 @@ " self allInstanceVariableNames indexOf:#device + self allInstanceVariableNames indexOf:#deviceForm + self allInstanceVariableNames indexOf:#monoDeviceForm + self allInstanceVariableNames indexOf:#fullColorDeviceForm " index == 13 ifTrue:[ @@ -6952,6 +6984,8 @@ ^ true "/ skip fullColorDeviceForm ]. ^ false + + "Modified (comment): / 31-01-2017 / 15:41:40 / stefan" ! ! !Image methodsFor:'displaying'! @@ -7176,9 +7210,9 @@ w "{Class: SmallInteger }" h "{Class: SmallInteger }" index "{Class: SmallInteger }" + lookupPos "{Class: SmallInteger }" ditherIds failed lastColor qScramble - clrLookup lookupPos - error clr| + clrLookup error clr| self depth ~~ 24 ifTrue:[^ nil]. @@ -7257,10 +7291,10 @@ i := i + ((qScramble at:((b bitShift:-4) bitAnd:16r0F) + 1) bitShift:-2). lookupPos := i. - [index < lookupPos] whileTrue:[ - clrLookup at:(index+1) put:(clrPosition-1-1). - index := index + 1 - ] + index+1 to:lookupPos do:[:idx| + clrLookup at:idx put:(clrPosition-1-1). + ]. + index := lookupPos. ]. clrLookup from:index+1 to:4096 put:(ditherColors size - 1). @@ -7630,6 +7664,8 @@ ]. ^ pseudoBits + + "Modified: / 30-01-2017 / 19:58:45 / stefan" ! floydSteinbergDitheredDepth8BitsColors:fixColors nRed:nRed nGreen:nGreen nBlue:nBlue @@ -10068,7 +10104,7 @@ processPixelToFill := [:spX :spY | - |samePixel sp idx| + |samePixel idx| mask isNil ifTrue:[ samePixel := (self pixelAtX:spX y:spY) == detectedPixel @@ -10136,7 +10172,8 @@ self release. "/ device-image is no longer valid ^ allDetectedPixelCoordinates - "Modified: / 29.7.1998 / 03:09:16 / cg" + "Modified: / 29-07-1998 / 03:09:16 / cg" + "Modified (format): / 30-01-2017 / 20:57:36 / stefan" ! rectangle: aRectangle withColor:aColor @@ -10278,18 +10315,19 @@ should be redefined in concrete subclasses, to avoid some processing when going from pixel to pixel (i.e. the byte-index and mask computations)." - |xS "{Class: SmallInteger }" - xE "{Class: SmallInteger }"| - - xS := xStart. - xE := xEnd. - yStart to:yEnd do:[:yRun | + |yS "{Class: SmallInteger }" + yE "{Class: SmallInteger }"| + + yS := yStart. + yE := yEnd. + yS to:yE do:[:yRun | self valuesAtY:yRun from:xStart to:xEnd do:[:xRun :pixel | aBlock value:xRun value:yRun value:pixel ] ] - "Modified: 7.6.1996 / 19:09:29 / cg" + "Modified: / 07-06-1996 / 19:09:29 / cg" + "Modified: / 31-01-2017 / 14:46:26 / stefan" ! ! !Image methodsFor:'finalization'! @@ -11845,21 +11883,19 @@ ^ self copyWithColorMapProcessing:[:clr | - |newColor| - - newColor := Color - redByte:(255 - clr redByte) - greenByte:(255 - clr greenByte) - blueByte:(255 - clr blueByte) - ] + Color + redByte:(255 - clr redByte) + greenByte:(255 - clr greenByte) + blueByte:(255 - clr blueByte) + ] " (Image fromFile:'goodies/bitmaps/gifImages/claus.gif') inspect (Image fromFile:'goodies/bitmaps/gifImages/claus.gif') negative inspect " - "Created: 20.6.1997 / 13:13:41 / cg" - "Modified: 20.6.1997 / 13:17:50 / cg" + "Created: / 20-06-1997 / 13:13:41 / cg" + "Modified: / 31-01-2017 / 14:43:19 / stefan" ! rotated:degrees @@ -11976,13 +12012,12 @@ threeDProjected:fraction1 and:fraction2 "return a 3D-projected version" - |dx1 dx2 newImage newBytesPerRow newBits - blackPixel halfW halfH m myDepth maskBits pix fr fl ml mr dm fractX my fy dstY o1 o2 df| + |dx1 dx2 newImage newBits + blackPixel halfH m myDepth maskBits pix fr fl ml mr dm fractX my fy dstY o1 df| newImage := self species new. newImage width:width. newImage height:height. - newBytesPerRow := newImage bytesPerRow. newImage createPixelStore. newBits := newImage bits. newImage photometric:photometric. @@ -12028,7 +12063,6 @@ "/ now, walk over destination pixels, "/ fetching from source. - halfW := (width - 1) / 2.0. halfH := (height - 1) / 2.0. "/ -------------------------------------------------------------- @@ -12065,7 +12099,6 @@ my := ml + (dm * fractX). fy := fl + (df * fractX). o1 := dx1 * fractX. - o2 := dx2 * fractX. 0 to:height-1 do:[:srcY | srcY < halfH ifTrue:[ @@ -12091,6 +12124,8 @@ (i threeDProjected:0.1 and:0.3) inspect (i threeDProjected:0.1 and:0.1) inspect " + + "Modified: / 31-01-2017 / 15:04:22 / stefan" ! withColorResolutionReducedBy:numBits @@ -12138,7 +12173,7 @@ ]. - photometric == #palette ifFalse:[ + photometric ~~ #palette ifTrue:[ "/ direct manipulation of the pixels 0 to:yMax do:[:y | 0 to:xMax do:[:x | @@ -12153,7 +12188,7 @@ anyChange ifFalse:[ ^ nil ]. - ] ifTrue:[ + ] ifFalse:[ "/ manipulate the colormap 0 to:yMax do:[:y | 0 to:xMax do:[:x | @@ -12192,6 +12227,8 @@ ]. ^ newImage + + "Modified: / 30-01-2017 / 20:15:02 / stefan" ! withPixelFunctionApplied:pixelFunctionBlock @@ -12800,16 +12837,17 @@ computeBitsFromPixelFunction "compute the bits from the pixelfunction" - |bpr idx| + |bpr| bpr := self bytesPerRow. bytes := ByteArray new:(bpr * height). - idx := 1. 0 to:height-1 do:[:y | 0 to:width-1 do:[:x | self pixelAtX:x y:y put:(pixelFunction value:x value:y). ] ]. + + "Modified: / 31-01-2017 / 14:39:26 / stefan" ! pixelFunction @@ -13477,13 +13515,14 @@ samplesPerPixel == 4 ifTrue:[ "/ assume that the cyan bits are the leftMost bits (cmyk) - bitsPerSample = #(8 8 8 8) ifTrue:[ + (#[8 8 8 8] isSameSequenceAs:bitsPerSample) ifTrue:[ ^ 100.0 / 255 * (pixel bitAnd:16rFF) ] ]. self subclassResponsibility + "Modified (format): / 31-01-2017 / 13:15:23 / stefan" ! blueBitsOf:pixel @@ -13700,14 +13739,14 @@ samplesPerPixel == 3 ifTrue:[ "/ assume that the cyan bits are the leftMost bits (cmy) - - bitsPerSample = #(8 8 8) ifTrue:[ + (#[8 8 8] isSameSequenceAs:bitsPerSample)ifTrue:[ ^ 100.0 / 255 * ((pixel bitShift:-16) bitAnd:16rFF) ] ]. self subclassResponsibility + "Modified (format): / 31-01-2017 / 13:15:56 / stefan" ! cyanComponentOfCMYK:pixel @@ -13716,14 +13755,14 @@ samplesPerPixel == 4 ifTrue:[ "/ assume that the cyan bits are the leftMost bits (cmyk) - - bitsPerSample = #(8 8 8 8) ifTrue:[ + (#[8 8 8 8] isSameSequenceAs:bitsPerSample)ifTrue:[ ^ 100.0 / 255 * ((pixel bitShift:-24) bitAnd:16rFF) ] ]. self subclassResponsibility + "Modified: / 31-01-2017 / 13:16:14 / stefan" ! greenBitsOf:pixel @@ -13851,15 +13890,14 @@ return the magenta component scaled to a percentage (0 .. 100) of a pixelValue." samplesPerPixel == 3 ifTrue:[ - "/ assume that the cyan bits are the leftMost bits (cmy) - - bitsPerSample = #(8 8 8) ifTrue:[ + (#[8 8 8] isSameSequenceAs:bitsPerSample)ifTrue:[ ^ 100.0 / 255 * ((pixel bitShift:-8) bitAnd:16rFF) ] ]. self subclassResponsibility + "Modified (format): / 31-01-2017 / 13:19:06 / stefan" ! magentaComponentOfCMYK:pixel @@ -13867,15 +13905,14 @@ return the magenta component scaled to a percentage (0 .. 100) of a pixelValue." samplesPerPixel == 4 ifTrue:[ - "/ assume that the cyan bits are the leftMost bits (cmyk) - - bitsPerSample = #(8 8 8 8) ifTrue:[ + (#[8 8 8 8] isSameSequenceAs:bitsPerSample)ifTrue:[ ^ 100.0 / 255 * ((pixel bitShift:-16) bitAnd:16rFF) ] ]. self subclassResponsibility + "Modified (format): / 31-01-2017 / 13:19:11 / stefan" ! nColorsUsed @@ -13885,12 +13922,13 @@ pixelArraySpecies "return the kind of pixel-value container in rowAt:/rowAt:put: methods" - |d| - - (d := self depth) <= 8 ifTrue:[^ ByteArray]. + self depth <= 8 ifTrue:[^ ByteArray]. + "/ (d := self depth) <= 8 ifTrue:[^ ByteArray]. "/ d <= 16 ifTrue:[^ WordArray]. "/ ^ IntegerArray ^ Array + + "Modified: / 31-01-2017 / 14:52:42 / stefan" ! realColorMap @@ -14295,7 +14333,7 @@ "given a color, return the corresponding pixel value. Non-representable colors return nil." - |pixel redBits greenBits blueBits alphaBits r g b a| + |pixel redBits greenBits blueBits r g b a| r := rgb bitAnd:16rFF. g := (rgb bitShift:-8) bitAnd:16rFF. @@ -14346,7 +14384,7 @@ redBits := bitsPerSample at:1. greenBits := bitsPerSample at:2. blueBits := bitsPerSample at:3. - alphaBits := bitsPerSample at:4. +"/ alphaBits := bitsPerSample at:4. pixel := (((((a bitShift:redBits) + r) bitShift:greenBits) + g) bitShift:blueBits) + b. ^ pixel ] @@ -14355,6 +14393,7 @@ ^ nil "Created: / 15-01-2008 / 15:55:08 / cg" + "Modified: / 31-01-2017 / 14:45:00 / stefan" ! valueFromRedBits:redBits greenBits:greenBits blueBits:blueBits @@ -14396,9 +14435,7 @@ return the yellow component scaled to a percentage (0 .. 100) of a pixelValue." samplesPerPixel == 3 ifTrue:[ - "/ assume that the cyan bits are the leftMost bits (cmy) - - bitsPerSample = #(8 8 8) ifTrue:[ + (#[8 8 8] isSameSequenceAs:bitsPerSample)ifTrue:[ ^ 100.0 / 255 * (pixel bitAnd:16rFF) ] ]. @@ -14406,6 +14443,7 @@ self subclassResponsibility + "Modified (format): / 31-01-2017 / 13:18:47 / stefan" ! yellowComponentOfCMYK:pixel @@ -14413,15 +14451,14 @@ return the yellow component scaled to a percentage (0 .. 100) of a pixelValue." samplesPerPixel == 4 ifTrue:[ - "/ assume that the cyan bits are the leftMost bits (cmyk) - - bitsPerSample = #(8 8 8 8) ifTrue:[ + (#[8 8 8 8] isSameSequenceAs:bitsPerSample)ifTrue:[ ^ 100.0 / 255 * ((pixel bitShift:-8) bitAnd:16rFF) ] ]. self subclassResponsibility + "Modified: / 31-01-2017 / 13:19:00 / stefan" ! ! !Image methodsFor:'saving on file'! @@ -14643,8 +14680,8 @@ ddepth := aDrawable depth. ]. photometric := aDrawable photometric. - samplesPerPixel := ddepth == 24 ifTrue:3 ifFalse:1. - bitsPerSample := ddepth == 24 ifTrue:#[8 8 8] ifFalse:[ByteArray with:bpp]. + samplesPerPixel := ddepth == 24 ifTrue:[3] ifFalse:[1]. + bitsPerSample := ddepth == 24 ifTrue:[#[8 8 8]] ifFalse:[ByteArray with:bpp]. ] ifFalse:[ "get some attributes of the display device" visType := device visualType. @@ -14677,7 +14714,7 @@ "/ with:device bitsGreen "/ with:device bitsBlue bpp := "bitsPerPixel :=" 24. - bitsPerSample := #(8 8 8). + bitsPerSample := #[8 8 8]. ] ifFalse:[ self error:'screen visual not supported'. ^ nil @@ -14761,9 +14798,9 @@ bytesPerLineIn := (info at:#bytesPerLine). "what I got" bytesPerLine := (w * bpp + 7) // 8. "what I want" - maskR := info at:#redMask ifAbsent:0. - maskG := info at:#greenMask ifAbsent:0. - maskB := info at:#blueMask ifAbsent:0. + maskR := info at:#redMask ifAbsent:[0]. + maskG := info at:#greenMask ifAbsent:[0]. + maskB := info at:#blueMask ifAbsent:[0]. ((bytesPerLine ~~ bytesPerLineIn) or:[bitsPerPixelIn ~~ bpp]) ifTrue:[ @@ -14898,8 +14935,8 @@ self setColorMap:map. ]. - "Modified: / 9.1.1998 / 21:32:36 / stefan" - "Modified: / 7.2.1998 / 18:23:07 / cg" + "Modified: / 07-02-1998 / 18:23:07 / cg" + "Modified: / 31-01-2017 / 15:02:52 / stefan" ! fromScreen:aRectangle diff -r 295325696e0d -r 46203abe7d57 Make.proto diff -r 295325696e0d -r 46203abe7d57 Make.spec --- a/Make.spec Wed Feb 01 21:42:41 2017 +0000 +++ b/Make.spec Wed Feb 01 22:17:58 2017 +0000 @@ -60,6 +60,7 @@ DeviceHandle \ DisplayTransform \ Event \ + FillStyle \ FontDescription \ GraphicsContext \ GraphicsDevice \ @@ -73,6 +74,7 @@ WindowSensor \ stx_libview \ BeveledBorder \ + BitmapFillStyle \ BitmapFont \ Border \ ColorPalette \ @@ -91,14 +93,20 @@ Font \ Form \ GradientBackground \ + GradientFillStyle \ HostGraphicsDevice \ ImageBackground \ MacButtonBorder \ NoBackground \ + OrientedFillStyle \ + RoundButtonBorder \ ScaleTransform \ SimpleBorder \ SolidBackground \ + SolidFillStyle \ SynchronousWindowSensor \ + TranslationTransform \ + TranslucentColor \ ViewStyle \ WindowEvent \ DeviceWorkstation \ @@ -111,7 +119,6 @@ SimpleView \ WidgetEvent \ WindowingTransformation \ - XGraphicsContext \ FixedPaletteWithAlpha \ MonoMappedPalette \ ShadowView \ @@ -121,6 +128,9 @@ StandardSystemView \ ModalBox \ +WIN32_CLASSES= \ + WinWorkstation \ + UNIX_CLASSES= \ FcConstants \ FcPattern \ @@ -129,9 +139,6 @@ XWorkstation \ GLXWorkstation \ -WIN32_CLASSES= \ - WinWorkstation \ - @@ -145,6 +152,7 @@ $(OUTDIR)DeviceHandle.$(O) \ $(OUTDIR)DisplayTransform.$(O) \ $(OUTDIR)Event.$(O) \ + $(OUTDIR)FillStyle.$(O) \ $(OUTDIR)FontDescription.$(O) \ $(OUTDIR)GraphicsContext.$(O) \ $(OUTDIR)GraphicsDevice.$(O) \ @@ -158,6 +166,7 @@ $(OUTDIR)WindowSensor.$(O) \ $(OUTDIR)stx_libview.$(O) \ $(OUTDIR)BeveledBorder.$(O) \ + $(OUTDIR)BitmapFillStyle.$(O) \ $(OUTDIR)BitmapFont.$(O) \ $(OUTDIR)Border.$(O) \ $(OUTDIR)ColorPalette.$(O) \ @@ -176,14 +185,20 @@ $(OUTDIR)Font.$(O) \ $(OUTDIR)Form.$(O) \ $(OUTDIR)GradientBackground.$(O) \ + $(OUTDIR)GradientFillStyle.$(O) \ $(OUTDIR)HostGraphicsDevice.$(O) \ $(OUTDIR)ImageBackground.$(O) \ $(OUTDIR)MacButtonBorder.$(O) \ $(OUTDIR)NoBackground.$(O) \ + $(OUTDIR)OrientedFillStyle.$(O) \ + $(OUTDIR)RoundButtonBorder.$(O) \ $(OUTDIR)ScaleTransform.$(O) \ $(OUTDIR)SimpleBorder.$(O) \ $(OUTDIR)SolidBackground.$(O) \ + $(OUTDIR)SolidFillStyle.$(O) \ $(OUTDIR)SynchronousWindowSensor.$(O) \ + $(OUTDIR)TranslationTransform.$(O) \ + $(OUTDIR)TranslucentColor.$(O) \ $(OUTDIR)ViewStyle.$(O) \ $(OUTDIR)WindowEvent.$(O) \ $(OUTDIR)DeviceWorkstation.$(O) \ @@ -207,6 +222,9 @@ $(OUTDIR)ModalBox.$(O) \ $(OUTDIR)extensions.$(O) \ +WIN32_OBJS= \ + $(OUTDIR)WinWorkstation.$(O) \ + UNIX_OBJS= \ $(OUTDIR)FcConstants.$(O) \ $(OUTDIR)FcPattern.$(O) \ @@ -215,8 +233,5 @@ $(OUTDIR)XWorkstation.$(O) \ $(OUTDIR)GLXWorkstation.$(O) \ -WIN32_OBJS= \ - $(OUTDIR)WinWorkstation.$(O) \ - diff -r 295325696e0d -r 46203abe7d57 SimpleView.st --- a/SimpleView.st Wed Feb 01 21:42:41 2017 +0000 +++ b/SimpleView.st Wed Feb 01 22:17:58 2017 +0000 @@ -10383,20 +10383,26 @@ when problem or warning conditions arise. Someone may redefine this to flash its contents (instead of black/white)." + shown ifFalse:[^ self]. + self fill:flashColor. messageOrNil notNil ifTrue:[ - self withForeground:self whiteColor do:[ - self displayString:messageOrNil centeredAt:(self center). - ]. + gc withForeground:self whiteColor do:[ + self displayString:messageOrNil centeredAt:(self center). + ]. ]. Delay waitForSeconds:0.1. + shown ifFalse:[^ self]. + self fill:self whiteColor. messageOrNil notNil ifTrue:[ - self withForeground:self blackColor do:[ - self displayString:messageOrNil centeredAt:(self center). - ]. + gc withForeground:self blackColor do:[ + self displayString:messageOrNil centeredAt:(self center). + ]. ]. Delay waitForSeconds:0.1. + shown ifFalse:[^ self]. + self fill:viewBackground. self invalidate diff -r 295325696e0d -r 46203abe7d57 TranslucentColor.st --- a/TranslucentColor.st Wed Feb 01 21:42:41 2017 +0000 +++ b/TranslucentColor.st Wed Feb 01 22:17:58 2017 +0000 @@ -38,8 +38,7 @@ documentation " - TranslucentColor represents colors with an alpha (transparency) - channel. + TranslucentColor represents colors with an alpha (transparency) channel. This is experimental and not yet used by the system. [Instance variables:] @@ -168,5 +167,9 @@ version ^ '$Header$' +! + +version_CVS + ^ '$Header$' ! ! diff -r 295325696e0d -r 46203abe7d57 WindowGroup.st --- a/WindowGroup.st Wed Feb 01 21:42:41 2017 +0000 +++ b/WindowGroup.st Wed Feb 01 22:17:58 2017 +0000 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " COPYRIGHT (c) 1993 by Claus Gittinger All Rights Reserved @@ -1071,10 +1073,11 @@ checkBlock is evaluated and the modal loop is left, whenever false is returned." - ^ self startupModal:checkBlock forGroup:(WindowGroup activeGroup). - - "Created: 10.12.1995 / 14:15:11 / cg" - "Modified: 20.8.1997 / 17:54:33 / cg" + ^ self startupModal:checkBlock forGroup:(self class activeGroup). + + "Created: / 10-12-1995 / 14:15:11 / cg" + "Modified: / 20-08-1997 / 17:54:33 / cg" + "Modified: / 31-01-2017 / 20:43:37 / stefan" ! startupModal:checkBlock forGroup:mainGroup @@ -1175,7 +1178,7 @@ the caller - which may make a difference in case of errors and/or blocking operations ...]" - |top nm dev devNm invokingApp| + |dev invokingApp| previousGroup := nil. @@ -1188,30 +1191,28 @@ "/ (well, not really forever ... ;-) myProcess := [ - [ - startupAction value. - self showWaitCursorWhenBusyForMillis:400. - self eventLoopWhile:[true] onLeave:[] - ] ensure:[ - |dev w app| - - (w := self mainView) notNil ifTrue:[ - (app := w application) notNil ifTrue:[ - app release - ] - ]. - (dev := self graphicsDevice) notNil ifTrue:[ - dev deviceIOErrorSignal handle:[:ex | - ] do:[ - "/ just in case the view did not yet have a chance to - "/ shutDown properly (process killed in processMonitor) - views notNil ifTrue:[ + [ + startupAction value. + self showWaitCursorWhenBusyForMillis:400. + self eventLoopWhile:[true] onLeave:[] + ] ensure:[ + |dev w app| + + (w := self mainView) notNil ifTrue:[ + (app := w application) notNil ifTrue:[ + app release + ] + ]. + dev := self graphicsDevice. + (dev notNil and:[views notNil]) ifTrue:[ + dev deviceIOErrorSignal catch:[ + "/ just in case the view did not yet have a chance to + "/ shutDown properly (process killed in processMonitor) self closeDownViews ] ] ] - ] - ] newProcess. + ] newProcess. self setProcessNameWithRedirectIndicator:''. myProcess priority:processPriority; @@ -1236,17 +1237,17 @@ "/ allow for the currently active application, "/ to hook on new-application process creation. - (invokingApp := WindowGroup activeMainApplication) notNil ifTrue:[ + (invokingApp := self class activeMainApplication) notNil ifTrue:[ invokingApp postApplicationProcessCreate:myProcess windowGroup:self. ]. - top := nm := dev := devNm := invokingApp:= nil. "/ to avoid dangling references via blocks home context. + dev := invokingApp:= nil. "/ to avoid dangling references via blocks home context. myProcess resume. ] - "Modified: / 13-12-1995 / 14:04:53 / stefan" "Created: / 24-07-1997 / 12:52:04 / cg" "Modified: / 17-09-2007 / 10:59:34 / cg" + "Modified: / 31-01-2017 / 21:45:42 / stefan" ! unhideTopViews @@ -1373,9 +1374,7 @@ ActivityNotifications send a #showActivity: if nonModal, otherwise they are ignored." - |thisProcess signalsToHandle| - - thisProcess := Processor activeProcess. + |signalsToHandle| signalsToHandle := SignalSet with:LeaveSignal @@ -1390,7 +1389,7 @@ WindowGroupQuerySignal answer:self do:[ [ - |p g s mainGroup mySema waitSema mainSema groupForSema| + |g s mainGroup mySema waitSema mainSema groupForSema| waitSema := mySema := mySensor eventSemaphore. @@ -1477,7 +1476,7 @@ ]. ex proceedWith:nil. ] do:[ - |dev gotSema mainView| + |gotSema mainView| (mainGroup notNil or:[mySensor hasEvents not]) ifTrue:[ waitSema isNil ifTrue:[ @@ -1500,11 +1499,7 @@ self graphicsDevice flush. ]. - self isModal ifTrue:[ - thisProcess setStateTo:#modalEventWait if:#active. - ] ifFalse:[ - thisProcess setStateTo:#eventWait if:#active. - ]. + Processor activeProcess setStateTo:(self isModal ifTrue:[#modalEventWait] ifFalse:[#eventWait]) if:#active. "/ now, wait for an event to arrive gotSema := waitSema wait. @@ -1554,8 +1549,8 @@ ] ensure:cleanupActions ] - "Modified: / 14-12-1995 / 11:12:24 / stefan" "Modified: / 06-07-2010 / 11:47:27 / cg" + "Modified (format): / 31-01-2017 / 20:43:00 / stefan" ! executePostEventHooksFor:anEvent @@ -1649,229 +1644,223 @@ self processExposeEvents. [ - LastEventQuerySignal handle:[:ex | - ex proceedWith:event - ] do:[ - [mySensor notNil - and:[(event := mySensor nextEvent) notNil]] whileTrue:[ - ignore := false. - focus := focusView. - modalDelegate := false. - modalTop := nil. - - modalGroup notNil ifTrue:[ - "/ an incoming event for a masterView, - "/ while being blocked by some other modalView. - - modalTops := modalGroup topViews. - modalTops size > 0 ifTrue:[ - modalTop := modalTops first. + [mySensor notNil + and:[(event := mySensor nextEvent) notNil]] whileTrue:[ + ignore := false. + focus := focusView. + modalDelegate := false. + modalTop := nil. + + modalGroup notNil ifTrue:[ + "/ an incoming event for a masterView, + "/ while being blocked by some other modalView. + + modalTops := modalGroup topViews. + modalTops notEmptyOrNil ifTrue:[ + modalTop := modalTops first. + ]. + + event isKeyEvent ifTrue:[ + "/ forward keyboard events to my modal + "/ groups first topView ... + modalTop notNil ifTrue:[ + focus := modalTop. + modalDelegate := true. + ]. + modalGroup focusView notNil ifTrue:[ + focus := modalGroup focusView ]. - - event isKeyEvent ifTrue:[ - "/ forward keyboard events to my modal - "/ groups first topView ... - modalTop notNil ifTrue:[ - focus := modalTop. - modalDelegate := true. + ] ifFalse:[ + event isFocusEvent ifTrue:[ + event isFocusInEvent ifTrue:[ + "/ move focus over to modalBox + modalTop notNil ifTrue:[ + modalTop getKeyboardFocus. + "/ focusIn is forwarded to the modalGroup + "/ (since keyboard is forwarded) + event view:modalTop. + focus := modalTop. + ] + ] ifFalse:[ + "/ focusOut goes to both the modal and + "/ the blocked main-group + "/ (actually, only the very first focusOut + "/ is needed in the mainGroup (to turn off the cursor) + "/ all others are only needed in the modalGroup) + +"/ syntheticEvent := event copy. +"/ syntheticEvent view:modalTop. +"/ LastEventQuerySignal handle:[:ex | +"/ ex proceedWith:syntheticEvent +"/ ] do:[ +"/ syntheticEvent sendEventWithFocusOn:nil. +"/ ]. + + "/ event view:modalTop. ]. - modalGroup focusView notNil ifTrue:[ - focus := modalGroup focusView - ]. + modalDelegate := true. ] ifFalse:[ - event isFocusEvent ifTrue:[ - event isFocusInEvent ifTrue:[ - "/ move focus over to modalBox - modalTop notNil ifTrue:[ - modalTop getKeyboardFocus. - "/ focusIn is forwarded to the modalGroup - "/ (since keyboard is forwarded) - event view:modalTop. - focus := modalTop. - ] - ] ifFalse:[ - "/ focusOut goes to both the modal and - "/ the blocked main-group - "/ (actually, only the very first focusOut - "/ is needed in the mainGroup (to turn off the cursor) - "/ all others are only needed in the modalGroup) - - "/ syntheticEvent := event copy. - "/ syntheticEvent view:modalTop. - "/ LastEventQuerySignal handle:[:ex | - "/ ex proceedWith:syntheticEvent - "/ ] do:[ - "/ syntheticEvent sendEventWithFocusOn:nil. - "/ ]. - - "/ event view:modalTop. - ]. - modalDelegate := true. + event isPointerLeaveEvent ifTrue:[ ] ifFalse:[ - event isPointerLeaveEvent ifTrue:[ - ] ifFalse:[ - event isUserEvent ifTrue:[ - ignore := true. - - event isButtonPressEvent ifTrue:[ - "/ raise the modalTop and beep - event view device beep. - modalTop notNil ifTrue:[ modalTop raise ]. - ] + event isUserEvent ifTrue:[ + ignore := true. + + event isButtonPressEvent ifTrue:[ + "/ raise the modalTop and beep + event view device beep. + modalTop notNil ifTrue:[ modalTop raise ]. ] ] ] - ]. - "/ also update the slave-sensor's modifier state from the master-sensor's - "/ state. This is needed for a popUpView to see the correct shift-, ctrl- and alt states - "/ in its own sensor. - - "/ cg: disabled 15-jun-2014 - "/ mhmh - something seems to have changed on a lower level, - "/ so now the modal sensor already has the correct sensor state - "/ (as opposed to previous versions, where this was not true). - "/ Now, enabling the following line leads to a confirmation dialog to NOT - "/ behave correctly w.r.t. Shift-CursorRight. - "/ I wonder, what is responsible for that fixing side effect... (sigh) - "/ modalGroup sensor updateModifierStatesFrom:mySensor + ] ]. - - ignore ifFalse:[ - (views notNil or:[topViews notNil]) ifTrue:[ - - "/ give eventRecorders, catchers etc. - "/ a chance to eat or modify that event - - modalGroup notNil ifTrue:[ - ignore := (modalGroup executePreEventHooksFor:event). - ] ifFalse:[ - ignore := false - ]. + "/ also update the slave-sensor's modifier state from the master-sensor's + "/ state. This is needed for a popUpView to see the correct shift-, ctrl- and alt states + "/ in its own sensor. + + "/ cg: disabled 15-jun-2014 + "/ mhmh - something seems to have changed on a lower level, + "/ so now the modal sensor already has the correct sensor state + "/ (as opposed to previous versions, where this was not true). + "/ Now, enabling the following line leads to a confirmation dialog to NOT + "/ behave correctly w.r.t. Shift-CursorRight. + "/ I wonder, what is responsible for that fixing side effect... (sigh) + "/ modalGroup sensor updateModifierStatesFrom:mySensor + ]. + + ignore ifFalse:[ + (views notNil or:[topViews notNil]) ifTrue:[ + "/ give eventRecorders, catchers etc. + "/ a chance to eat or modify that event + modalGroup notNil ifTrue:[ + ignore := modalGroup executePreEventHooksFor:event. + ] ifFalse:[ + ignore := false + ]. + ignore ifFalse:[ + ignore := self executePreEventHooksFor:event. ignore ifFalse:[ - ignore := (self executePreEventHooksFor:event). + evView := event view. + + (event isKeyEvent + and:[(keyboardProcessor := (modalTop ? evView topView) keyboardProcessor) notNil]) ifTrue:[ + ignore := keyboardProcessor processEvent:event forModalView:modalTop + ]. + ignore ifFalse:[ - evView := event view. - - (event isKeyEvent - and:[(keyboardProcessor := (modalTop ? evView topView) keyboardProcessor) notNil]) ifTrue:[ - ignore := keyboardProcessor processEvent:event forModalView:modalTop - ]. - - ignore ifFalse:[ - "/ event handling below will vanish ... - "/ (keyboardProcessor will do it eventually) - - event isKeyPressEvent ifTrue:[ - event key == #Escape ifTrue:[ - modalDelegate ifTrue:[ - top := modalTop. - ] ifFalse:[ - (isModal and:[topViews size > 0]) ifTrue:[ - top := topViews first. + "/ event handling below will vanish ... + "/ (keyboardProcessor will do it eventually) + + event isKeyPressEvent ifTrue:[ + event key == #Escape ifTrue:[ + modalDelegate ifTrue:[ + top := modalTop. + ] ifFalse:[ + (isModal and:[topViews notEmptyOrNil]) ifTrue:[ + top := topViews first. + ] + ]. + top notNil ifTrue:[ + "/ a popUpView does it himself (only closing one submenu) + (top isPopUpView not + or:[UserPreferences current closePopUpMenuChainOnEscape]) ifTrue:[ + top escapeIsCancel ifTrue:[ + top closeCancel. + "/ top hideRequest. + top realized ifFalse:[ ignore := true ]. ] - ]. - top notNil ifTrue:[ - "/ a popUpView does it himself (only closing one submenu) - (top isPopUpView not - or:[ UserPreferences current closePopUpMenuChainOnEscape ]) ifTrue:[ - top escapeIsCancel ifTrue:[ - top closeCancel. - "/ top hideRequest. - top realized ifFalse:[ ignore := true ]. - ] - ] - ]. - ] - ] ifFalse:[ - "/ - "/ keep track of which view has the pointer - "/ - event isPointerEnterEvent ifTrue:[ - pointerView := evView - ] ifFalse:[ - event isPointerLeaveEvent ifTrue:[ - pointerView := nil ] - ] - ]. + ]. + ] + ] ifFalse:[ + "/ + "/ keep track of which view has the pointer + "/ + event isPointerEnterEvent ifTrue:[ + pointerView := evView + ] ifFalse:[event isPointerLeaveEvent ifTrue:[ + pointerView := nil + ]]. ]. ]. ]. - - ignore ifFalse:[ - "/ - "/ buttonPress events turn off explicit focus, and reverts - "/ to implicit focus control - "/ This used to be done for every click - - "/ but behaved ugly if clicking in a scrollbar ... - - "/ XXX: move to dispatchEvent - event isButtonPressEvent ifTrue:[ - (evView wantsFocusWithButtonPress) ifTrue:[ - "/ cannot use 'evView requestFocus' here, - "/ since we want to enforce it without giving the - "/ view a chance to circumvent this. - - "/ evView requestFocus. - self focusView:evView. - ]. + ]. + + ignore ifFalse:[ + "/ + "/ buttonPress events turn off explicit focus, and reverts + "/ to implicit focus control + "/ This used to be done for every click - + "/ but behaved ugly if clicking in a scrollbar ... + + "/ XXX: move to dispatchEvent + event isButtonPressEvent ifTrue:[ + (evView wantsFocusWithButtonPress) ifTrue:[ + "/ cannot use 'evView requestFocus' here, + "/ since we want to enforce it without giving the + "/ view a chance to circumvent this. + + "/ evView requestFocus. + self focusView:evView. ]. - - (busyHook notNil and:[busyHookBlock isNil]) ifTrue:[ - (event isKeyEvent or:[event isButtonPressEvent]) ifTrue:[ - "/ start a timeout action - to invoke the busyHook after some time - busyHookCalled := false. - busyHookBlock := [ - (inModalLoop ~~ true and:[busyHookCalled not]) ifTrue:[ - busyHook value:true. - busyHookCalled := true - ] - ]. - Processor - addTimedBlock:busyHookBlock - for:Processor timeoutHandlerProcess - afterMilliseconds:(busyHookTimeout ? BusyHookTime ? 150). - ]. + ]. + + (busyHook notNil and:[busyHookBlock isNil]) ifTrue:[ + (event isKeyEvent or:[event isButtonPressEvent]) ifTrue:[ + "/ start a timeout action - to invoke the busyHook after some time + busyHookCalled := false. + busyHookBlock := [ + (inModalLoop ~~ true and:[busyHookCalled not]) ifTrue:[ + busyHook value:true. + busyHookCalled := true + ] + ]. + Processor + addTimedBlock:busyHookBlock + for:Processor timeoutHandlerProcess + afterMilliseconds:(busyHookTimeout ? BusyHookTime ? 150). ]. - event isMessageSendEvent ifTrue:[ - "/ a synthetic event (delayed message) + ]. + event isMessageSendEvent ifTrue:[ + "/ a synthetic event (delayed message) "/ cg: seems to not be a good idea (see modalLoopStarts): "/ if in a modal-loop, do not process now, but repush onto the queue "/ modalGroup notNil ifTrue:[ "/ mySensor pushEvent:event "/ ] ifFalse:[ - event value + event value "/ ] + ] ifFalse:[ + " + if there is no view information in the event, + it must have been sent directly to the sensor. + Send it to the first topView. + " + (evReceiver := evView) isNil ifTrue:[ + (firstTop := topViews first) notNil ifTrue:[ + event isApplicationEvent ifTrue:[ + evReceiver := firstTop application ? firstTop + ] ifFalse:[ + evReceiver := firstTop. + ]. + ] + ]. + evReceiver isNil ifTrue:[ + ('WindowGroup [warning]: no receiver to dispatch ' , event type asString , '-event to. Ignored.') infoPrintCR. ] ifFalse:[ - " - if there is no view information in the event, - it must have been sent directly to the sensor. - Send it to the first topView. - " - (evReceiver := evView) isNil ifTrue:[ - (firstTop := topViews first) notNil ifTrue:[ - event isApplicationEvent ifTrue:[ - evReceiver := firstTop application ? firstTop - ] ifFalse:[ - evReceiver := firstTop. - ]. - ] - ]. - evReceiver isNil ifTrue:[ - ('WindowGroup [warning]: no receiver to dispatch ' , event type asString , '-event to. Ignored.') infoPrintCR. - ] ifFalse:[ - evReceiver dispatchEvent:event withFocusOn:focus delegate:true - ]. + evReceiver dispatchEvent:event withFocusOn:focus delegate:true ]. ]. - - "/ give eventRecorders, postProcessors - "/ a chance to see that event - self executePostEventHooksFor:event - ] - ]. + ]. + + "/ give eventRecorders, postProcessors + "/ a chance to see that event + self executePostEventHooksFor:event + ] ]. - ] + ] "end while". + ] on:LastEventQuerySignal do:[:ex | + ex proceedWith:event ] ensure:[ busyHookBlock notNil ifTrue:[ Processor removeTimedBlock:busyHookBlock. @@ -1883,8 +1872,9 @@ ]. ]. - "Created: / 5.3.1997 / 11:33:11 / cg" - "Modified: / 4.8.1998 / 18:18:55 / cg" + "Created: / 05-03-1997 / 11:33:11 / cg" + "Modified: / 04-08-1998 / 18:18:55 / cg" + "Modified: / 31-01-2017 / 16:48:45 / stefan" ! processExposeEvents @@ -1954,15 +1944,15 @@ This is required after a scroll operation, to wait for either a noExpose or a real expose." - |event view sensor thisProcess| + |sensor| (sensor := mySensor) isNil ifTrue:[^ self]. sensor damageCount == 0 ifTrue:[^ self]. - thisProcess := Processor activeProcess. - WindowGroupQuerySignal answer:self do:[ - [true] whileTrue:[ + |event view| + + [ "/ event := aView nextDamage. event := sensor nextExposeEventFor:someViewOrNil. event isNil ifTrue:[^ self]. @@ -1984,11 +1974,12 @@ self executePostEventHooksFor:event. ] ] - ] - ] - - "Created: / 2.7.1997 / 14:32:19 / cg" - "Modified: / 5.4.1998 / 11:35:43 / cg" + ] loop. + ]. + + "Created: / 02-07-1997 / 14:32:19 / cg" + "Modified: / 05-04-1998 / 11:35:43 / cg" + "Modified (format): / 31-01-2017 / 21:53:29 / stefan" ! repairDamage @@ -2905,15 +2896,14 @@ !WindowGroup::WindowGroupQuery class methodsFor:'redefined answering'! answer:something do:action - |retVal| - - [ + ^ [ WindowGroup flushCachedActiveGroup. - retVal := super answer:something do:action + super answer:something do:action ] ensure:[ WindowGroup flushCachedActiveGroup ]. - ^ retVal + + "Modified: / 31-01-2017 / 20:28:14 / stefan" ! ! !WindowGroup class methodsFor:'documentation'! diff -r 295325696e0d -r 46203abe7d57 WindowSensor.st --- a/WindowSensor.st Wed Feb 01 21:42:41 2017 +0000 +++ b/WindowSensor.st Wed Feb 01 22:17:58 2017 +0000 @@ -888,23 +888,23 @@ p := Processor activeProcess. wasBlocked := p blockInterrupts. + [ - Error handle:[:ex | - ('WindowSensor [Warning]: Error in eventQ handling ignored: ' , ex description) errorPrintCR. - "/ thisContext fullPrintAll. - "/ whichLock printCR. - ex return - ] do:[ - whichLock critical:aBlock - ] + whichLock critical:aBlock + ] on:Error do:[:ex| + ('WindowSensor [Warning]: Error in eventQ handling ignored: ' , ex description) errorPrintCR. + "/ thisContext fullPrintAll. + "/ whichLock printCR. + ex return. ] ensure:[ wasBlocked ifFalse:[ p unblockInterrupts. ] ] - "Created: / 6.6.1998 / 21:04:02 / cg" - "Modified: / 14.10.1998 / 17:17:05 / cg" + "Created: / 06-06-1998 / 21:04:02 / cg" + "Modified: / 14-10-1998 / 17:17:05 / cg" + "Modified: / 31-01-2017 / 16:53:08 / stefan" ! criticalUserEventQueueAccess:aBlock diff -r 295325696e0d -r 46203abe7d57 XftFontDescription.st --- a/XftFontDescription.st Wed Feb 01 21:42:41 2017 +0000 +++ b/XftFontDescription.st Wed Feb 01 22:17:58 2017 +0000 @@ -1,3 +1,15 @@ +" + COPYRIGHT (c) 2013 by Jan Vrany + COPYRIGHT (c) 2013 by eXept Software AG + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. +" "{ Package: 'stx:libview' }" "{ NameSpace: Smalltalk }" @@ -94,6 +106,22 @@ !XftFontDescription class methodsFor:'documentation'! +copyright +" + COPYRIGHT (c) 2013 by Jan Vrany + COPYRIGHT (c) 2013 by eXept Software AG + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. + +" +! + documentation " WARNING: Unfinished. diff -r 295325696e0d -r 46203abe7d57 abbrev.stc --- a/abbrev.stc Wed Feb 01 21:42:41 2017 +0000 +++ b/abbrev.stc Wed Feb 01 22:17:58 2017 +0000 @@ -83,4 +83,7 @@ PopUpView PopUpView stx:libview 'Views-Basic' 2 StandardSystemView StandardSystemView stx:libview 'Views-Basic' 2 ModalBox ModalBox stx:libview 'Views-Basic' 2 +ControllerWithMenu ControllerWithMenu stx:libview 'Interface-Support-Controllers' 0 +GraphicsAttributes GraphicsAttributes stx:libview 'Graphics-Support' 0 +NeXTWorkstation NeXTWorkstation stx:libview 'Interface-Graphics' 0 WinWorkstation WinWorkstation stx:libview 'unknownCategory' 0 diff -r 295325696e0d -r 46203abe7d57 bc.mak diff -r 295325696e0d -r 46203abe7d57 extensions.st --- a/extensions.st Wed Feb 01 21:42:41 2017 +0000 +++ b/extensions.st Wed Feb 01 22:17:58 2017 +0000 @@ -26,6 +26,12 @@ "Created: / 22-02-2016 / 08:08:38 / Jan Vrany " ! ! +!Object methodsFor:'testing'! + +isColormap + ^ false +! ! + !stx_libview class methodsFor:'documentation'! extensionsVersion_HG diff -r 295325696e0d -r 46203abe7d57 libInit.cc diff -r 295325696e0d -r 46203abe7d57 stx_libview.st --- a/stx_libview.st Wed Feb 01 21:42:41 2017 +0000 +++ b/stx_libview.st Wed Feb 01 22:17:58 2017 +0000 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " COPYRIGHT (c) Claus Gittinger / 2006 by eXept Software AG All Rights Reserved @@ -103,15 +105,17 @@ excludedFromPreRequisites ^ #( - #'stx:libcompat' "OrderedDither - referenced by Image>>convertToPalette:renderedBy: " - #'stx:libtool' "GenericToolbarIconLibrary - referenced by SimpleView class>>readStyleSheet " - #'stx:libtool2' "ImageEditor - referenced by Image>>edit " - #'stx:libui' "ViewSpec - referenced by SimpleView>>specClass " - #'stx:libview2' "TIFFReader - referenced by Image>>saveOn: " - #'stx:libwidg' "Button - referenced by ModalBox>>initialize " - #'stx:libwidg2' "ImageView - referenced by Form>>show " - #'stx:goodies/communication' "HTTPInterface - referenced by ImageReader class>>fromURL: " + #'stx:libcompat' "OrderedDither - referenced by Image>>convertToPalette:renderedBy: " + #'stx:libtool' "GenericToolbarIconLibrary - referenced by SimpleView class>>readStyleSheet " + #'stx:libtool2' "ImageEditor - referenced by Image>>edit " + #'stx:libui' "ViewSpec - referenced by SimpleView>>specClass " + #'stx:libview2' "TIFFReader - referenced by Image>>saveOn: " + #'stx:libwidg' "Button - referenced by ModalBox>>initialize " + #'stx:libwidg2' "ImageView - referenced by Form>>show " + #'stx:goodies/communication' "HTTPInterface - referenced by ImageReader class>>fromURL:" ) + + "Modified: / 31-01-2017 / 13:35:51 / stefan" ! mandatoryPreRequisites @@ -120,33 +124,37 @@ are extended by myself. They are mandatory, because we need these packages as a prerequisite for loading and compiling. This method is generated automatically, - by searching along the inheritance chain of all of my classes." + by searching along the inheritance chain of all of my classes. + Please take a look at the #referencedPreRequisites method as well." ^ #( - #'stx:libbasic' "Collection - superclass of ColorPalette" + #'stx:libbasic' "AllocationFailure - superclass of GraphicsDevice::GraphicResourceAllocationFailure" ) ! referencedPreRequisites "list packages which are a prerequisite, because they contain classes which are referenced by my classes. - We do not need these packages as a prerequisite for compiling or loading, + These packages are NOT needed as a prerequisite for compiling or loading, however, a class from it may be referenced during execution and having it unloaded then may lead to a runtime doesNotUnderstand error, unless the caller includes explicit checks for the package being present. This method is generated automatically, - by searching all classes (and their packages) which are referenced by my classes." + by searching all classes (and their packages) which are referenced by my classes. + Please also take a look at the #mandatoryPreRequisites method" ^ #( - #'stx:libbasic2' "BooleanArray - referenced by Image>>floodFillAt:withValue:" + #'stx:libbasic2' "UUID - referenced by DisplayRootView>>uuid" ) + + "Modified: / 31-01-2017 / 13:35:33 / stefan" ! subProjects "list packages which are known as subprojects. The generated makefile will enter those and make there as well. However: they are not forced to be loaded when a package is loaded; - for those, redefine requiredPrerequisites" + for those, redefine #referencedPrerequisites or #mandatoryPreRequisites." ^ #( ) @@ -479,16 +487,24 @@ PopUpView StandardSystemView ModalBox + (ControllerWithMenu autoload) + (GraphicsAttributes autoload) + (NeXTWorkstation autoload) (WinWorkstation win32) ) + + "Modified (format): / 31-01-2017 / 13:35:18 / stefan" ! extensionMethodNames "list class/selector pairs of extensions. - A correponding method with real names must be present in my concrete subclasses" + Entries are 2-element array literals, consisting of class-name and selector. + A correponding method with real names must be present in my concrete subclasses + if it has extensions." ^ #( 'ConfigurableFeatures class' hasFontConfig + Object isColormap 'ConfigurableFeatures class' hasXFT ) ! ! diff -r 295325696e0d -r 46203abe7d57 stx_libviewWINrc.rc --- a/stx_libviewWINrc.rc Wed Feb 01 21:42:41 2017 +0000 +++ b/stx_libviewWINrc.rc Wed Feb 01 22:17:58 2017 +0000 @@ -3,7 +3,7 @@ // automagically generated from the projectDefinition: stx_libview. // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,1,1,90 + FILEVERSION 7,1,1,93 PRODUCTVERSION 7,1,0,0 #if (__BORLANDC__) FILEFLAGSMASK VS_FF_DEBUG | VS_FF_PRERELEASE @@ -18,14 +18,14 @@ BEGIN BLOCK "040904E4" BEGIN - VALUE "CompanyName", "eXept Software AG\0" + VALUE "CompanyName", "Claus Gittinger / eXept Software AG\0" VALUE "FileDescription", "Smalltalk/X Low Level Graphic Interfacing (LIB)\0" - VALUE "FileVersion", "7.1.1.90\0" + VALUE "FileVersion", "7.1.1.93\0" VALUE "InternalName", "stx:libview\0" - VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2012\nCopyright eXept Software AG 2012\0" + VALUE "LegalCopyright", "Copyright Claus Gittinger 1988\nCopyright eXept Software AG 2012\0" VALUE "ProductName", "Smalltalk/X\0" VALUE "ProductVersion", "7.1.0.0\0" - VALUE "ProductDate", "Wed, 20 Jul 2016 10:51:07 GMT\0" + VALUE "ProductDate", "Tue, 31 Jan 2017 12:37:04 GMT\0" END END