Loading...
Logo
Processing Forum
hello, I'm trying to resize a image, movie, but this function resize (),
not work for movie.

Now, first I'm trying to resize an image, the resize method, and another method to pixels [], but
with metedo pixels [], the image is not very clear.
as best I can this?





Image-Original




Copy code


  1. ///method resize()

    PImage img = createImage(500, 500, RGB);
    PImage myImage = loadImage("C:\\Users\\Omnimusha\\Desktop\\bleach-hd-background.jpg");
    //PImage myImage = loadImage("http://wallnen.com/wp-content/uploads/2013/05/Ichigo-Bleach-03-HD-Wallpaper.jpg");

      size(500,500);

    myImage.resize(500, (500*myImage.height)/myImage.width);
    //image(myImage, 0, 0,myImage.width,myImage.height);

    println(myImage.width);
    println(myImage.height);

    img.loadPixels();
    for (int i = 0; i < 500; i++) {
         for (int x = 0; x < myImage.height; x++) {
          
          int Index = i+  x * (myImage.width);
          int ndex = i+  (x+(500-myImage.height)/2) * (img.width);

      img.pixels[ndex] = myImage.pixels[Index];
    }
    }
    img.updatePixels();
    //
    image(img, 0, 0,width,height);
Copy code
  1. // method pixels[]

      size(500,500);
    PImage img = createImage(500, 500, RGB);
    PImage myImage = loadImage("C:\\Users\\Omnimusha\\Desktop\\bleach-hd-background.jpg");
    //PImage myImage = loadImage("http://wallnen.com/wp-content/uploads/2013/05/Ichigo-Bleach-03-HD-Wallpaper.jpg");

    img.loadPixels();
    int f=(500*myImage.height)/myImage.width;
    println(f);
    for (int i = 0; i < 500; i++) {
         for (int x = 0; x < f; x++) {
           float X=map(x,0,f,0,myImage.height);
           float Y=map(i,0,500,0,myImage.width);

            int Index = int (Y)+ int  (X) * (myImage.width);
           
            int ndex = i + (x+(500-f)/2) * (img.width);

         img.pixels[ndex] = myImage.pixels[Index];
       }
    }
    myImage.updatePixels();

    img.updatePixels();


    image(img, 0, 0,img.width,img.height);


result:



Result


Replies(5)

resize() changes the size of an image. It is good if you load an image of a given size and always want to display it at a different size, always the same. Otherwise (size changing on each frame, for example), just use image() at the right size.
To my knowledge, resize() won't work on a movie, and it not useful on a movie image, since they always change. Just display the movie image with image() at the right size.
I can not use this function image ().

think you can beat the / / method pixels []?
why you don´t simply use

Copy code
  1. image(myMovie, 0,0, 500, 500);

the image() function will automatically resize an input image for you to fit into 500x500 or whatever you specify. I think this is how movies are shown in smaller sizes.
it is for other purposes, and I can not use this function
I fail to understand your limitation (is this for an assignment?), but you can use your pixels method, by wrapping it in your own function. Probably much slower, but usable.