x


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?

more ▼

asked Jan 13 '11 at 10:29 PM

ina gravatar image

ina
3.3k 492 551 603

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

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;
}
more ▼

answered Jul 25 '11 at 01:32 PM

The19 gravatar image

The19
1 1 1 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2210
x416
x104
x47

asked: Jan 13 '11 at 10:29 PM

Seen: 1380 times

Last Updated: Jul 25 '11 at 01:33 PM