At 10:35 Uhr +0200 03.07.2002, Martijn wrote:
>Hi,
>I'd like to convert a rgb bitmap to greyscale with lingo. How can it be
>done?
>I suppose I can use imaging lingo to adjust the (R,G,B).
>will this work?:
>
>repeat with something to something else -- scan whole image...
> myPixel = imageToConvert.getPixel(x,y)
> tempValue = (myPixel.color.red + myPixel.color.green + myPixel.color.blue)
>/ 3
> myPixel.color.red = tempValue
> myPixel.color.green = tempValue
> myPixel.color.blue = tempValue
>end repeat
>
>
>Syntax may be off a little, but will it work by just take the average of R,
>G and B. Then assign the average value to the three channels?
>
I think it is to slow to change every single pixel, since
get/setPixel are slow operations.
you can convert the whole image to #grayscale palette instead with
the following handler. (also the quality will be a little bit
inferior)
on convertImageToGrayscale imgObj
returnImg = image(imgObj.width, imgObj.height, 8, 0, #grayscale)
returnImg.copyPixels(imgObj, imgObj.rect, imgObj.rect, [#dither:1969])
return returnImg
end
grayscaleImage = convertImageToGrayscale (member("x").image)
--
|||
a�ex
--
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]