Example #1
0
        static void Main(string[] args)
        {
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
                        #if DEBUG
            Trace.Listeners.Add(new ConsoleTraceListener());
                        #endif

            if (!ProcessArgs(args) || !ValidateArgs())
            {
                return;
            }

            var inpmap = Bitmap.FromFile(InputImage) as Bitmap;
            var outmap = new Bitmap(inpmap.Width, inpmap.Height, PixelFormat.Format32bppArgb);

            using (InputBitmap = new LockBitmap(inpmap))
                using (OutputBitmap = new LockBitmap(outmap))
                {
                    InputBitmap.LockBits();
                    OutputBitmap.LockBits();
                    RenderZoom(inpmap);
                }

            outmap.Save(OutputImage);
        }
Example #2
0
        static Color GetExtendedPixel(LockBitmap b, int x, int y)
        {
            int w = b.Width - 1;
            int h = b.Height - 1;
            int bx, by;

            if (y < 0)
            {
                by = 0;
            }
            else if (y > h)
            {
                by = h;
            }
            else
            {
                by = y;
            }

            if (x < 0)
            {
                bx = 0;
            }
            else if (x > w)
            {
                bx = h;
            }
            else
            {
                bx = x;
            }

            return(b.GetPixel(bx, by));
        }
Example #3
0
        static Color GetAliasedColor(LockBitmap lb, int x, int y)
        {
            Color
                c00 = GetExtendedPixel(lb, x - 1, y - 1)
            , c01   = GetExtendedPixel(lb, x + 0, y - 1)
            , c02   = GetExtendedPixel(lb, x + 1, y - 1)
            , c10   = GetExtendedPixel(lb, x - 1, y + 0)
            , c11   = GetExtendedPixel(lb, x + 0, y + 0)
            , c12   = GetExtendedPixel(lb, x + 1, y + 0)
            , c20   = GetExtendedPixel(lb, x - 1, y + 1)
            , c21   = GetExtendedPixel(lb, x + 0, y + 1)
            , c22   = GetExtendedPixel(lb, x + 1, y + 1)
            ;

                        #if !MEMOIZE
            double d1 = 1.0 / 16.0;
            double d2 = 2.0 / 16.0;
            double d4 = 4.0 / 16.0;

            double a =
                d1 * c00.A + d2 * c01.A + d1 * c02.A
                + d2 * c10.A + d4 * c11.A + d2 * c12.A
                + d1 * c20.A + d2 * c21.A + d1 * c22.A
            ;
            double r =
                d1 * c00.R + d2 * c01.R + d1 * c02.R
                + d2 * c10.R + d4 * c11.R + d2 * c12.R
                + d1 * c20.R + d2 * c21.R + d1 * c22.R
            ;
            double g =
                d1 * c00.G + d2 * c01.G + d1 * c02.G
                + d2 * c10.G + d4 * c11.G + d2 * c12.G
                + d1 * c20.G + d2 * c21.G + d1 * c22.G
            ;
            double b =
                d1 * c00.B + d2 * c01.B + d1 * c02.B
                + d2 * c10.B + d4 * c11.B + d2 * c12.B
                + d1 * c20.B + d2 * c21.B + d1 * c22.B
            ;
                        #else
            double a =
                AccessMemoize(1, c00.A) + AccessMemoize(2, c01.A) + AccessMemoize(1, c02.A)
                + AccessMemoize(2, c10.A) + AccessMemoize(4, c11.A) + AccessMemoize(2, c12.A)
                + AccessMemoize(1, c20.A) + AccessMemoize(2, c21.A) + AccessMemoize(1, c22.A)
            ;
            double r =
                AccessMemoize(1, c00.R) + AccessMemoize(2, c01.R) + AccessMemoize(1, c02.R)
                + AccessMemoize(2, c10.R) + AccessMemoize(4, c11.R) + AccessMemoize(2, c12.R)
                + AccessMemoize(1, c20.R) + AccessMemoize(2, c21.R) + AccessMemoize(1, c22.R)
            ;
            double g =
                AccessMemoize(1, c00.G) + AccessMemoize(2, c01.G) + AccessMemoize(1, c02.G)
                + AccessMemoize(2, c10.G) + AccessMemoize(4, c11.G) + AccessMemoize(2, c12.G)
                + AccessMemoize(1, c20.G) + AccessMemoize(2, c21.G) + AccessMemoize(1, c22.G)
            ;
            double b =
                AccessMemoize(1, c00.B) + AccessMemoize(2, c01.B) + AccessMemoize(1, c02.B)
                + AccessMemoize(2, c10.B) + AccessMemoize(4, c11.B) + AccessMemoize(2, c12.B)
                + AccessMemoize(1, c20.B) + AccessMemoize(2, c21.B) + AccessMemoize(1, c22.B)
            ;
                        #endif
            return(Color.FromArgb((int)a, (int)r, (int)g, (int)b));
        }