Monday, 4 July 2016

doubling image size

// write your code here
//selecting the image i wanted to enlarge
var smallImage = ("smalllion.jpg");
//creating a blank image which is having twice as size of original image
var bigImage =   ("smallImage.getWidth() *2 , smallImage.getHeight() *2");
for (var px of bigImage.values()){
    var x = px.getX();
    var y = px.getY();
    var calx = Math.floor(x/2);
    var caly = Math.floor(y/2);
    var smallPixel = smallImage.getPixel(calx,caly);
    px.setRed(smallPixel.getRed());
    px.setGreen(smallPixel.getGreen());
    px.setBlue(smallPixel.getBlue());
}
print (bigImage);

No comments:

Post a Comment