tags:

views:

190

answers:

3

I need to write an anaglyph images program. Let say I have two mono-color images: red color one and cyan color one. How can I combines them into one to make an anaglyph image?

Please give me an advice. Thank you.

P/s: I'm using C# program language.

+1  A: 

One approach is to use the ImageMagick composite utility to overlay the images. This method has no programming required.

Greg Hewgill
A: 

maybe set them at 50% alpha each then offset and copy them using a drawing surface

Jim
That won't handle the red/blue colouring that is needed.
DrStalker
+1  A: 

If the images are RGB, use a Darken blending mode. If they're CMYK, use a Lighten blending mode.

For darken, take the lower value (Math.Min()) of each channel. For lighten, take the higher one (Math.Max()).

//Darken pseudocode
for(int y=0;y<CompositionBitmap.Height;y++)
    for(int x=0;x<CompositionBitmap.Width;x++){
        CompositionBitmap[x,y].R=Math.Min(RedBitmap[x,y].R,CyanBitmap[x,y].R);
        CompositionBitmap[x,y].G=Math.Min(RedBitmap[x,y].G,CyanBitmap[x,y].G);
        CompositionBitmap[x,y].B=Math.Min(RedBitmap[x,y].B,CyanBitmap[x,y].B);
    }
}
pyrochild