Beispiel #1
0
            public bool sample_pixel(double x, double y, out double r, out double g, out double b)
            {
                // h = y*(r/sqrt(x^2+f^2))
                // a = center_direction+atan(x/f)
                // r = 1, f fixed, for each "h, a", find "x, y"
                MyImageD image = image_provider.GetImageD();

                return(image.sample(x - (this.center_x - 0.5 * image.width), y - (this.center_y - 0.5 * image.height), out r, out g, out b));
            }
Beispiel #2
0
        protected override MyImageD GetImageDInternal()
        {
            MyImageD imgd = imgd_provider.GetImageD();
            int      width = (int)Math.Ceiling(imgd.width * scale), height = (int)Math.Ceiling(imgd.height * scale);
            int      stride = width * 4;
            MyImageD ans    = new MyImageD(new double[height * stride], width, height, stride, imgd.dpi_x, imgd.dpi_y, imgd.format, imgd.palette);

            Parallel.For(0, height, i => {
                for (int j = 0; j < width; j++)
                {//bgra
                    int k = i * stride + j * 4;
                    //x = width > 1 ? i / (width - 1) * (imgd.width - 1) : (imgd.width - 1) / 2;
                    //y = height > 1 ? i / (height - 1) * (imgd.height - 1) : (imgd.height - 1) / 2;
                    //imgd.sample(x, y, out double r, out double g, out double b);
                    imgd.sample(j / scale, i / scale, out double r, out double g, out double b);
                    //System.Diagnostics.Trace.WriteLine($"r={r}, g={g}, b={b}");
                    ans.data[k + 0] = b;
                    ans.data[k + 1] = g;
                    ans.data[k + 2] = r;
                    ans.data[k + 3] = 1;
                }