Acting on your suggestion, even though I though by default the PGraphics and the main applet shoul dbe in the same color mode, I explicitly set them up to be so.... but it didn't help.
Code:PImage loadedimage;
PGraphics buffer;
void setup()
{
size(500, 500);
colorMode(RGB, 255, 255, 255);
background(255);
loadedimage=loadImage("test.jpg");
buffer = createGraphics(loadedimage.width, loadedimage.height, P2D);
buffer.beginDraw();
buffer.image(loadedimage, 0, 0);
buffer.endDraw();
image(buffer, 50, 50, 400, 300);
}
void draw()
{
image(buffer, 50, 50, 400, 300);
}
void mouseDragged()
{
float bufferx, buffery;
bufferx = map(mouseX, 50, 450, 0, loadedimage.width);
buffery = map(mouseY, 50, 350, 0, loadedimage.height);
buffer.beginDraw();
buffer.colorMode(RGB, 255, 255, 255);
buffer.fill(0);
buffer.noStroke();
buffer.ellipse(bufferx, buffery, 20, 20);
buffer.endDraw();
}
void keyPressed()
{
buffer.save("saved.jpg");
}
The colours in the output image are all sort of washed out pinks and purples (it is a city scene with sky so they started out as mostly blues and greys). It's weird that you got a different result, remerer...what version of Processing, OS and Java are you using?
I have Processing 1.09, Windows XP, Java 1.6.0_18.