Bug 1013 : image(a, x, y) not honoring imageMode(CENTER)
Last modified: 2009-04-27 09:02




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P1
Severity:
normal

 

Reporter:
fry
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2008-11-16 05:06
imageMode(CORNER) and CORNERS work fine, but CENTER is ignored in 0156 and
earlier.

fixed for 0157.
Additional Comment #1 From PhiLhoČ 2009-04-27 08:53
I thought I should re-open (update) this bug instead of creating a new.
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 (perhaps after the fix of this
bug...).
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);
}
Additional Comment #2 From fry 2009-04-27 09:02
actually if you can file a new one that'd be great--this was a separate
problem so it's tracked differently (otherwise it goofs up the svn change
log if referring to an older bug that was closed). thanks!