1098 imageBits := ByteArray uninitializedNew:(width * height * 3). |
1098 imageBits := ByteArray uninitializedNew:(width * height * 3). |
1099 usedDevicePadding := 8. |
1099 usedDevicePadding := 8. |
1100 |
1100 |
1101 "/ now, walk over the image and compose 24bit values from the r/g/b triples |
1101 "/ now, walk over the image and compose 24bit values from the r/g/b triples |
1102 %{ |
1102 %{ |
|
1103 unsigned char *srcPtr = 0; |
|
1104 unsigned char *dstPtr = 0; |
|
1105 |
|
1106 if (__isByteArray(__INST(bytes))) { |
|
1107 srcPtr = _ByteArrayInstPtr(__INST(bytes))->ba_element; |
|
1108 } else { |
|
1109 if (__isExternalBytes(__INST(bytes))) { |
|
1110 srcPtr = __externalBytesAddress(__INST(bytes)); |
|
1111 } |
|
1112 } |
|
1113 if (__isByteArray(imageBits)) { |
|
1114 dstPtr = _ByteArrayInstPtr(imageBits)->ba_element; |
|
1115 } else { |
|
1116 if (__isExternalBytes(imageBits)) { |
|
1117 dstPtr = __externalBytesAddress(imageBits); |
|
1118 } |
|
1119 } |
|
1120 |
1103 if (__bothSmallInteger(_INST(height), _INST(width)) |
1121 if (__bothSmallInteger(_INST(height), _INST(width)) |
1104 && __bothSmallInteger(rightShiftR, shiftRed) |
1122 && __bothSmallInteger(rightShiftR, shiftRed) |
1105 && __bothSmallInteger(rightShiftG, shiftGreen) |
1123 && __bothSmallInteger(rightShiftG, shiftGreen) |
1106 && __bothSmallInteger(rightShiftB, shiftBlue) |
1124 && __bothSmallInteger(rightShiftB, shiftBlue) |
1107 && __isByteArray(_INST(bytes)) |
1125 && srcPtr |
1108 && __isByteArray(imageBits)) { |
1126 && dstPtr) { |
1109 int rShRed = __intVal(rightShiftR), |
1127 int rShRed = __intVal(rightShiftR), |
1110 rShGreen = __intVal(rightShiftG), |
1128 rShGreen = __intVal(rightShiftG), |
1111 rShBlue = __intVal(rightShiftB), |
1129 rShBlue = __intVal(rightShiftB), |
1112 lShRed = __intVal(shiftRed), |
1130 lShRed = __intVal(shiftRed), |
1113 lShGreen = __intVal(shiftGreen), |
1131 lShGreen = __intVal(shiftGreen), |
1114 lShBlue = __intVal(shiftBlue); |
1132 lShBlue = __intVal(shiftBlue); |
1115 int x, y, w; |
1133 int x, y, w; |
1116 |
|
1117 unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element; |
|
1118 unsigned char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element; |
|
1119 |
1134 |
1120 w = __intVal(_INST(width)); |
1135 w = __intVal(_INST(width)); |
1121 if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) { |
1136 if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) { |
1122 for (y=__intVal(_INST(height)); y > 0; y--) { |
1137 for (y=__intVal(_INST(height)); y > 0; y--) { |
1123 for (x=w; x > 0; x--) { |
1138 for (x=w; x > 0; x--) { |