Bug 428 : ARGB Images with createGraphics
Last modified: 2007-10-15 11:43




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

 

Reporter:
Stephen
Assigned To:
fry

Attachment Type Created Size Actions
The sketch to reproduce the problem. application/x-zip 2006-11-09 10:35 1.83 KB

Description:   Opened: 2006-11-03 09:05
When painting an ARGB image to a PGraphics object (created with
createGraphics) using image() or as a texture on a polygon it doesn't work.

It works fine when painting to the PApplets g object but not when I create
my own Graphics object.

I found the resulved bug http://dev.processing.org/bugs/show_bug.cgi?id=350
which is similar but a different problem.

Revision 'til 0118

below is some code that illustrates the problem.



PGraphics pg;

PImage b;

void setup() {
size(20, 20, P3D);
pg = createGraphics(20, 20, P3D);
//pg.format = ARGB;
b = loadImage("gui_small_handle_normal.gif");
// b = loadImage("gui_small_handle_normal.png");
// b = loadImage("gui_small_handle_normal.jpg");
}

void draw() {
background(255, 100, 0);
pg.beginDraw();
pg.background(255, 100, 0);
// pg.background(255);
// pg.image(b, 0, 0, width, height);
// pg.background(b);
pg.beginShape();
pg.texture(b);
pg.vertex(0, 0, 0, 0);
pg.vertex(20, 0, 100, 0);
pg.vertex(20, 20, 100, 100);
pg.vertex(0, 20, 0, 100);
pg.endShape();

pg.endDraw();

g.image(b, 50, 50);
g.image(pg, 0, 0);

if (mousePressed) {
g.beginShape();
g.texture(b);
g.vertex(0, 0, 0, 0);
g.vertex(20, 0, 100, 0);
g.vertex(20, 20, 100, 100);
g.vertex(0, 20, 0, 100);
g.endShape();
}
int bob = 0;
bob++;
}
Additional Comment #1 From fry 2006-11-03 20:37
can you post a copy of your actual sketch as an attachment? (use tools ->
archive sketch, and then the "create attachment" link above).
Additional Comment #2 From Stephen 2006-11-09 10:35
edit]
The sketch to reproduce the problem.
Additional Comment #3 From fry 2006-11-09 12:57
k, thanks for posting.

this is exclusive to cases where createGraphics() is used to build a
transparent surface, and the texture rendering is not happening properly.
until it is fixed, the workaround is to set pg.format = RGB, or use
background() to set the background opaque, although obviously that won't
work for all situations.

dev notes: this is a cousin of bug #90, where basically the
tint/fill/texture commands need to be straightened out as to their proper
use, and then implemented more consistently between the renderers.
specifically, for images, tint() should always be used to color textured
images, there is no such thing as fill() for textured images. internally,
however, the slots for 'fill' will be used to store the tint information
for the surface, as tint() is simply a simplification for the user that
prevents us from having to set the fill() to white any time we want to show
an image (otherwise it would be affected by the fill color, as is the case
for opengl, or extremely early releases of processing, i.e. rev 0013.. etc).
Additional Comment #4 From fry 2006-11-22 14:24
*** Bug 160 has been marked as a duplicate of this bug. ***
Additional Comment #5 From fry 2007-10-15 11:43
fixed in release 0127.