Image() function with 4 points

@chrisir,

Can you provide some context for this statement:

I am seeing the opposite in the context of my example below.

image() with 5 parameters is faster than resize() in this example:

PImage img1, img2;
int t1, t2;
boolean toggle;

void setup() 
  {
  size(800, 800, P2D);
  img1 = loadImage("https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/A_beautiful_view%2C_Kel%2C_Kashmir.jpg/480px-A_beautiful_view%2C_Kel%2C_Kashmir.jpg");
  println(img1.width, img1.height);
  mouseX = 1; mouseY = 1;
  }

void draw() 
  {
  background(0); 
  
  img2 = img1.copy();
  
  // image
  if (toggle)
    {
    t1 = millis();
    image(img2, 0, 0, mouseX, mouseY);
    t2 = millis();
    println("image", t2-t1);
    }
  // resize
  else
    {
    t1 = millis();
    img2.resize(mouseX, mouseY);
    image(img2, 0, 0);
    t2 = millis();
    println("resize", t2-t1);
    }
  }
  
void mouseClicked()
  {
  toggle = !toggle;
  }

Related topic:
Faster PImage Resizing

:)

1 Like

Well, the idea of resize is to use it only ONCE in setup and NOT throughout in draw()