--- a/Depth24Image.st Wed Sep 07 06:48:09 2016 +0200
+++ b/Depth24Image.st Thu Sep 08 06:46:34 2016 +0200
@@ -79,15 +79,11 @@
Pixels start at x=0 , y=0 for upper left pixel,
end at x = width-1, y=height-1 for lower right pixel"
- |index "{ Class: SmallInteger }"
- rVal gVal bVal|
-
- index := 1 + (((width * y) + x) * 3).
+ |rgbVal|
+
photometric == #rgb ifTrue:[
- rVal := bytes at:(index).
- gVal := bytes at:(index + 1).
- bVal := bytes at:(index + 2).
- ^ Color redByte:rVal greenByte:gVal blueByte:bVal
+ rgbVal := self pixelAtX:x y:y.
+ ^ Color rgbValue:rgbVal.
].
"/ the inherited method should handle all cases.
^ super colorAtX:x y:y.
@@ -98,14 +94,8 @@
Pixels start at x=0 , y=0 for upper left pixel, end at
x = width-1, y=height-1 for lower right pixel."
- |index "{ Class: SmallInteger }"|
-
photometric ~~ #rgb ifTrue:[^ super colorAtX:x y:y put:aColor].
-
- index := 1 + (((width * y) + x) * 3).
- bytes at:(index) put:(aColor redByte).
- bytes at:(index + 1) put:(aColor greenByte).
- bytes at:(index + 2) put:(aColor blueByte).
+ self pixelAtX:x y:y put:aColor rgbValue.
"Created: 24.4.1997 / 17:32:59 / cg"
!
@@ -2722,59 +2712,59 @@
&& (__BlockInstPtr(aBlock)->b_nargs == __mkSmallInteger(3))
&& ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil)
) {
- int c_x1 = __intVal(x1);
- int c_x2 = __intVal(x2);
- int c_y1 = __intVal(y1);
- int c_y2 = __intVal(y2);
- int c_w = __intVal(__INST(width));
- int c_h = __intVal(__INST(height));
- int c_srcIndex = __intVal(srcIndex);
- int c_bytesPerRow = __intVal(bytesPerRow);
- int c_y, c_x;
- OBJ c_rHome;
-
- c_rHome = __BlockInstPtr(aBlock)->b_home;
- if ((c_rHome == nil) || (__qSpace(c_rHome) >= STACKSPACE)) {
- if ((((unsigned)c_y1) < c_h)
- && (((unsigned)c_y2) < c_h)
- && (((unsigned)c_x1) < c_w)
- && (((unsigned)c_x2) < c_w)) {
- unsigned char *c_bytes = (unsigned char*)__ByteArrayInstPtr(bytes)->ba_element;
-
- if ((c_srcIndex + (c_bytesPerRow * (c_y2-c_y1))) < __byteArraySize(bytes)) {
- c_bytes += c_srcIndex;
- for (c_y=c_y1; c_y<=c_y2; c_y++) {
- unsigned char *c_next = c_bytes + c_bytesPerRow;
-
- for (c_x=c_x1; c_x<=c_x2; c_x++) {
- int c_value;
-
- c_value = c_bytes[0];
- c_value = (c_value<<8) | c_bytes[1];
- c_value = (c_value<<8) | c_bytes[2];
- (*(__BlockInstPtr(aBlock)->b_code))(c_rHome, __mkSmallInteger(c_x), __mkSmallInteger(c_y), __mkSmallInteger(c_value));
- c_bytes += 3;
- }
- c_bytes = c_next;
- }
- RETURN(self);
- }
- }
- }
+ int c_x1 = __intVal(x1);
+ int c_x2 = __intVal(x2);
+ int c_y1 = __intVal(y1);
+ int c_y2 = __intVal(y2);
+ int c_w = __intVal(__INST(width));
+ int c_h = __intVal(__INST(height));
+ int c_srcIndex = __intVal(srcIndex)-1;
+ int c_bytesPerRow = __intVal(bytesPerRow);
+ int c_y, c_x;
+ OBJ c_rHome;
+
+ c_rHome = __BlockInstPtr(aBlock)->b_home;
+ if ((c_rHome == nil) || (__qSpace(c_rHome) >= STACKSPACE)) {
+ if ((((unsigned)c_y1) < c_h)
+ && (((unsigned)c_y2) < c_h)
+ && (((unsigned)c_x1) < c_w)
+ && (((unsigned)c_x2) < c_w)) {
+ unsigned char *c_bytes = (unsigned char*)__ByteArrayInstPtr(bytes)->ba_element;
+
+ if ((c_srcIndex + (c_bytesPerRow * (c_y2-c_y1))) < __byteArraySize(bytes)) {
+ c_bytes += c_srcIndex;
+ for (c_y=c_y1; c_y<=c_y2; c_y++) {
+ unsigned char *c_next = c_bytes + c_bytesPerRow;
+
+ for (c_x=c_x1; c_x<=c_x2; c_x++) {
+ int c_value;
+
+ c_value = c_bytes[0];
+ c_value = (c_value<<8) | c_bytes[1];
+ c_value = (c_value<<8) | c_bytes[2];
+ (*(__BlockInstPtr(aBlock)->b_code))(c_rHome, __mkSmallInteger(c_x), __mkSmallInteger(c_y), __mkSmallInteger(c_value));
+ c_bytes += 3;
+ }
+ c_bytes = c_next;
+ }
+ RETURN(self);
+ }
+ }
+ }
}
%}.
y1 to:y2 do:[:y |
- srcNext := srcIndex + bytesPerRow.
- x1 to:x2 do:[:x |
- value := bytes at:srcIndex.
- value := (value bitShift:8) + (bytes at:srcIndex+1).
- value := (value bitShift:8) + (bytes at:srcIndex+2).
- srcIndex := srcIndex + 3.
-
- aBlock value:x value:y value:value
- ].
- srcIndex := srcNext.
+ srcNext := srcIndex + bytesPerRow.
+ x1 to:x2 do:[:x |
+ value := bytes at:srcIndex.
+ value := (value bitShift:8) + (bytes at:srcIndex+1).
+ value := (value bitShift:8) + (bytes at:srcIndex+2).
+ srcIndex := srcIndex + 3.
+
+ aBlock value:x value:y value:value
+ ].
+ srcIndex := srcNext.
].
"Modified: 11.7.1996 / 20:06:47 / cg"
@@ -3418,3 +3408,4 @@
version_CVS
^ '$Header$'
! !
+
--- a/Image.st Wed Sep 07 06:48:09 2016 +0200
+++ b/Image.st Thu Sep 08 06:46:34 2016 +0200
@@ -12598,7 +12598,7 @@
copyFrom:anImage x:srcX y:srcY toX:dstX y:dstY width:w height:h
"replace a rectangular area by pixels from another image.
- The sources colors must be present in the destinations
+ The source's colors must be present in the destination's
colorMap - otherwise, an error will be reported.
Any mask is copied from the source.
@@ -12658,9 +12658,9 @@
"
|i1 i8 i4|
- i8 := Image fromFile:'goodies/bitmaps/gifImages/garfield.gif'.
+ i8 := Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif'.
i8 inspect.
- i1 := Image fromFile:'libtool/bitmaps/SBrowser.xbm'.
+ i1 := Image fromFile:'../../libtool/bitmaps/SBrowser.xbm'.
i1 inspect.
i4 := Depth4Image fromImage:i8.
@@ -12764,6 +12764,13 @@
i inspect.
(i subImageIn:(300@160 corner:340@200)) inspect
"
+ "
+ |i|
+
+ i := Image fromFile:'/Volumes/tmp/fillimage.ok.png'.
+ i inspect.
+ (i subImageIn:(0@0 corner:i width@i height)) inspect
+ "
"Created: 20.9.1995 / 01:24:20 / claus"
! !