Ejemplo n.º 1
0
        private bool GetZBitmap()
        {
            Function2D f = null;

            for (int i = 0; i < Model.Items.Count; i++)
            {
                if (Model.Items[i] is Function2D)
                {
                    f = (Function2D)Model.Items[i];
                }
            }
            if (f != null)
            {
                if (f.rgb && (zscale.img == null || !zscale.rgb || fd != zscale.w || fh != zscale.h))
                {
                    zscale.w   = fd; zscale.h = fh;
                    zscale.img = new Bitmap(zscale.w, zscale.h);
                    for (int y = 0; y < zscale.h; y++)
                    {
                        for (int x = 0; x < zscale.w; x++)
                        {
                            zscale.img.SetPixel(x, zscale.h - 1 - y, f.RGBColor(((double)y) / zscale.h));
                        }
                    }
                }
                else if (!f.rgb && (zscale.img == null || zscale.rgb || f.Color != zscale.color ||
                                    fd != zscale.w || fh != zscale.h))
                {
                    zscale.w   = fd; zscale.h = fh;
                    zscale.img = new Bitmap(zscale.w, zscale.h);
                    for (int y = 0; y < zscale.h; y++)
                    {
                        for (int x = 0; x < zscale.w; x++)
                        {
                            zscale.img.SetPixel(x, zscale.h - 1 - y, f.FColor(((double)y) / zscale.h));
                        }
                    }
                }
                zscale.color = f.Color;
                zscale.rgb   = f.rgb;
            }
            return(f != null);
        }