Depth24Image.st
changeset 8121 e9b681715859
parent 8098 489f84d2fc13
child 8127 826558a642a9
equal deleted inserted replaced
8120:f7f0d04eda06 8121:e9b681715859
   180     val := val bitShift:-8.
   180     val := val bitShift:-8.
   181     bytes at:(index) put:val.
   181     bytes at:(index) put:val.
   182 !
   182 !
   183 
   183 
   184 rgbValueAtX:x y:y
   184 rgbValueAtX:x y:y
   185     "retrieve a pixels rgb value at x/y; return a 24bit rgbValue (rrggbb, red is MSB).
   185     "retrieve a pixel's rgb value at x/y; 
   186      Pixels start at 0@0 for upper left pixel, end at (width-1)@(height-1) for lower right pixel."
   186      return a 24bit rgbValue (rrggbb, red is MSB).
       
   187      Pixels start at 0@0 for the upper left pixel, 
       
   188      and end at (width-1)@(height-1) for the lower right pixel."
   187 
   189 
   188     ^ self pixelAtX:x y:y.
   190     ^ self pixelAtX:x y:y.
       
   191 
       
   192     "Modified (comment): / 29-08-2017 / 14:35:01 / cg"
   189 !
   193 !
   190 
   194 
   191 rowAt:y putAll:pixelArray startingAt:startIndex
   195 rowAt:y putAll:pixelArray startingAt:startIndex
   192     "store a single rows bits from bits in the pixelArray argument;
   196     "store a single rows bits from bits in the pixelArray argument;
   193      Return the pixelArray.
   197      Return the pixelArray.
  2637     "Created: / 7.6.1996 / 19:12:28 / cg"
  2641     "Created: / 7.6.1996 / 19:12:28 / cg"
  2638     "Modified: / 27.7.1998 / 20:03:02 / cg"
  2642     "Modified: / 27.7.1998 / 20:03:02 / cg"
  2639 !
  2643 !
  2640 
  2644 
  2641 valuesAtY:y from:xLow to:xHigh do:aBlock
  2645 valuesAtY:y from:xLow to:xHigh do:aBlock
  2642     "perform aBlock for each pixelValue from x1 to x2 in row y.
  2646     "WARNING: this enumerates pixel values which need photometric interpretation
       
  2647      Do not confuse with #rgbValuesAtY:from:to:do:
       
  2648 
       
  2649      Perform aBlock for each pixelValue from x1 to x2 in row y.
       
  2650 
       
  2651      Notice the difference between rgbValue and pixelValue: rgbValues are always
       
  2652      the rgb bytes; pixelvalues depend on the photometric interpretation, and may be
       
  2653      indices into a colormap or be non-byte-sized rgb values.
       
  2654 
  2643      The block is passed the pixelValue at each pixel.
  2655      The block is passed the pixelValue at each pixel.
  2644      This method allows slighly faster processing of an
  2656      This method allows slighly faster processing of an
  2645      image than using valueAtX:y:, since some processing can be
  2657      image than using valueAtX:y:, since some processing can be
  2646      avoided when going from pixel to pixel. However, for
  2658      avoided when going from pixel to pixel. However, for
  2647      real image processing, specialized methods should be written.
  2659      real image processing, specialized methods should be written.
  2662     x2 := xHigh.
  2674     x2 := xHigh.
  2663 
  2675 
  2664     srcIndex := 1 + (((width * y) + x1) * 3).
  2676     srcIndex := 1 + (((width * y) + x1) * 3).
  2665 
  2677 
  2666     x1 to:x2 do:[:x |
  2678     x1 to:x2 do:[:x |
  2667 	r := bytes at:(srcIndex).
  2679         r := bytes at:(srcIndex).
  2668 	g := bytes at:(srcIndex + 1).
  2680         g := bytes at:(srcIndex + 1).
  2669 	b := bytes at:(srcIndex + 2).
  2681         b := bytes at:(srcIndex + 2).
  2670 	srcIndex := srcIndex + 3.
  2682         srcIndex := srcIndex + 3.
  2671 	aBlock value:x value:(((r bitShift:16) bitOr:(g bitShift:8)) bitOr:b)
  2683         aBlock value:x value:(((r bitShift:16) bitOr:(g bitShift:8)) bitOr:b)
  2672     ]
  2684     ]
  2673 
  2685 
  2674     "Created: 7.6.1996 / 19:09:40 / cg"
  2686     "Created: / 07-06-1996 / 19:09:40 / cg"
       
  2687     "Modified (comment): / 29-08-2017 / 14:53:14 / cg"
  2675 !
  2688 !
  2676 
  2689 
  2677 valuesFromX:xStart y:yStart toX:xEnd y:yEnd do:aBlock
  2690 valuesFromX:xStart y:yStart toX:xEnd y:yEnd do:aBlock
  2678     "perform aBlock for each pixel in the rectangle
  2691     "WARNING: this enumerates pixel values which need photometric interpretation
  2679      yStart..yEnd / xStart..xEnd.
  2692      Do not confuse with #rgbValuesAtY:from:to:do:
       
  2693 
       
  2694      Perform aBlock for each pixelValue in a rectangular area of the image.
       
  2695 
       
  2696      Notice the difference between rgbValue and pixelValue: rgbValues are always
       
  2697      the rgb bytes; pixelvalues depend on the photometric interpretation, and may be
       
  2698      indices into a colormap or be non-byte-sized rgb values.
       
  2699 
  2680      The block is passed the pixelValue at each pixel.
  2700      The block is passed the pixelValue at each pixel.
  2681      This method allows slighly faster processing of an
  2701      This method allows slighly faster processing of an
  2682      image than using individual valueAtX:y: accesses,
  2702      image than using individual valueAtX:y: accesses,
  2683      since some processing can be avoided when going from pixel to pixel..
  2703      since some processing can be avoided when going from pixel to pixel..
  2684      However, for real high performance image  processing, specialized methods
  2704      However, for real high performance image  processing, specialized methods
  2766             aBlock value:x value:y value:value
  2786             aBlock value:x value:y value:value
  2767         ].
  2787         ].
  2768         srcIndex := srcNext.
  2788         srcIndex := srcNext.
  2769     ].
  2789     ].
  2770 
  2790 
  2771     "Modified: 11.7.1996 / 20:06:47 / cg"
  2791     "Created: / 11-07-1996 / 20:08:11 / cg"
  2772     "Created: 11.7.1996 / 20:08:11 / cg"
  2792     "Modified (comment): / 29-08-2017 / 14:45:54 / cg"
  2773 ! !
  2793 ! !
  2774 
  2794 
  2775 !Depth24Image methodsFor:'image manipulations'!
  2795 !Depth24Image methodsFor:'image manipulations'!
  2776 
  2796 
  2777 easyRotateBitsInto:destinationImage angle:degrees
  2797 easyRotateBitsInto:destinationImage angle:degrees