realbasic-nug
[Top] [All Lists]

Re: Drawing a greyscale picture?

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Drawing a greyscale picture?
From: dda <headspin at gmail dot com>
Date: Fri, 31 Mar 2006 03:32:43 +0200
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=MEkjoQTEU5ibgPDDBE9WMls6q8gA7NUc3Nrr8yy2oCq9ov2edYpurlqsFKyOcg6HA8Gou2y6QRejk/YNSlHlwjR4NpdqnJBzfxF0XpjZOmcVRSNsp5kQrtl6r+jdRuh6gg++gNxC9Az4a+o3KdP/P6C5TiYmZR9lqND8XdFa4u8=
References: <20060331002358 dot 8436B11ABC54 at lists dot realsoftware dot com>
Draw it into a Picture object, and loop over its RGBSurface doing:
      c=rs.Pixel(n,j)
      k=(C.Red * 0.275) + (C.Green * 0.58) + (C.Blue * 0.145)
      rs.Pixel(n,j)=rgb(k,k,k)
you could also just average out the three colours, ie
      k=(c.red+c.green+c.blue)\3
but I found that the one above produced better results. My ImageTools
library [plain RB] does that and much more.

HTH

--
dda
ImageTools, pure RB fast graphics
http://sungnyemun.org/?q=node/3

RBDeveloper Columnist, "Beyond the Limits"
http://rbdeveloper.com

On 3/31/06, Mark O'Neill <mark at cutto dot co dot uk> wrote:
> Hi All,
>
> I'm not too hot at graphics, so please
> excuse me if this is a simple question,
> but how would I go about drawing a
> picture (which is a color JPG) as
> greyscale on a canvas?
>
> Thanks for your help.
>
> All the best,
>
> Mark.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
<Prev in Thread] Current Thread [Next in Thread>