Hi Martijn,

> 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?:
>
(... getPixel code...)
>
> 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?

Using the get/stpixel methods for a whole image will be slooooOOOwww!

here comes a little routine that should fit your needs:

on ConvertToGrayscale (iSrcImage) ------------------------------------
  -- INPUT : iSrcImage <#image> : the image object you want to convert
  -- OUTPUT: <#image> or VOID (if iSrcImage is not an image object)
  -------

  -- 1 - check input
  if (ilk(iSrcImage) <> #image) then return VOID

  rImgRect = iSrcImage.rect
  iBuffer  = image(rImgRect.width, rImgRect.height, 8, #grayScale)
  iBuffer.copyPixels(iSrcImage, rImgRect, rImgRect)

  return iBuffer
end -- ConvertToGrayscale handler

-- sample use:
-- mSrcMember  = member(1)
-- mGrayMember = new(#bitmap)
-- mGrayMember.image = ConvertToGrayscale(mSrcMember.image)

hth,
.s�b

[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!]

Reply via email to