* [9fans] color compositing
@ 2004-09-14 23:52 andrey mirtchovski
2004-09-15 1:19 ` Russ Cox
0 siblings, 1 reply; 3+ messages in thread
From: andrey mirtchovski @ 2004-09-14 23:52 UTC (permalink / raw)
To: 9fans
i'm in a pickle here trying to find out how to use duff/porter's alpha
channels properly. here's the situation:
- there is an image with background color which should be
transparent
- this image, sans the background color, should go onto
another image
the problem is that i'm not able to extract the non-background color
from the image. obviously the easiest soution would be to use a mask
for anything that non-background, so the first thing i tried was to
use the image as a mask on a 'draw everything in white on black
background'. the problem i ran into was that if i use a low-bit
channel (GRAY1) i only see the parts of the image which were bright
enough originally, if i use a higher-bit channel i get variations of
grey causing everything drawn afterwards to appear black'n'white...
then i tried several of the duff/porter compositing operators with
absolutely no effect whatsoever.
in my desperation i even tried creating an image with the alpha for
the particular color set to zero, but it proved fruitless.
to summarize: how can i remove a certain color from an image
programmatically?
andrey
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9fans] color compositing
2004-09-14 23:52 [9fans] color compositing andrey mirtchovski
@ 2004-09-15 1:19 ` Russ Cox
2004-09-15 1:24 ` andrey mirtchovski
0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2004-09-15 1:19 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> to summarize: how can i remove a certain color from an image
> programmatically?
first make the "image with background color which should
be transparent" into an "image with transparent background":
read it into a Memimage of (say) RGBA32,
then loop over the pixels looking for your particular
color and replacing them with 0,0,0,0. (actual transparent
pixels.)
then you can
draw(dst, dst->r, bottom, nil, ZP);
draw(dst, dst->r, image, nil, ZP);
and voila! you have your image.
russ
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9fans] color compositing
2004-09-15 1:19 ` Russ Cox
@ 2004-09-15 1:24 ` andrey mirtchovski
0 siblings, 0 replies; 3+ messages in thread
From: andrey mirtchovski @ 2004-09-15 1:24 UTC (permalink / raw)
To: 9fans
thanks, that's how i'll do it (chris hollis-locke suggested the same
privately). i wanted to see whether there's a way of doing it without
preprocessing, but i guess not.
andrey
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-09-15 1:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-14 23:52 [9fans] color compositing andrey mirtchovski
2004-09-15 1:19 ` Russ Cox
2004-09-15 1:24 ` andrey mirtchovski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).