While trying to speed my code up I've ran into a snag. My question is with /drawfill -s(Surface Fill), it should go through the entire bitmap in the @win and replace <color2> with <color1> correct?

If so why isn't this working:
Code:
;@GreyScale::Buffer is already created and the %p image is already drawn into it

;Prepare variables for looping
var %w = $pic(%p).width
var %h = $Pic(%p).height
var %y = 0
var %x
var %dot
var %rdot

;Start at the top of the image and work down:
while (%y < %h) {
  %x = 0

  ;move from left to right
  while (%x < %w) {

    ;get the current dots RGB value in the format of "RRR+GGG+BBB"
    %dot = $getdot(@GreyScale::Buffer,%x,%y)
    %rdot = $replace($rgb(%dot),$chr(44),+)

    ;Check to make sure the color isn't already a shade of grey
    if (!$regex(%rdot,/^(\d+)\+\1\+\1$/)) {

      ;get the average of the R,G,B Values (R + G + B)/3
      %n = $calc( ( %rdot )/ 3)


      ;Replace the current dot's color with the ave'ed rgb's
      ;why isn't this working:
      drawfill -s @GreyScale::Buffer $rgb(%n,%n,%n) %dot %x %y


      ;This works but is slow:
      ;drawdot -nr @GreyScale::Buffer $rgb(%n,%n,%n) 1 %x %y


    }
    ;drawdot @GreyScale::Buffer
    inc %x
  }
  inc %y
}


I removed some things to get to the heart of my problem for this post. If something doesn't seem right then it's probably my editing for here and will correct it here when spotted.


Oh and am using v7.17 on 32bit XPsp3

Last edited by FroggieDaFrog; 10/01/11 01:11 PM.