예제 #1
0
    private DTexture PointScale2()
    {
        DTexture tex = new DTexture(this.width * 2, this.width * 2);

        for (int x = 0; x < this.width; x++)
        {
            for (int y = 0; y < this.height; y++)
            {
                tex.SetPixel((x * 2), (y * 2), this.GetPixel(x, y));
                tex.SetPixel((x * 2) + 1, (y * 2), this.GetPixel(x, y));
                tex.SetPixel((x * 2), (y * 2) + 1, this.GetPixel(x, y));
                tex.SetPixel((x * 2) + 1, (y * 2) + 1, this.GetPixel(x, y));
            }
        }
        return(tex);
    }
예제 #2
0
    private DTexture BilinearScale2()
    {
        DTexture tex = new DTexture(this.width * 2, this.width * 2);

        for (int x = 0; x < tex.width; x++)
        {
            for (int y = 0; y < tex.height; y++)
            {
                //sample and average the four colours around this pixel
                float v = 0;
                v += 0.25f * this.GetPixel(Mathf.FloorToInt((float)(x - 1) / 2f), Mathf.FloorToInt((float)(y) / 2f));
                v += 0.25f * this.GetPixel(Mathf.FloorToInt((float)(x) / 2f), Mathf.FloorToInt((float)(y - 1) / 2f));
                v += 0.25f * this.GetPixel(Mathf.FloorToInt((float)(x) / 2f), Mathf.FloorToInt((float)(y + 1) / 2f));
                v += 0.25f * this.GetPixel(Mathf.FloorToInt((float)(x + 1) / 2f), Mathf.FloorToInt((float)(y) / 2f));
                tex.SetPixel(x, y, v);
            }
        }

        return(tex);
    }