Depth8Image.st
changeset 2248 20fc22184ef5
parent 2202 03d4cf38f4a5
child 2295 f3c1f14ba32f
equal deleted inserted replaced
2247:50650fdc8c72 2248:20fc22184ef5
  1326      value    "{ Class: SmallInteger }"
  1326      value    "{ Class: SmallInteger }"
  1327      x1       "{ Class: SmallInteger }"
  1327      x1       "{ Class: SmallInteger }"
  1328      x2       "{ Class: SmallInteger }"
  1328      x2       "{ Class: SmallInteger }"
  1329      y1       "{ Class: SmallInteger }"
  1329      y1       "{ Class: SmallInteger }"
  1330      y2       "{ Class: SmallInteger }"
  1330      y2       "{ Class: SmallInteger }"
  1331      colorArray|
  1331      colorArray
       
  1332      maxColor|
  1332 
  1333 
  1333     x1 := xStart.
  1334     x1 := xStart.
  1334     x2 := xEnd.
  1335     x2 := xEnd.
  1335     y1 := yStart.
  1336     y1 := yStart.
  1336     y2 := yEnd.
  1337     y2 := yEnd.
  1337 
  1338 
  1338     srcIndex := (width * y1) + x1 + 1 .
  1339     srcIndex := (width * y1) + x1 + 1 .
  1339     bytesPerRow := self bytesPerRow.
  1340     bytesPerRow := self bytesPerRow.
  1340 
  1341 
  1341     colorArray := self realColorMap.
  1342     colorArray := self realColorMap.
       
  1343     maxColor := colorArray size.
  1342 
  1344 
  1343     y1 to:y2 do:[:y |
  1345     y1 to:y2 do:[:y |
  1344         srcNext := srcIndex + bytesPerRow.
  1346         srcNext := srcIndex + bytesPerRow.
  1345         x1 to:x2 do:[:x |
  1347         x1 to:x2 do:[:x |
  1346             value := bytes at:srcIndex.
  1348             value := bytes at:srcIndex.
  1347             srcIndex := srcIndex + 1.
  1349             srcIndex := srcIndex + 1.
  1348 
  1350 
       
  1351             value >= maxColor ifTrue:[
       
  1352                 value := 0.
       
  1353             ].
  1349             aBlock value:x value:y value:(colorArray at:value+1)
  1354             aBlock value:x value:y value:(colorArray at:value+1)
  1350         ].
  1355         ].
  1351         srcIndex := srcNext.
  1356         srcIndex := srcNext.
  1352     ].
  1357     ].
  1353     ^ self
  1358     ^ self
  1354 
  1359 
  1355     "Created: 7.6.1996 / 19:12:35 / cg"
  1360     "Created: / 7.6.1996 / 19:12:35 / cg"
  1356     "Modified: 11.7.1996 / 20:20:55 / cg"
  1361     "Modified: / 17.8.1998 / 10:17:45 / cg"
  1357 !
  1362 !
  1358 
  1363 
  1359 valuesAtY:y from:xLow to:xHigh do:aBlock
  1364 valuesAtY:y from:xLow to:xHigh do:aBlock
  1360     "perform aBlock for each pixelValue from x1 to x2 in row y.
  1365     "perform aBlock for each pixelValue from x1 to x2 in row y.
  1361      The block is passed the pixelValue at each pixel.
  1366      The block is passed the pixelValue at each pixel.
  1862 ! !
  1867 ! !
  1863 
  1868 
  1864 !Depth8Image class methodsFor:'documentation'!
  1869 !Depth8Image class methodsFor:'documentation'!
  1865 
  1870 
  1866 version
  1871 version
  1867     ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.84 1998-07-29 11:17:25 cg Exp $'
  1872     ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.85 1998-08-17 08:18:15 cg Exp $'
  1868 ! !
  1873 ! !