Halftone effect in with gdi+

邮差的信 提交于 2019-12-22 08:34:43

问题


How would I go about mimicking this halftone effect in GDI+?

It almost looks like Floyd–Steinberg dithered version of the image overlaying a full one but I'm not convinced.


回答1:


I gave this a try and got this result:

It may be a place to start. I did it like this:

  1. Draw the original picture with low saturation (using a color matrix)
  2. Draw the original image onto 1) with high saturation using a pattern mask (ie the dots)

I created the pattern mask like this:

        using (var g = Graphics.FromImage(bmpPattern))
        {
            g.Clear(Color.Black);
            g.SmoothingMode = SmoothingMode.HighQuality;
            for (var y = 0; y < bmp.Height; y += 10)
                for (var x = 0; x < bmp.Width ; x += 6)
                {
                    g.FillEllipse(Brushes.White, x, y, 4, 4);
                    g.FillEllipse(Brushes.White, x + 3, y + 5, 4, 4);
                }
        }

And then I imposed it over the oversaturated bitmap using this technique.

Update: Elaboration on how the images got merged. Let's talk even a little more general and say that we want to combine two different colorized versions of the same image using a pattern mask, resulting in a new image - we could do it like this:

Create THREE new bitmaps, all with the same size as the original image. Call them bmpA, bmpB and bmpMask.

  • Draw one colored/effect version into bmpA
  • Draw the other colored/effect version into bmpB
  • Create the mask in bmpMask (black and white)
  • Push one of the R/G/B channels of bmpMask into the alpha channel of bmpB using the transferOneARGBChannelFromOneBitmapToAnother method.
  • Draw bmpB over bmpA (since bmpB now has transparent parts in it)
  • The result is now bmpA. bmpB and bmpMask can be disposed.

Done



来源:https://stackoverflow.com/questions/8882512/halftone-effect-in-with-gdi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!