On 4 Jul 2006, at 16:06, Chris Carroll-Davis wrote:

Hello again.

Well, I've made some progress! I can now stick an image on a card and use that image to make an alpha channel for a second image. Hurrah. Trouble is it is S--L--O--W! It takes over 10 seconds to process a tiny 50-pixel square image!!! The utility I'm making needs to export about 3000 - much larger - graphics!

The problem is that ImageData uses 4 bytes per pixel (even if it is a 8-bit greyscale image) but AlphaData only uses 1 byte per pixel, so I have to strip the data out in a repeat loop that is huge; even for moderately sized graphics! I started with a 300 x 300 graphic, but of course for AlphaData that is 300x300 bytes = 90,000 repeats. Yuk! There must be a better way

Is there any lightning fast way of manipulating the binary data without resorting to a repeat loop?


I'm not sure what calculations you are doing in the loop, but it sounds too slow. The following routine creates alphaData from a 300 x 300 grayscale image in less than a second on my not so fast machine. (You'll probably need to substitute the calculation inside the loop with your own.)

I'm sure others will step up with faster alternatives. :-)


on mouseUp

  put the imageData of image 1 into tImageData
  put the milliseconds into tStart ## for speed calc
  put 0 into tCount
  repeat for each char tChar in tImageData
    add 1 to tCount
    if tCount = 4 then
      put numToChar(255 - charToNum(tChar)) after tMaskData
      put 0 into tCount
    end if
  end repeat
  put the milliseconds - tStart && length(tMaskData) ##speed score
  set the alphaData of image 1 to tMaskData
end mouseUp

Cheers
Dave
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to