fix for bug 522, problems with set() and JAVA2D

This commit is contained in:
benfry
2007-06-19 02:57:43 +00:00
parent 5ba1f9df32
commit dc39cb7614
2 changed files with 8 additions and 44 deletions

View File

@@ -1257,54 +1257,18 @@ public class PGraphicsJava2D extends PGraphics {
}
// fully debugged
/*
public void set(int dx, int dy, PImage src) {
int sx = 0;
int sy = 0;
int sw = src.width;
int sh = src.height;
if (dx < 0) { // off left edge
sx -= dx;
sw += dx;
dx = 0;
}
if (dy < 0) { // off top edge
sy -= dy;
sh += dy;
dy = 0;
}
if (dx + sw > width) { // off right edge
sw = width - dx;
}
if (dy + sh > height) { // off bottom edge
sh = height - dy;
}
//System.out.println(dx + " " + dy + " " +
// sx + " " + sy + " " + sw + " " + sh + " " +
// src.pixels + " " + 0 + " " + src.width);
BufferedImage bi = (BufferedImage) image;
bi.setRGB(dx, dy, sw, sh, src.pixels, sy*src.width + sx, src.width);
}
*/
protected void setImpl(int dx, int dy, int sx, int sy, int sw, int sh,
PImage src) {
//BufferedImage bi = (BufferedImage) image;
//bi.setRGB(dx, dy, sw, sh, src.pixels, sy*src.width + sx, src.width);
WritableRaster raster = ((BufferedImage) image).getRaster();
if ((sx == 0) && (sy == 0) && (sw == src.width) && (sh == src.height)) {
raster.setDataElements(dx, dy, src.width, src.height, src.pixels);
} else {
int mode = src.imageMode;
src.imageMode = CORNERS;
src.imageMode = CORNER;
// TODO Optimize, incredibly inefficient to reallocate this much memory
PImage temp = src.get(sx, sy, sw, sh);
src.imageMode = mode;
raster.setPixels(dx, dy, temp.width, temp.height, temp.pixels);
raster.setDataElements(dx, dy, temp.width, temp.height, temp.pixels);
}
}

View File

@@ -78,9 +78,11 @@ X workaround is to write the code properly, but suggests something bad
X http://dev.processing.org/bugs/show_bug.cgi?id=150
X registerSize() was registering as pre() instead
X http://dev.processing.org/bugs/show_bug.cgi?id=582
_ set() doesn't bounds check
_ this shouldn't actually be the case
_ http://dev.processing.org/bugs/show_bug.cgi?id=522
X set() doesn't bounds check
X this shouldn't actually be the case
X http://dev.processing.org/bugs/show_bug.cgi?id=522
X get()/set() in PGraphicsJava2D don't bounds check
X was actually a dumb error in setDataElements()
_ PGraphics problem with fillColor
_ http://dev.processing.org/bugs/show_bug.cgi?id=468
@@ -416,8 +418,6 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=346
_ image memory use.. how to handle lots of images
_ need to figure out exactly how they should/can unload
_ get()/set() in PGraphicsJava2D don't bounds check
_ add better error messages for all built-in renderers
_ i.e. "import library -> pdf" when pdf is missing