FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 1420 : images copied have alpha channel set to FE
Last modified: 2010-02-18 06:00
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
ASSIGNED
Resolution:
-
Pr
i
ority:
P4
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
hungerburg
Assigned To:
fry
Attachment
Type
Created
Size
Actions
img.copy() changes alpha from 255 to 254
application/x-zip-compressed
2010-02-18 03:54
2.71 KB
Description
: Opened: 2009-12-27 15:27
My sketch requests images, on loading filters them THRESHOLD and then
copies the new image over an old one with img.copy(...)
The sketch later reads pixels from the image. Unlike the starting image,
that comes from the data directory and is a b/w png, alpha in newly fetched
images becomes FE and black becomes in hex() not FF000000 but FE000000. The
OPAQUE filter does not help.
Additional Comment
#1 From fry 2010-02-17 20:02
can you post a very short example that shows the problem?
Additional Comment
#2 From hungerburg 2010-02-18 03:54
edit
]
img.copy() changes alpha from 255 to 254
Hello fry!
My report was a little confusing. I created a minimal sketch, its clearer now.
There is just one image that is copied over itself. Look at the console output,
press shift for a second, after the image is swapped, alpha goes from 255 to
254. filtering does not help. loadPixels neither.
PImage img; // image we want to track
PImage nimg; // next image
color c; // under mouse
void setup()
{
frameRate(1);
size (200, 200);
img = loadImage("some.jpg");
nimg = loadImage("some.jpg");
//nimg.filter(OPAQUE);
}
void draw()
{
image(img, 0, 0, width, height);
if(keyPressed && keyCode == SHIFT) {
img.copy(nimg, 0, 0, nimg.width, nimg.height, 0, 0, width, height);
//img.loadPixels();
println("image swapped.");
}
c = img.pixels[mouseY*img.width+mouseX];
println(mouseX+", "+mouseY+", "+alpha(c));
}
Additional Comment
#3 From fry 2010-02-18 06:00
k, the problem is just that the image functions (like copy) aren't super
accurate. they sacrifice accuracy for speed, so there's some rounding error
as things are transferred. unfortunately that's what you're seeing here.
there's not much we can do about it short of making the image copy() method
far slower, so i think we're mostly stuck with it.
thanks for the report, i'll keep this around in case we can move to a
better solution in the future.
This bug is now being tracked
here
.