- Home /
Question by
ina · Jan 13, 2011 at 10:29 PM ·
texturemobilescreenshotantialias
Resizing a screenshot (mobile)
How do you resize a screenshot? (Say, not fullscreen resolution, but half the screen resolution)
Is there a way to antialias the resized screenshot?
Comment
Answer by The19 · Jul 25, 2011 at 01:32 PM
Source: http://jon-martin.com/?p=114
private Texture2D ScaleTexture(Texture2D source,int targetWidth,int targetHeight) {
Texture2D result=new Texture2D(targetWidth,targetHeight,source.format,true);
Color[] rpixels=result.GetPixels(0);
float incX=((float)1/source.width)*((float)source.width/targetWidth);
float incY=((float)1/source.height)*((float)source.height/targetHeight);
for(int px=0; px<rpixels.Length; px++) {
rpixels[px] = source.GetPixelBilinear(incX*((float)px%targetWidth),
incY*((float)Mathf.Floor(px/targetWidth)));
}
result.SetPixels(rpixels,0);
result.Apply();
return result;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613095331im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Using shaders for text effects (TextMesh) 0 Answers
Saving texture as raw 1 Answer
unity3d www download of large texture mobile 0 Answers