Discussion:
Drawing a greyscale picture?
(too old to reply)
Mark O'Neill
2006-03-31 00:23:57 UTC
Permalink
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.
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.3/296 - Release Date: 29/03/2006


_______________________________________________
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>
support-9+jg12ILN6UkMvPuQOpXZQXbj/ (Christian Schmitz)
2006-03-31 00:38:17 UTC
Permalink
Post by Mark O'Neill
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?
One way is:

dim p as Picture

p=TintPictureMBS(bild1,&c808080,&c808080)

g.DrawPicture p,0,0

Of course you need to know good values for GrayBase and SepiaBase.

Another way is the PictureSepiaMBS class which has more options:

dim p as Picture
dim t as PictureSepiaMBS

t=new PictureSepiaMBS

t.SourcePicture=bild1

if t.run then
p=t.DestinationPicture

g.DrawPicture p,0,0
end if

(the more options are not used in this example)

Mfg
Christian
--
Around eleven thousand functions in one REALbasic plug-in.
The Monkeybread Software Realbasic Plugin.
<http://www.monkeybreadsoftware.de/realbasic/plugins.shtml>
_______________________________________________
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>
Mark O'Neill
2006-03-31 00:53:41 UTC
Permalink
Hi Christian,

| One way is:
|
| dim p as Picture
|
| p=TintPictureMBS(bild1,&c808080,&c808080)
|
| g.DrawPicture p,0,0
|
| Of course you need to know good values for GrayBase and SepiaBase.
|
| Another way is the PictureSepiaMBS class which has more options:
|
| dim p as Picture
| dim t as PictureSepiaMBS
|
| t=new PictureSepiaMBS
|
| t.SourcePicture=bild1
|
| if t.run then
| p=t.DestinationPicture
|
| g.DrawPicture p,0,0
| end if
|
| (the more options are not used in this example)

Thanks for your examples, but I'm a die-hard
"no plugins in my project" kinda guy. :)

I'm sure your plugins are absolutely gorgeous,
but I'd rather maintain all my code and not
rely on 3rd party plugins if possible.

As the old saying goes...

"Give a man a fish; you have fed him for today.
Teach a man to use the Net and he won't bother you
for weeks."

Or words to that effect. :)

Thanks anyway,

All the best,

Mark.
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.3/296 - Release Date: 29/03/2006


_______________________________________________
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>
dda
2006-03-31 01:32:43 UTC
Permalink
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
Post by Mark O'Neill
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.
Mark O'Neill
2006-03-31 01:42:23 UTC
Permalink
Hi DDA,

| 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.


Thank you. :)

All the best,

Mark.
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.3/296 - Release Date: 29/03/2006


_______________________________________________
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>
John Balestrieri
2006-03-31 04:17:40 UTC
Permalink
Or you can just take the .Value of the color (Assuming Rb also uses
the optically weighted conversion values, as dda uses -- which I
think it does, iirc.)

John Balestrieri
Tinrocket, LLC
Post by dda
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
_______________________________________________
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>

Continue reading on narkive:
Loading...