コード例 #1
0
        public static void CopyRect(Rectangle src, Rectangle dest, ComplexData from, BitBits to, bool use48)
        {
            if (from != null && from.Loaded)
            {
                if (src.Width > dest.Width)
                {
                    int xScale = src.Width / dest.Width;
                    int yScale = src.Height / dest.Height;

                    if (Settings.Main_Shrink_AveragePixel)
                    {
                        for (int x = 0; x < src.Width; x += xScale)
                        {
                            for (int y = 0; y < src.Height; y += yScale)
                            {
                                ColorD cd = AvgRange(from, x + src.X, y + src.Y, xScale);
                                Color c = Utils.Dither(cd);
                                if (use48)
                                {
                                    to.Set(x / xScale + dest.X, y / yScale + dest.Y, c, cd);
                                }
                                else
                                {
                                    to.Set(x / xScale + dest.X, y / yScale + dest.Y, c);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int x = 0; x < src.Width; x += xScale)
                        {
                            for (int y = 0; y < src.Height; y += yScale)
                            {
                                ColorD cd = from.GetPoint(x + src.X, y + src.Y);
                                Color c = Utils.Dither(cd);
                                if (use48)
                                {
                                    to.Set(x / xScale + dest.X, y / yScale + dest.Y, c, cd);
                                }
                                else
                                {
                                    to.Set(x / xScale + dest.X, y / yScale + dest.Y, c);
                                }
                            }
                        }
                    }
                }
                else if (src.Width == dest.Width)
                {
                    for (int x = 0; x < src.Width; x++)
                    {
                        for (int y = 0; y < src.Height; y++)
                        {
                            ColorD cd = from.GetPoint(x + src.X, y + src.Y);
                            Color c = Utils.Dither(cd);
                            if (use48)
                            {
                                to.Set(x + dest.X, y + dest.Y, c, cd);
                            }
                            else
                            {
                                to.Set(x + dest.X, y + dest.Y, c);
                            }
                        }
                    }
                }
                else if (src.Width < dest.Width)
                {
                    int xScale = dest.Width / src.Width;
                    int yScale = dest.Height / src.Height;

                    for (int x = 0; x < src.Width; x++)
                    {
                        for (int y = 0; y < src.Height; y++)
                        {
                            ColorD cd = from.GetPoint(x + src.X, y + src.Y);
                            Color c = Utils.Dither(cd);

                            for (int xOff = 0; xOff < xScale; xOff++)
                            {
                                for (int yOff = 0; yOff < yScale; yOff++)
                                {
                                    if (use48)
                                    {
                                        to.Set(x * xScale + dest.X + xOff, y * yScale + dest.Y + yOff, c, cd);
                                    }
                                    else
                                    {
                                        to.Set(x * xScale + dest.X + xOff, y * yScale + dest.Y + yOff, c);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Color c1 = Color.FromArgb(204, 204, 204);
                Color c2 = Color.FromArgb(255, 255, 255);
                ColorD cd1 = (ColorD)c1;
                ColorD cd2 = (ColorD)c2;

                for (int x = 0; x < dest.Width; x++)
                {
                    for (int y = 0; y < dest.Height; y++)
                    {
                        Color temp;
                        ColorD tempd;

                        if ((((x / 8) % 2) == 0) ^ (((y / 8) % 2) == 0))
                        {
                            temp = c1;
                            tempd = cd1;
                        }
                        else
                        {
                            temp = c2;
                            tempd = cd2;
                        }

                        if (use48)
                        {
                            to.Set(x + dest.X, y + dest.Y, temp, tempd);
                        }
                        else
                        {
                            to.Set(x + dest.X, y + dest.Y, temp);
                        }
                    }
                }
            }
        }
コード例 #2
0
        static void CopyRect48(Rectangle src, Rectangle dest, ComplexData from, BitBits to)
        {
            if (from.Loaded)
            {
                if (src.Width > dest.Width)
                {
                    int xScale = src.Width / dest.Width;
                    int yScale = src.Height / dest.Height;

                    for (int x = 0; x < src.Width; x += xScale)
                    {
                        for (int y = 0; y < src.Height; y += yScale)
                        {
                            ColorD c = AvgRange48(from, x + src.X, y + src.Y, xScale);
                            to.Set(x / xScale + dest.X, y / yScale + dest.Y, Utils.Dither(c), c);
                        }
                    }
                }
                else if (src.Width == dest.Width)
                {
                    for (int x = 0; x < src.Width; x++)
                    {
                        for (int y = 0; y < src.Height; y++)
                        {
                            ColorD cd = from.GetPoint(x + src.X, y + src.Y);
                            Color c = Utils.Dither(cd);
                            to.Set(x + dest.X, y + dest.Y, c, cd);
                        }
                    }
                }
                else if (src.Width < dest.Width)
                {
                    int xScale = dest.Width / src.Width;
                    int yScale = dest.Height / src.Height;

                    for (int x = 0; x < src.Width; x++)
                    {
                        for (int y = 0; y < src.Height; y++)
                        {
                            ColorD cd = from.GetPoint(x + src.X, y + src.Y);

                            for (int xOff = 0; xOff < xScale; xOff++)
                            {
                                for (int yOff = 0; yOff < yScale; yOff++)
                                {
                                    Color c = Utils.Dither(cd);
                                    to.Set(x * xScale + dest.X + xOff, y * yScale + dest.Y + yOff, c, cd);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Color c1 = Color.FromArgb(204, 204, 204);
                Color c2 = Color.FromArgb(255, 255, 255);

                for (int x = 0; x < dest.Width; x++)
                {
                    for (int y = 0; y < dest.Height; y++)
                    {
                        if ((((x / 8) % 2) == 0) ^ (((y / 8) % 2) == 0))
                        {
                            to.Set(x + dest.X, y + dest.Y, c1, c1);
                        }
                        else
                        {
                            to.Set(x + dest.X, y + dest.Y, c2, c2);
                        }
                    }
                }
            }
        }