FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 1232 : imageMode(CENTER) doesn't work properly in P2D mode
Last modified: 2009-05-31 15:13
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
FIXED -
Pr
i
ority:
P2
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
PhiLhoČ
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2009-04-28 02:50
Following a message in Discourse (it have been deleted shortly after...), I
tested imageMode(CENTER) inside a PGraphics in P2D mode.
It appears the same operation is done twice.
PGraphics.image(PImage image, float x, float y) (and the version with all
parameters)
is offsetting the coordinates by half the image size, then call imageImpl.
PGraphicsJava2D.imageImpl() just calls g2.drawImage() and result is OK.
PGraphics2D..imageImpl() calls simple_image() which does:
if (imageMode == CENTER) {
sx1 -= image.width / 2;
sy1 -= image.height / 2;
}
Double offset...
Demonstration code:
PImage niceImage;
PImage smallImage;
void setup()
{
size(800, 800);
smooth();
noLoop();
niceImage = loadImage("Globe.png");
smallImage = loadImage("icon.png");
PGraphics pj = createGraphics(600, 600, P2D); // Change to JAVA2D for
correct result
pj.beginDraw();
pj.image(niceImage, 0, 0);
pj.imageMode(CENTER);
pj.image(smallImage, pj.width/2, pj.height/2);
pj.line(0, 0, pj.width, pj.height);
pj.line(0, pj.height, pj.width, 0);
pj.endDraw();
image(pj, 100, 100);
}
Processing 1.0.1, Windows XP Pro SP3
Additional Comment
#1 From fry 2009-04-28 03:48
Thanks.. did the original poster delete the message? Or is there something
wrong with the board?
Additional Comment
#2 From PhiLhoČ 2009-04-28 08:37
(In reply to
comment #1
)
> Thanks.. did the original poster delete the message? Or is there
something
> wrong with the board?
No idea. Just got an error when sending the answer, it was no longer in the
sub-forum listing...
Perhaps OP saw it works in JAVA2D and thought post was no longer relevant.
Additional Comment
#3 From fry 2009-05-31 15:13
thanks, now fixed for 1.0.4.