# \[imageLoad()\] disapear when i change size()

**URL:** <https://discourse.processing.org/t/imageload-disapear-when-i-change-size/7702>\
**Category:** Beginners\
**Created:** [January 21, 2019, 5:13pm UTC](https://discourse.processing.org/t/imageload-disapear-when-i-change-size/7702 "2019-01-21T17:13:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bMan](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bMan](https://discourse.processing.org/u/bMan)\
**Post date:** [January 21, 2019, 5:13pm UTC](https://discourse.processing.org/t/imageload-disapear-when-i-change-size/7702/1 "2019-01-21T17:13:17Z")

</div>

Hi, guys!  
I’m super new here. I need some help 🙂

I added a image with resolution for example 600x400, and set the size(600,400). Its perfectly works  
However,  
When i change size to another value for example size(800x600), the image cant be shown.

How do i solve that problem?

Actually, i want to add 2 photo with different resolutions and place them in a different location.  
for example first image placed x=0 y=0 [top left corner of image] and second one x=250 y=250 [again top left corner of image].

Thank you all ! 🤗

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [January 21, 2019, 5:22pm UTC](https://discourse.processing.org/t/imageload-disapear-when-i-change-size/7702/2 "2019-01-21T17:22:10Z")

</div>

Can you post your code? Or better yet, can you post a small example that shows the problem?

---

<div class="post-metadata">

**Author:** ![bMan](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bMan](https://discourse.processing.org/u/bMan)\
**Post date:** [January 21, 2019, 6:39pm UTC](https://discourse.processing.org/t/imageload-disapear-when-i-change-size/7702/3 "2019-01-21T18:39:13Z")

</div>

```auto

void settings(){
 size(1024,551); 
 frog = loadImage("frog.png");
}

void draw(){
 loadPixels();
 frog.loadPixels();
   for(int x=0;x<width;x++){
     for(int y=0;y<height;y++){
       int loc=x+y*width;
       pixels[loc] = frog.pixels[loc];
     }
   }
 updatePixels();
}

```

When i code like this, the image appears. (My frog.jpg’s resolution is width1024, heigth551)  
However if i change the size(1024,551) to another value, it doesnt appear…(with same image.)  
Like

```auto

void settings(){
 size(1400,700); // Randomly selected values
 frog = loadImage("frog.png");
}

void draw(){
 loadPixels();
 frog.loadPixels();
   for(int x=0;x<width;x++){
     for(int y=0;y<height;y++){
       int loc=x+y*width;
       pixels[loc] = frog.pixels[loc];
     }
   }
 updatePixels();
}

```

How can i work with any screen resolution ?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 21, 2019, 11:49pm UTC](https://discourse.processing.org/t/imageload-disapear-when-i-change-size/7702/4 "2019-01-21T23:49:41Z")

</div>

-a- first i think that is not related to a

```auto
loadImage(file);

```

problem.

-b- and i think you are aware ( and that should be your first test )  
of the default way to show the file / picture

```auto
void draw() {
  image(frog,0,0);
}

```

-c- your way  
“loading the image”  
AGAIN and AGAIN ( 60 times per sec )  
by overwriting the pixels buffer with pixels from picture  
( might be for some further experiments )  
but be aware that using width and height in the double for loop  
is insofar “wrong” ( if not wanted )  
as the “lines of picture” logic usually requires to use

```auto
frog.width
frog.height

```

actually i expect that there is a error in case your width\*height is bigger as the

> frog.width\*frog.height = frog.length

( total number of pix in picture )

so please  
-a- test the normal image(frog,0,0) way to make sure picture file loads ok.  
-b- take the pixels thing out of draw  
-c- repair the loop logic

could you please give some more words about  
what you want to do?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [January 22, 2019, 12:41am UTC](https://discourse.processing.org/t/imageload-disapear-when-i-change-size/7702/5 "2019-01-22T00:41:42Z")

</div>

> [@bMan](#):
>
> Actually, i want to add 2 photo with different resolutions and place them in a different location.  
> for example first image placed x=0 y=0 [top left corner of image] and second one x=250 y=250 [again top left corner of image].

Here is an example of loading two images and displaying them in a simple sketch.

```auto
size(600, 600);
PImage img1 = loadImage("https://forum.processing.org/processing-org.jpg");
PImage img2 = loadImage("https://processing.org/img/processing3-logo.png");
image(img1, 0, 0);
image(img2, 250, 250);

```

…and here again, in a dynamic sketch. The second image is tied to the mouse pointer.

```auto
PImage img1;
PImage img2;

void setup() {
  size(600, 600);
  img1 = loadImage("https://processing.org/img/processing3-logo.png");
  img2 = loadImage("https://forum.processing.org/processing-org.jpg");
}

void draw() {
  background(0);
  image(img1, 0, 0);
  image(img2, mouseX, mouseY);
}

```
