Bug 1198 : Image created with img.get() works incorrectly when using filter()
Last modified: 2010-06-05 03:07




Status:
ASSIGNED
Resolution:
-
Priority:
P2
Severity:
normal

 

Reporter:
backspaces
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-03-11 07:46
When creating a duplicate image using img.get(), the use of the filter() method works or
doesn't, depending on the order of imaging the initial image and creating the duplicate.

I said it badly, but the attached code shows the problem. First run as is, and it will operate
as I expected. Flip the boolean showBug to true, and the filter call on the duplicate will not
take effect.

Revision: 1.0.1
Mac OS X 10.5.6
Code attached
Details above.

PImage img = createImage(200, 200, RGB);
boolean showBug = false;

void setup() {
size(img.width*2, img.height*2);
img.loadPixels();
for(int i = 0; i<img.pixels.length; i++)
img.pixels[i] = i % 256;
img.updatePixels();
noLoop();
}

void draw() {
PImage img1;
if (showBug) {
image(img,0,0); // Call image first
img1 = img.get();
}
else {
img1 = img.get(); // make duplicate image first
image(img,0,0);
}
image(img1,width/2,0);

img1.filter(THRESHOLD);
image(img,0,height/2);
image(img1,width/2,height/2);
}
Additional Comment #1 From backspaces 2009-03-11 07:56
It occurred to me that the code was clearer with the names of the two images changed from
img1 & img2 to img and dup. Here's a copy:

PImage img = createImage(200, 200, RGB);
boolean showBug = false;

void setup() {
size(img.width*2, img.height*2);
img.loadPixels();
for(int i = 0; i<img.pixels.length; i++)
img.pixels[i] = i % 256;
img.updatePixels();
noLoop();
}

void draw() {
PImage dup;
if (showBug) {
image(img,0,0); // Call image first
dup = img.get();
}
else {
dup = img.get(); // make duplicate image first
image(img,0,0);
}
image(dup,width/2,0);

dup.filter(THRESHOLD);
image(img,0,height/2);
image(dup,width/2,height/2);
}

Additional Comment #2 From fry 2009-03-11 08:00
*** Bug 1197 has been marked as a duplicate of this bug. ***
This bug is now being tracked here.