# How to apply Corner radius to Raw Image texture ?

I trying to set corner radius to Raw Image in canvas .
How to set rounded image ( i.e my Raw image Rect (50,50) ) Like iOS we **Set Corner Radius ** to UIImage.

public RawImage PImage;
Texture2D texture = PImage.texture // also take any texture here

``````Texture2D temp = CalculateTexture (texture.height, texture.width, texture.height / 2, texture.height / 2, texture.width / 2, texture);
PImage.texture = temp;

Texture2D CalculateTexture (int h, int w, float r, float cx, float cy, Texture2D sourceTex)
{
Color [] c = sourceTex.GetPixels (0, 0, sourceTex.width, sourceTex.height);
Texture2D b = new Texture2D (h, w);
for (int i = 0; i<(h*w); i++)
{
int y = Mathf.FloorToInt (((float)i) / ((float)w));
int x = Mathf.FloorToInt (((float)i - ((float)(y * w))));
if (r * r >= (x - cx) * (x - cx) + (y - cy) * (y - cy)) {
b.SetPixel (x, y, c *);*
``````
• `````` 	} else {*
``````
• `````` 		b.SetPixel (x, y, Color.clear);*
``````
• `````` 	}*
``````

}

• `````` b.Apply ();*
``````
• `````` return b;*
``````

}