--- a/Depth24Image.st Fri Feb 27 14:33:16 2015 +0100
+++ b/Depth24Image.st Fri Feb 27 14:48:04 2015 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
@@ -11,6 +13,8 @@
"
"{ Package: 'stx:libview' }"
+"{ NameSpace: Smalltalk }"
+
Image subclass:#Depth24Image
instanceVariableNames:''
classVariableNames:''
@@ -2681,7 +2685,8 @@
hardAntiAliasedMagnifiedBy:scalePoint
"return a new image magnified by scalePoint, aPoint.
- This interpolates pixels and is therefore slower."
+ This interpolates pixels and is therefore much slower,
+ but generates nicer looking magnifications."
|mX
mY
@@ -2705,24 +2710,24 @@
newBytesPerRow := ((newWidth * bitsPerPixel) + 7) // 8.
newBits := ByteArray new: "uninitializedNew:" (newBytesPerRow * newHeight).
newBits isNil ifTrue:[
- 'Depth24Image [warning]: failed to allocate byteArray for image bits' errorPrintCR.
- ^ nil
+ 'Depth24Image [warning]: failed to allocate byteArray for image bits' errorPrintCR.
+ ^ nil
].
mask notNil ifTrue:[
- newMask := (mask magnifiedBy:scalePoint)
+ newMask := (mask magnifiedBy:scalePoint)
].
newImage := self species new.
newImage
- width:newWidth
- height:newHeight
- photometric:photometric
- samplesPerPixel:samplesPerPixel
- bitsPerSample:bitsPerSample
- colorMap:colorMap copy
- bits:newBits
- mask:newMask.
+ width:newWidth
+ height:newHeight
+ photometric:photometric
+ samplesPerPixel:samplesPerPixel
+ bitsPerSample:bitsPerSample
+ colorMap:nil
+ bits:newBits
+ mask:newMask.
mY := mY asFloat.
mX := mX asFloat.
@@ -2741,86 +2746,86 @@
double _mY = __floatVal(mY);
for (_row = 0; _row <= _h; _row++) {
- double _srcY;
- double _dY;
- int _sR;
-
- _srcY = ((double)_row / _mY);
- _sR = (int)_srcY;
- _dY = _srcY - ((double)_sR);
- _srcRowP = _srcP + (_width3 * _sR);
-
- for (_col = 0; _col <= _w; _col++) {
- unsigned int rHere, gHere, bHere;
- unsigned int rRight, gRight, bRight;
- unsigned int rRightBelow, gRightBelow, bRightBelow;
- unsigned int rBelow, gBelow, bBelow;
- unsigned int _r, _g, _b;
- double wHere, wRight, wRightBelow, wBelow, sumW;
- double _srcX;
- double _dX;
- int _sC;
-
- _srcX = ((double)_col / _mX);
- _sC = (int)_srcX;
- _dX = _srcX - ((double)_sC);
- sP = _srcRowP + (_sC * 3);
-
- rHere = sP[0];
- gHere = sP[1];
- bHere = sP[2];
-
- if (_sC < _oldW) {
- rRight = sP[3];
- gRight = sP[4];
- bRight = sP[5];
-
- if (_sR < _oldH) {
- rBelow = sP[0+_width3];
- gBelow = sP[1+_width3];
- bBelow = sP[2+_width3];
- rRightBelow = sP[3+_width3];
- gRightBelow = sP[4+_width3];
- bRightBelow = sP[5+_width3];
- } else {
- rRightBelow = rHere;
- gRightBelow = gHere;
- bRightBelow = bHere;
- rBelow = rHere;
- gBelow = gHere;
- bBelow = bHere;
- }
- } else {
- rRight = rRightBelow = rHere;
- gRight = gRightBelow = gHere;
- bRight = bRightBelow = bHere;
- if (_sR < _oldH) {
- rBelow = sP[0+_width3];
- gBelow = sP[1+_width3];
- bBelow = sP[2+_width3];
- } else {
- rBelow = rHere;
- gBelow = gHere;
- bBelow = bHere;
- }
- }
-
- wHere = (1.0 - _dX) * (1.0 - _dY);
- wRight = _dX * (1.0 - _dY);
- wBelow = _dY * (1.0 - _dX);
- wRightBelow = _dX * _dY;
- sumW = wHere + wRight + wBelow + wRightBelow;
-
- _r = ((rHere * wHere) + (rRight * wRight) + (rBelow * wBelow) + (rRightBelow * wRightBelow)) / sumW;
- _g = ((gHere * wHere) + (gRight * wRight) + (gBelow * wBelow) + (gRightBelow * wRightBelow)) / sumW;
- _b = ((bHere * wHere) + (bRight * wRight) + (bBelow * wBelow) + (bRightBelow * wRightBelow)) / sumW;
-
- _dstP[0] = _r;
- _dstP[1] = _g;
- _dstP[2] = _b;
-
- _dstP += 3;
- }
+ double _srcY;
+ double _dY;
+ int _sR;
+
+ _srcY = ((double)_row / _mY);
+ _sR = (int)_srcY;
+ _dY = _srcY - ((double)_sR);
+ _srcRowP = _srcP + (_width3 * _sR);
+
+ for (_col = 0; _col <= _w; _col++) {
+ unsigned int rHere, gHere, bHere;
+ unsigned int rRight, gRight, bRight;
+ unsigned int rRightBelow, gRightBelow, bRightBelow;
+ unsigned int rBelow, gBelow, bBelow;
+ unsigned int _r, _g, _b;
+ double wHere, wRight, wRightBelow, wBelow, sumW;
+ double _srcX;
+ double _dX;
+ int _sC;
+
+ _srcX = ((double)_col / _mX);
+ _sC = (int)_srcX;
+ _dX = _srcX - ((double)_sC);
+ sP = _srcRowP + (_sC * 3);
+
+ rHere = sP[0];
+ gHere = sP[1];
+ bHere = sP[2];
+
+ if (_sC < _oldW) {
+ rRight = sP[3];
+ gRight = sP[4];
+ bRight = sP[5];
+
+ if (_sR < _oldH) {
+ rBelow = sP[0+_width3];
+ gBelow = sP[1+_width3];
+ bBelow = sP[2+_width3];
+ rRightBelow = sP[3+_width3];
+ gRightBelow = sP[4+_width3];
+ bRightBelow = sP[5+_width3];
+ } else {
+ rRightBelow = rHere;
+ gRightBelow = gHere;
+ bRightBelow = bHere;
+ rBelow = rHere;
+ gBelow = gHere;
+ bBelow = bHere;
+ }
+ } else {
+ rRight = rRightBelow = rHere;
+ gRight = gRightBelow = gHere;
+ bRight = bRightBelow = bHere;
+ if (_sR < _oldH) {
+ rBelow = sP[0+_width3];
+ gBelow = sP[1+_width3];
+ bBelow = sP[2+_width3];
+ } else {
+ rBelow = rHere;
+ gBelow = gHere;
+ bBelow = bHere;
+ }
+ }
+
+ wHere = (1.0 - _dX) * (1.0 - _dY);
+ wRight = _dX * (1.0 - _dY);
+ wBelow = _dY * (1.0 - _dX);
+ wRightBelow = _dX * _dY;
+ sumW = wHere + wRight + wBelow + wRightBelow;
+
+ _r = ((rHere * wHere) + (rRight * wRight) + (rBelow * wBelow) + (rRightBelow * wRightBelow)) / sumW;
+ _g = ((gHere * wHere) + (gRight * wRight) + (gBelow * wBelow) + (gRightBelow * wRightBelow)) / sumW;
+ _b = ((bHere * wHere) + (bRight * wRight) + (bBelow * wBelow) + (bRightBelow * wRightBelow)) / sumW;
+
+ _dstP[0] = _r;
+ _dstP[1] = _g;
+ _dstP[2] = _b;
+
+ _dstP += 3;
+ }
}
%}.
@@ -2834,8 +2839,8 @@
"
|i|
i := Depth24Image width:3 height:3 fromArray:#[ 0 0 0 0 0 0 0 0 0
- 0 0 0 255 255 255 0 0 0
- 0 0 0 0 0 0 0 0 0].
+ 0 0 0 255 255 255 0 0 0
+ 0 0 0 0 0 0 0 0 0].
i hardAntiAliasedMagnifiedBy:8@8
"
@@ -3114,10 +3119,10 @@
!Depth24Image class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.97 2014-03-02 13:59:49 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.98 2015-02-27 13:48:04 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.97 2014-03-02 13:59:49 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.98 2015-02-27 13:48:04 cg Exp $'
! !