<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with loadimage() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=loadimage%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:13:48 +0000</pubDate>
         <description>Tagged with loadimage() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedloadimage%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How can I clone an image object?</title>
      <link>https://forum.processing.org/two/discussion/18109/how-can-i-clone-an-image-object</link>
      <pubDate>Thu, 08 Sep 2016 06:02:29 +0000</pubDate>
      <dc:creator>thinsoldier</dc:creator>
      <guid isPermaLink="false">18109@/two/discussions</guid>
      <description><![CDATA[<p>I want to load an image and draw it once with a mask and again without the mask.</p>

<p>I though I could load it then duplicate it as img2 and only apply the mask to the first img object.</p>

<p>Is that possible or is there a different way to do it?</p>

<pre><code>function preload() {
  img = loadImage("assets/moonwalk.jpg");
  imgMask = loadImage("assets/mask.png");
  img2 = ? ? ? ? ? ?; // how do i clone the first img?
}

function setup() {
  createCanvas(720, 400);
  img.mask(imgMask);
  imageMode(CENTER);
}

function draw() {
  background(250, 255, 3);
  image(img2, width/2, height/2);
  image(img, mouseX, mouseY);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Using py processing to cycle through a set of jpgs?</title>
      <link>https://forum.processing.org/two/discussion/28039/using-py-processing-to-cycle-through-a-set-of-jpgs</link>
      <pubDate>Tue, 05 Jun 2018 00:19:53 +0000</pubDate>
      <dc:creator>netrate</dc:creator>
      <guid isPermaLink="false">28039@/two/discussions</guid>
      <description><![CDATA[<p>I am getting this error : 1st arg can't be coerced to processing.core.PImage</p>

<p>I have three jpgs named img1, img2, img3.</p>

<pre><code>img1=loadImage("pic1.jpg")
img2=loadImage("pic2.jpg")
img3=loadImage("pic3.jpg")`
</code></pre>

<p>The variable names are in a list.</p>

<pre><code>list1=["img1","img2","img3"]`
</code></pre>

<p>I wanted to iterate through the list using a for loop and call each image in sequence to run a simple animation, but I continue to get the error.</p>

<pre><code>for i in list1:
      image(i, 100, 100)
</code></pre>

<p>Is this not possible with processing or is there a different way to make this work?</p>
]]></description>
   </item>
   <item>
      <title>Find image dimensions when loading image</title>
      <link>https://forum.processing.org/two/discussion/27604/find-image-dimensions-when-loading-image</link>
      <pubDate>Sat, 31 Mar 2018 16:47:02 +0000</pubDate>
      <dc:creator>mikemcsharry</dc:creator>
      <guid isPermaLink="false">27604@/two/discussions</guid>
      <description><![CDATA[<p>Is it possible to open an image file, and get the size in pixels of the image as you load it? I have a bunch of photos with similar, but not identical, dimensions. I need to transform and rotate the images which is currently failing with some lovely screen displays!!</p>
]]></description>
   </item>
   <item>
      <title>Open Files</title>
      <link>https://forum.processing.org/two/discussion/7888/open-files</link>
      <pubDate>Fri, 31 Oct 2014 01:32:03 +0000</pubDate>
      <dc:creator>philspitler</dc:creator>
      <guid isPermaLink="false">7888@/two/discussions</guid>
      <description><![CDATA[<p>I'm using the code from this example to open a file.</p>

<p><a href="https://www.processing.org/reference/selectInput_.html" target="_blank" rel="nofollow">https://www.processing.org/reference/selectInput_.html</a></p>

<p>The issue I am having is that the code in my Setup and Draw function is starting to execute before I select a file.</p>

<p>I need my sketch to wait until I choose a file then proceed.</p>

<p>Any ideas?</p>

<p>Thanks.</p>

<p>Phil</p>

<pre><code>    void setup() {
      selectInput("Select a file to process:", "fileSelected");

      size(img.width, img.height);


    }

    void draw() {  



    }




    void fileSelected(File file) {
      if (file == null) {
        println("Window was closed or the user hit cancel.");
      } else {
        println("User selected " + file.getAbsolutePath());
        img = loadImage(file.getPath());  // Load the image into the program  


      }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to upload image in p5.js mode</title>
      <link>https://forum.processing.org/two/discussion/25418/how-to-upload-image-in-p5-js-mode</link>
      <pubDate>Wed, 06 Dec 2017 18:55:57 +0000</pubDate>
      <dc:creator>asdf</dc:creator>
      <guid isPermaLink="false">25418@/two/discussions</guid>
      <description><![CDATA[<p>I would like to upload an image file named "dillustration-01.png" (dimension: 1995 × 1667pixels) in p5.js mode. But if I use the following code, I get a blank screen with no image. I double checked that I have added the file "dillustration-01.png" in my sketch and I don't know why it's not working. Is there anything wrong with what I'm doing?</p>

<pre><code>var img;  // Declare variable 'img'.

function setup() {
  createCanvas(1000, 1000);
  img = loadImage("dillustration-01.png");  // Load the image
}

function draw() {
  // Displays the image at its actual size at point (0,0)
  image(img, 0, 0);
  // Displays the image at point (0, height/2) at half size
  //image(img, 0, height/2, img.width/2, img.height/2);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to use arguments with an application built with processing ?</title>
      <link>https://forum.processing.org/two/discussion/6457/how-to-use-arguments-with-an-application-built-with-processing</link>
      <pubDate>Tue, 22 Jul 2014 13:25:19 +0000</pubDate>
      <dc:creator>berenger</dc:creator>
      <guid isPermaLink="false">6457@/two/discussions</guid>
      <description><![CDATA[<p>I read in this thread : <a href="http://forum.processing.org/two/discussion/comment/22707#Comment_22707" target="_blank" rel="nofollow">http://forum.processing.org/two/discussion/comment/22707#Comment_22707</a></p>

<p>that "Processing's PApplet has a String[] field called args", so I'm wondering if anyone has managed to do an application that can use an argument on startup :</p>

<p>I mean I would like to double click on a gif and open a custom program made with processing to display it. Has anyone done this before ?</p>
]]></description>
   </item>
   <item>
      <title>Loading a large number of images</title>
      <link>https://forum.processing.org/two/discussion/23742/loading-a-large-number-of-images</link>
      <pubDate>Tue, 08 Aug 2017 00:42:59 +0000</pubDate>
      <dc:creator>bnew</dc:creator>
      <guid isPermaLink="false">23742@/two/discussions</guid>
      <description><![CDATA[<p>I'm working on a project where I cycle through and manipulate large number of images, but I keep running out of memory when trying to fill an array with my images. I have 2.3k images ranging from 400-700kb; the total size of the images is about 1.3 gb. I've increased the max memory allowance in Processing to 8gb but I'm still running out of memory.</p>

<p>My program gets stuck in setup loading my image files - (heres the code for reference)</p>

<p>for (int n = 0; n &lt; imageCount; n++) {
    images[n] = loadImage(prefix + n + fileformat);
  }</p>

<p>Is there a more memory efficient way to work with a large number of images? It still seems strange that the program takes significantly more memory than the file size of the images. I've been able to make it work with an image count ~1000.</p>

<p>Thanks!
B</p>
]]></description>
   </item>
   <item>
      <title>Google Chrome Image() function problem</title>
      <link>https://forum.processing.org/two/discussion/23465/google-chrome-image-function-problem</link>
      <pubDate>Sun, 16 Jul 2017 14:15:25 +0000</pubDate>
      <dc:creator>DominikN</dc:creator>
      <guid isPermaLink="false">23465@/two/discussions</guid>
      <description><![CDATA[<p>I made an animation in p5 Javascript. This animaiton has a backgroundimage. This Image is displayed perfectly in firefox and all other browsers except Google Chrome.</p>

<p>Can somebody help me?</p>

<h2>My JS code:</h2>

<pre><code>var canvas;
var backgroundimage;

var type1_Rect = [];
var type1_Rect_amount = screen.width * 0.2;
var type1_Rect_speed = 1;
var type1_Rect_size = 1;

//-----------------------
var type2_Rect = [];
var type2_Rect_amount = screen.width * 0.1;
var type2_Rect_speed = 0.7;
var type2_Rect_size = 2;
var j = 0;
//------------------------

var i = 0;
function windowResized() {
    resizeCanvas(window.innerWidth, window.innerHeight);
}
function setup() {
    backgroundimage = loadImage("wallpaper/wallpaper.png"); //The Backgroundimage

    canvas = createCanvas(window.innerWidth, window.innerHeight);
    canvas.position(0, 0);
    canvas.style('z-index', '-10');

    for (i = 0; i &lt; type1_Rect_amount; i++) {
    type1_Rect[i] = {
        x: random(0, screen.width),
        y: random(0, screen.height),

        display: function() {
            fill(255);
            noStroke();
            rect(this.x, this.y, type1_Rect_size, type1_Rect_size);
        },

        move: function() {
            this.y = this.y - type1_Rect_speed;

            if(type1_Rect[i].y &lt;= 0) {
                type1_Rect[i].y = window.innerHeight;
            }
        }
    }
}
i = 0;

//-------------------------------------
for (j = 0; j &lt; type2_Rect_amount; j++) {
type2_Rect[j] = {
    x: random(0, screen.width),
    y: random(0, screen.height),

    display: function() {
        fill(255);
        noStroke();
        rect(this.x, this.y, type2_Rect_size, type2_Rect_size);
    },

    move: function() {
        this.y = this.y - type2_Rect_speed;

        if(type2_Rect[j].y &lt;= 0) {
            type2_Rect[j].y = window.innerHeight;
        }
    }
}
}
j = 0;
 //---------------------------------------
}

function draw() {

image(backgroundimage, 0, 0);      //Backgroundimage

fill(255);
      //text(screen.width, 50, 50);
      //text(type1_Rect_amount, 50, 70);
      //text(type2_Rect_amount, 50, 90);

while (i &lt; type1_Rect_amount) {
type1_Rect[i].display();
type1_Rect[i].move();

i++;
}
i = 0;

      //----------------------------
while (j &lt; type2_Rect_amount) {
type2_Rect[j].display();
type2_Rect[j].move();

j++;
}
j = 0;
      //----------------------------
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>memory problem</title>
      <link>https://forum.processing.org/two/discussion/23381/memory-problem</link>
      <pubDate>Sun, 09 Jul 2017 23:57:48 +0000</pubDate>
      <dc:creator>scram</dc:creator>
      <guid isPermaLink="false">23381@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I'm trying to make a slide show-type program that loads images into an array and displays them randomly.  I've worked that out on a smaller scale but with the full array (1714 images) it runs out of memory.  Any ideas on how to optimize this?  Is there a way to randomly load a smaller number of images into the array as I go along, like randomized buffering?</p>

<pre><code>PImage [] images = new PImage [1714];


void setup() {
  fullScreen;
  noCursor();
  for (int i = 0; i &lt; images.length; i++) {
    images[i] = loadImage(i+".jpg");
  }
}

void draw() {
  image(images[int(random(1714))], 0, 0, width, height);
  frameRate(24);
}
</code></pre>

<p>Thank you!!</p>
]]></description>
   </item>
   <item>
      <title>Slides scrolling</title>
      <link>https://forum.processing.org/two/discussion/23278/slides-scrolling</link>
      <pubDate>Sun, 02 Jul 2017 00:45:17 +0000</pubDate>
      <dc:creator>leeepd</dc:creator>
      <guid isPermaLink="false">23278@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I am looking for ways to do scrolling slides. Say, I had a series of gif images or png images as frames. and as I slide down, those images will be loaded, working like an animation. I been searching on this Forum threads, but not really worked out. Any ideas? Thanks for your time on this.</p>
]]></description>
   </item>
   <item>
      <title>Read JSON and images in preload()</title>
      <link>https://forum.processing.org/two/discussion/23174/read-json-and-images-in-preload</link>
      <pubDate>Fri, 23 Jun 2017 03:04:16 +0000</pubDate>
      <dc:creator>reona396</dc:creator>
      <guid isPermaLink="false">23174@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I have a question about p5.js preload function.</p>

<p>I want to read JSON and images in my p5.js sketch,<br />
and JSON has images information (number of files, names, id).<br />
So I write a code and JSON as follows, but it doesn't work properly.<br />
I think JSON value  is not read normally or not on time in preload function.<br />
I wonder how I can resolve this problem. Please your help!</p>

<hr />

<pre><code>var data;  
var images = [];  
var itemNum;  

function preload() {  
    data = loadJSON("./data.json");  

    itemNum = Object.keys(data).length;  
    console.log(itemNum); // output "0", but this is actually "3"  

    for (var i = 0; i &lt; itemNum; i++) {  
        images[i] = loadImage("./images/image" + data[i].imageId + ".png");  
    }  
}  

function setup() {  
    createCanvas(100, 100);  
    image(images[0], 0, 0);  
}  
</code></pre>

<hr />

<pre><code>[{
        "name": "AAA",
        "imageId": "100"
    },
    {
        "name": "BBB",
        "imageId": "200"
    },
    {
        "name": "CCC",
        "imageId": "300"
    }
]
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to make 2 moving images collide?</title>
      <link>https://forum.processing.org/two/discussion/22966/how-to-make-2-moving-images-collide</link>
      <pubDate>Tue, 06 Jun 2017 23:47:15 +0000</pubDate>
      <dc:creator>brianna0811</dc:creator>
      <guid isPermaLink="false">22966@/two/discussions</guid>
      <description><![CDATA[<p>I want to have the panda (which the user moves with left and right arrow keys) collide with a candy image which is falling from the top left of the screen. When the 2 images collide, it would say "YOU TOUCHED THE CANDY" on the screen and the console. But when the panda and candy touch, nothing happens.</p>

<p>Here is the link to the code (I couldn't figure out how to indent the code on here):
<a href="https://paste.ofcode.org/sBSTST866aqUv5xkzWJ84g" target="_blank" rel="nofollow">https://paste.ofcode.org/sBSTST866aqUv5xkzWJ84g</a></p>

<p>I tried doing if (pandaX==xPosCandy &amp;&amp; pandaY==yPosCandy ) 
But it didn't work.
I also tried doing if (pandaX&gt;xPosCandy &amp;&amp; pandaY&lt;yPosCandy ) but it says YOU TOUCHED THE CANDY too soon.</p>

<p>Any help would be appreciated, and let me know if you need more code. Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Strange behavoure with text(..)</title>
      <link>https://forum.processing.org/two/discussion/22289/strange-behavoure-with-text</link>
      <pubDate>Sat, 29 Apr 2017 17:48:39 +0000</pubDate>
      <dc:creator>dreezy</dc:creator>
      <guid isPermaLink="false">22289@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>i'm new here, but i cannot find the answer about my question.</p>

<p>I've writen a program with some text-entries.
The coordinates of the text are calculated by a for-loop</p>

<pre><code>for (i=0;i&lt;14;i++){
   StrStart=tijdStart[i].substring(0,IntstrTemp);  
     IntstrTemp=tijdStop[i].indexOf(":");
     StrStop=tijdStop[i].substring(0,IntstrTemp);
     text(StrStart+" t/m "+StrStop+" u",(i*85)+10,215+yTranspose);
     WeatherPicture = loadImage("http://" + "openweathermap.org/img/w/" + code[i] + ".png");
     image(WeatherPicture,(i*85)+10,210+yTranspose,60,60);
     text("vocht: "+vochtigheid[i]+"%",(i*85)+10,270+yTranspose);

etc
</code></pre>

<p>The first time the program runs, everything is at the right place, but after a minute, the program gets an update from openweathermap.org and prints the info again.</p>

<p>The info is now placed to the left.. Everything is out of order...</p>

<p>1st picture is the right alignment, second picture is after 1 minute....</p>

<p><img src="http://i1373.photobucket.com/albums/ag387/dreezy100/1_zpsp4cyvk7c.png" alt="" /></p>

<p><img src="http://i1373.photobucket.com/albums/ag387/dreezy100/2_zps7qfwqj7r.png" alt="" /></p>

<p>I hope you can give me some answer what to do.</p>

<p>Thanx</p>
]]></description>
   </item>
   <item>
      <title>Trying loading media in thimbleproject</title>
      <link>https://forum.processing.org/two/discussion/22191/trying-loading-media-in-thimbleproject</link>
      <pubDate>Tue, 25 Apr 2017 06:35:48 +0000</pubDate>
      <dc:creator>kfrajer</dc:creator>
      <guid isPermaLink="false">22191@/two/discussions</guid>
      <description><![CDATA[<p>Trying to follow this post: <a href="https://forum.processing.org/two/discussion/18109/how-can-i-clone-an-image-object" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/18109/how-can-i-clone-an-image-object</a> (also <a href="https://thimbleprojects.org/gotoloop/97931/sketch.js" target="_blank" rel="nofollow">https://thimbleprojects.org/gotoloop/97931/sketch.js</a>   )</p>

<p>I tried to use sketchpad.cc but I gave up as it doesn't allow me to load mp3 files to their assets folder.</p>

<p>The idea is to load a sound file but I am having issues accessing the files from the assets source as demo by <a href="/two/profile/GoToLoop">@GoToLoop</a> in previous posts. I am not sure what I am doing wrong or what I am missing. I am trying images and no success. What I am missing?</p>

<p>This is what I have:</p>

<pre><code>"use strict";

const SUBFOLDER = 'assets/';
let original;

function preload(){
  original = loadImage('http://"+"ashemag.com/wp-content/uploads/2016/03/Classy-Sunglasses-for-summer-03-300x300.jpg');}

  //NOTICE I also tried to loaded from hte resource folder
  //original = loadImage(SUBFOLDER + 'original.jpg');
}

function setup() {

  createCanvas(original.width, original.height);

}

function draw() {
  background(original); 
}
</code></pre>

<p>My html file is like this:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;title&gt;Made with Thimble&lt;/title&gt;
  &lt;link rel="stylesheet" href="style.css"&gt;

    &lt;script async src="<a href="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/p5.js" target="_blank" rel="nofollow">https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/p5.js</a>"&gt;&lt;/script&gt;

  &lt;!--&lt;script language="javascript" type="text/javascript" src="https://"+"cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/addons/p5.dom.js"&gt;&lt;/script&gt;
&lt;script async language="javascript" type="text/javascript"  src="https://"+"cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.8/addons/p5.sound.js"&gt;&lt;/script&gt;--&gt;

  &lt;script defer src="sketch.js"&gt; &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

  &lt;h1&gt;Welcome to Thimble&lt;/h1&gt;
  &lt;div id="supercanvas"&gt;&lt;/div&gt;
  &lt;p&gt;Make something &lt;strong&gt;amazing&lt;/strong&gt; with the web!&lt;/p&gt;
&lt;/body&gt;
</code></pre>

<p></p>

<p>So when I try running the js + html, I get a "Loading..." but nothing happens. Is this CORS related despite I am running in thimbleproject?</p>

<p>CORS relate comment: <a href="https://forum.processing.org/two/discussion/comment/95739/#Comment_95739" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/comment/95739/#Comment_95739</a></p>

<p>Kf</p>

<p>Additional but not relevant: <a href="https://forum.processing.org/two/discussion/21532/dom-interfering-with-sketch-container/p1" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/21532/dom-interfering-with-sketch-container/p1</a></p>
]]></description>
   </item>
   <item>
      <title>On p5JS canvas changing background image showing already drawn objects behind the background image</title>
      <link>https://forum.processing.org/two/discussion/22026/on-p5js-canvas-changing-background-image-showing-already-drawn-objects-behind-the-background-image</link>
      <pubDate>Sun, 16 Apr 2017 07:21:26 +0000</pubDate>
      <dc:creator>Adeeba</dc:creator>
      <guid isPermaLink="false">22026@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'm drawing some objects on canvas but if later I change the background image on demand, then already drawn objects are behind the background image. How to bring already drawn objects in front. Below is the sample code i'm using to change the background image.</p>

<p>function draw() {
    if(chnBg){  //if change background is clicked
        loadImage("images/Grid_Image.png",function(bg){<br />
                background(bg);<br />
        });
    }
}</p>
]]></description>
   </item>
   <item>
      <title>Strange behavioral difference between rectangles and images</title>
      <link>https://forum.processing.org/two/discussion/21991/strange-behavioral-difference-between-rectangles-and-images</link>
      <pubDate>Fri, 14 Apr 2017 10:24:59 +0000</pubDate>
      <dc:creator>sai</dc:creator>
      <guid isPermaLink="false">21991@/two/discussions</guid>
      <description><![CDATA[<p>I am beginning to learn P5JS by creating a simple shooting game in which targets are loaded as random images and when clicked they disappear. The targets are objects that are loaded into an array and drawn each frame, and when one is clicked it is simply removed from the array and no longer drawn the next frame. I have run into a problem in which I can't get the images to be redrawn every frame, however if I replace the image with a rectangle it IS redrawn every frame.</p>

<p>Here is my code:</p>

<pre><code>var target;

// Array the stores all targets
var targets = [];

// x and y spawn coordinates for targets
var x;
var y;
var targetX;
var targetY;

// Image that shows when a target is hit, an explosion etc
var deathImage;

function setup() {
    createCanvas(windowWidth, windowHeight);
    frameRate(2);
    imageMode(CENTER);
    cursor(CROSS);
}

function draw() {

    x = int(random(windowWidth));
    y = int(random(windowHeight));
    targetImage = createImg('assets/test.png').hide();

    targets.push(new Target(x, y, targetImage));
    fill(0, 255, 255);
    rectMode(CORNER);
    rect(0, 0, width, height);
    for (var i = 0; i &lt; targets.length; i++) {
            targets[i].display();
    }

}

// Target Class
function Target(x, y, targetImage) {
    this.display = function() {
            this.targetX = x;
            this.targetY = y;
            this.TargetPicture = targetImage;

            /* When I use an image here it only shows in a single frame and then dissapears, the targets[i].display(); for loop fails to redraw all the targets */
            image(this.TargetPicture, this.targetX, this.targetY, 200, 200);

            /*However if I draw rectangles it works as expected            
            fill(255,0,0);
            rectMode(CENTER);
            rect(x,y,200,200); */
    }
}

function mouseClicked() {
    for (var i = 0; i &lt; targets.length; i++) {
        var distanceChecker = dist(mouseX, mouseY, targets[i].targetX, targets[i].targetY);
        // If target is hit
        if (distanceChecker &lt; 150) {
            fill(255, 0, 255);
            // Show explosion when target hit
            deathImage = createImg('assets/deathImage.png').hide();
            image(deathImage, mouseX, mouseY, 300, 300);
            // Remove target from array
            targets.splice(i, 1);
        }
    }

}
</code></pre>

<p>What am I missing? Thanks in advance!</p>
]]></description>
   </item>
   <item>
      <title>size() variable error</title>
      <link>https://forum.processing.org/two/discussion/21314/size-variable-error</link>
      <pubDate>Fri, 10 Mar 2017 16:42:37 +0000</pubDate>
      <dc:creator>Frey</dc:creator>
      <guid isPermaLink="false">21314@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I want to set the size based on an image dimensions.</p>

<p>What am I doing wrong?
<a rel="nofollow" href="https://forum.processing.org/two/uploads/imageupload/445/ODGZGEL7YGYB.jpg" title="Error">Error</a></p>

<p>(if I print the value, it's ok).</p>

<p>def setup():</p>

<pre><code> photo = loadImage("Photo.jpg")
 print(photo.height)
 image(photo, 0, 0)
</code></pre>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>Creating image slider in p5.js</title>
      <link>https://forum.processing.org/two/discussion/20873/creating-image-slider-in-p5-js</link>
      <pubDate>Sat, 18 Feb 2017 20:33:17 +0000</pubDate>
      <dc:creator>nielsvanhaaften</dc:creator>
      <guid isPermaLink="false">20873@/two/discussions</guid>
      <description><![CDATA[<p>Hey</p>

<p>I am very new to p5.js and programming in general. I am trying to create an image slider in p5.js, but i am running into a problem. I want the image slider to function as an HTML object so when you click on the image it will shift to the next image. In order to make it into an HTML object I have to use the createImg(), right? But this function does not work with the variables I need for the image slider, I think because HTML objects are only drawn once.</p>

<p>Your assistance would be very much appreciated!</p>

<p>This is the code I have so far (hope I did that display as code thing right, it doesn't show yet)</p>

<pre><code>var img = [];
var index = 0;
var lala;

function preload(){

  img[0] = loadImage('afbeelding0.jpg');
  img[1] = loadImage('afbeelding1.jpg');
}

function setup(){
  createCanvas(displayWidth,displayHeight*2);
}

function draw(){

  lala = createImg(img[index]);

  lala.position(50,50);
  lala.mousePressed(next);

  if (index == img.length){
    index = index - img.length;
  }
  print(index)
}

function next(){
  index = index + 1;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>I do not know why loadImage() is not working.</title>
      <link>https://forum.processing.org/two/discussion/20573/i-do-not-know-why-loadimage-is-not-working</link>
      <pubDate>Tue, 31 Jan 2017 11:40:34 +0000</pubDate>
      <dc:creator>BabluKumar</dc:creator>
      <guid isPermaLink="false">20573@/two/discussions</guid>
      <description><![CDATA[<p>Here is my code snippet. I do not know why my code is not working. <a href="https://alpha.editor.p5js.org/hacback17/sketches/rk8xNLave" target="_blank" rel="nofollow">https://alpha.editor.p5js.org/hacback17/sketches/rk8xNLave</a></p>
]]></description>
   </item>
   <item>
      <title>how to access an image that's dragged onto a DOM element</title>
      <link>https://forum.processing.org/two/discussion/19831/how-to-access-an-image-that-s-dragged-onto-a-dom-element</link>
      <pubDate>Mon, 19 Dec 2016 19:34:56 +0000</pubDate>
      <dc:creator>djneils98</dc:creator>
      <guid isPermaLink="false">19831@/two/discussions</guid>
      <description><![CDATA[<p>playing around with file dragging. I can get an image dragged into the page to display on the page using a createimg command and then I can put that image into the P5 canvas but is there a way of getting the dropped image file straight into a variable so I can access its pixels?
I tried this but no dice:</p>

<p>function gotFile(file){</p>

<p>var img = file.data
  image(img,0,0)
}</p>
]]></description>
   </item>
   <item>
      <title>How do I process my image with this code and save the result?</title>
      <link>https://forum.processing.org/two/discussion/19653/how-do-i-process-my-image-with-this-code-and-save-the-result</link>
      <pubDate>Sat, 10 Dec 2016 22:12:11 +0000</pubDate>
      <dc:creator>Urahara</dc:creator>
      <guid isPermaLink="false">19653@/two/discussions</guid>
      <description><![CDATA[<p>Hi, how do I process my images with this code? 
<a href="https://www.openprocessing.org/sketch/158305" target="_blank" rel="nofollow">https://www.openprocessing.org/sketch/158305</a></p>

<p>I downloaded Processing, opened the code, put my image in the sketch's "data" folder and added the
img = loadImage("img0.jpg");
line to the code under void setup(), but the program reterns an error:</p>

<p>"The file "img0.jpg" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable. Could not run the sketch (Target VM failed to initialize). "</p>

<p>Thank you</p>
]]></description>
   </item>
   <item>
      <title>Image transparency (alpha) via tint() is very slow.</title>
      <link>https://forum.processing.org/two/discussion/19438/image-transparency-alpha-via-tint-is-very-slow</link>
      <pubDate>Wed, 30 Nov 2016 23:45:59 +0000</pubDate>
      <dc:creator>brig</dc:creator>
      <guid isPermaLink="false">19438@/two/discussions</guid>
      <description><![CDATA[<p>Hi. I'm trying to adjust the alpha channel for images loaded using loadImage(). However, when I do so, FPS drops from 60FPS to 3FPS with just 4 images on screen.</p>

<p>Code I'm using is approximately: 
var path = "assets/video_placeholder.jpg"
var imgHandler = loadImage(path);
tint(255, 126);
image(imgHandler, 200, 200, 450, 450);</p>

<p>Is this expected? Other than using DOM to load images and applying CSS to control opacity, is there any better way to give transparency to images?</p>

<p>thx!</p>
]]></description>
   </item>
   <item>
      <title>Initializing arrays within a method</title>
      <link>https://forum.processing.org/two/discussion/19397/initializing-arrays-within-a-method</link>
      <pubDate>Tue, 29 Nov 2016 16:44:11 +0000</pubDate>
      <dc:creator>Mysterio1000</dc:creator>
      <guid isPermaLink="false">19397@/two/discussions</guid>
      <description><![CDATA[<p>I have this code:</p>

<pre><code>PImage[] lol;
PImage thing;

void setup() {
  size(500,300);

  thing = loadImage("c_0.png");
  loadImages(lol, 12);
}

void loadImages(PImage[] p1, int size) {
  p1 = new PImage[size];

  for(int i = 0; i &lt; size; i++) {
    p1[i] = thing;
  }
}

void draw() {
  image(lol[3], 30, 40);
}
</code></pre>

<p>However, this gives me a NullPointerException. Why? Can't I initialize the PImages inside a method?</p>

<p>Thank you for any help :)</p>
]]></description>
   </item>
   <item>
      <title>RaspberryPi Processing 3 Performance Issues for Loading images on runtime</title>
      <link>https://forum.processing.org/two/discussion/18287/raspberrypi-processing-3-performance-issues-for-loading-images-on-runtime</link>
      <pubDate>Sun, 25 Sep 2016 10:02:24 +0000</pubDate>
      <dc:creator>Bhargav</dc:creator>
      <guid isPermaLink="false">18287@/two/discussions</guid>
      <description><![CDATA[<p>I am using processing 3.2.1 on RasbperryPi 3</p>

<p>In one of my programs I am loading three images on runtime from set of images in a folder.  The images are changing runtime. Raspberrypi is fast enough to run the code and atleast load three images of each less then 150kb and of resolution 1260x760.</p>

<p>But my output becomes extremely slow while loading these images together. Loading one image runs smooth, two slower and three super slow. I have no guess about why is processing not able to run fast when Raspberypi is capable to running the code.  The same code runs with perfect speed on my laptop in windows.</p>

<p>Part of the code is as under :</p>

<pre><code>  //Load Images
  imgA = loadImage(path+ displayuserid +"/"+ displayobjectid +"/" + (imageno)%36 +  ".jpg");
  imgB = loadImage(path+ displayuserid +"/"+ displayobjectid +"/" + (imageno+1)%36 +  ".jpg");
  imgC = loadImage(path+ displayuserid +"/"+ displayobjectid +"/" + (imageno+2)%36 +  ".jpg");     


    //Display Images
    imgA.resize(0,250);
    image(imgA, width/2 - imgA.width/2, height/2 + height/2 - imgA.height);      


     pushMatrix();
     translate(width/2,height/2);
     rotate(90*TWO_PI/360);
     imgB.resize(0,250);
     image(imgB, -imgB.width/2, height/2-imgB.height);
     popMatrix();

     pushMatrix();
     translate(width/2,height/2);
     rotate(-90*TWO_PI/360);
     imgC.resize(0,250);
     image(imgC, -imgC.width/2, height/2-imgC.height);
     popMatrix();  
</code></pre>
]]></description>
   </item>
   <item>
      <title>Conditional background() of an image in draw() fails on OS X.</title>
      <link>https://forum.processing.org/two/discussion/18312/conditional-background-of-an-image-in-draw-fails-on-os-x</link>
      <pubDate>Tue, 27 Sep 2016 16:59:50 +0000</pubDate>
      <dc:creator>jet</dc:creator>
      <guid isPermaLink="false">18312@/two/discussions</guid>
      <description><![CDATA[<p>Running in to a strange problem with p5 0.6.1 on the Mac -- I can get a background image to load sometimes but not others.  The same script loads just fine on my Win8 VMWare partition, I'm using Firefox in OS X and Win8.</p>

<pre><code>var bg;
var backgroundLoaded = false;

function setup() {
  bg = loadImage("assets/moonwalk.png");
  createCanvas(720, 400);
}

function draw() {
  // this works, loads the background image on every cycle and overrwites my ellipses:
  // background(bg);

  if (backgroundLoaded == false) {
    // this works, turns the screen red, ellipses are not overwritten
    // background(255, 0, 0);
    // but this gives me a white screen:
    background(bg);
    backgroundLoaded = true;
  }

  ellipse(mouseX, mouseY, 10);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Setting img as background - Coordinate out of bounds</title>
      <link>https://forum.processing.org/two/discussion/18227/setting-img-as-background-coordinate-out-of-bounds</link>
      <pubDate>Wed, 21 Sep 2016 04:29:44 +0000</pubDate>
      <dc:creator>nach</dc:creator>
      <guid isPermaLink="false">18227@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys, I'm trying to display and image as my background in the <code>void setup()</code> but it shows me the <em>ArrayIndexOutOfBoundException: Coordinate out of bounds!</em> error.
However, when I use <code>background(img);</code> in the <code>void draw()</code> , it works.</p>

<pre><code>PImage sourceImg;
int dw, dh;

void setup () {
  sourceImg = loadImage("test2.jpg");
  surface.setResizable(true);
  dw = sourceImg.width;
  dh = sourceImg.height;
  surface.setSize(dw, dh);
  background(sourceImg); //HERE IT GIVES ME THE ERROR
}

void draw() {
  //background(sourceImg); //HERE IT WORKS
}
</code></pre>

<p>I don't know how to fix this. I need the background image to be drawn one time at the start of the program. What does that error mean?</p>

<p>Thx in advance!</p>
]]></description>
   </item>
   <item>
      <title>How do you load an image?</title>
      <link>https://forum.processing.org/two/discussion/18183/how-do-you-load-an-image</link>
      <pubDate>Fri, 16 Sep 2016 01:23:38 +0000</pubDate>
      <dc:creator>TajA</dc:creator>
      <guid isPermaLink="false">18183@/two/discussions</guid>
      <description><![CDATA[<p>I think that my syntax is correct but when i load the image, nothing shows up and then the program says "nullpointerexception" and crashes</p>
]]></description>
   </item>
   <item>
      <title>How to preload images using filenames from a .txt file</title>
      <link>https://forum.processing.org/two/discussion/18043/how-to-preload-images-using-filenames-from-a-txt-file</link>
      <pubDate>Fri, 02 Sep 2016 07:38:14 +0000</pubDate>
      <dc:creator>Hokk</dc:creator>
      <guid isPermaLink="false">18043@/two/discussions</guid>
      <description><![CDATA[<p>Hi I am currently working on a game project where I use a txt file that contains the sprite for an object, the object name, and some properties based on the object (ex: player.png, player, player's health). While the first two parts are not a problem to get working into the game, I cannot load the sprites due to only being able to run preload once which is spent on LoadStrings and so I cannot also load the images due to not being able to read the strings. Is there a way to force preload to wait until the LoadStrings function is done so that I can load the images that the txt file indicates?</p>

<p>Code Sample:</p>

<pre><code>    funtion preload(){
      mainFile = loadStrings("assets/MainFile.txt"); //load the text file
      //need it to wait here until loading strings finishes
      for (var i = 3; i &lt; mainFile.length; i++) {
        var newCharacterStr = splitTokens(mainFile[i], ",");
        var newImage = loadImage(newCharacterStr[0]);
      }
    }
</code></pre>

<p>MainFile.txt:</p>

<p>player.png,player,5</p>
]]></description>
   </item>
   <item>
      <title>How to set processing to automatically detect an image size and set it as a background?</title>
      <link>https://forum.processing.org/two/discussion/18033/how-to-set-processing-to-automatically-detect-an-image-size-and-set-it-as-a-background</link>
      <pubDate>Thu, 01 Sep 2016 14:42:54 +0000</pubDate>
      <dc:creator>testnia</dc:creator>
      <guid isPermaLink="false">18033@/two/discussions</guid>
      <description><![CDATA[<p>From my understanding, setting a background image in processing requires the size of the window to match the dimension of the image.</p>

<pre><code>PImage img = loadImage("background.jpg"); //a 100x100 background image.
size(100,100);
background(img);
</code></pre>

<p>However, since size() does not take in variables, how are we suppose to define a background with variable dimensions?</p>

<p>I have tested with the surface.setSize() function but it does not see to work.</p>

<p>Example:</p>

<pre><code>PImage img = loadImage("background.jpg"); //a 100x100 background image.
surface.setSize(img.width,img.height);
background(img);
</code></pre>
]]></description>
   </item>
   <item>
      <title>Processing doesn't let me use the size of the image for the size of the window</title>
      <link>https://forum.processing.org/two/discussion/17551/processing-doesn-t-let-me-use-the-size-of-the-image-for-the-size-of-the-window</link>
      <pubDate>Sat, 16 Jul 2016 17:01:57 +0000</pubDate>
      <dc:creator>cadavara</dc:creator>
      <guid isPermaLink="false">17551@/two/discussions</guid>
      <description><![CDATA[<p>I got the following code from a tutorial. I checked it with the reference and it should work.</p>

<p>The error I get is: "The size of this sketch could not be determined from your code. Use only numbers (not variables) for the size() command. Read the size() reference for more details.".</p>

<p><code>void setup(){
  PImage img = loadImage("image.jpg"); 
  size(img.width*2, img.height, P2D); 
  }</code></p>
]]></description>
   </item>
   </channel>
</rss>