implement imageMode(CENTER)

This commit is contained in:
benfry
2008-08-15 23:28:53 +00:00
parent c07d454379
commit 168c8d44d0
4 changed files with 14 additions and 0 deletions
@@ -1386,6 +1386,11 @@ public class PGraphicsJava2D extends PGraphics {
protected void setImpl(int dx, int dy, int sx, int sy, int sw, int sh,
PImage src) {
if (imageMode == CENTER) {
dx -= src.width/2; // not sw, since it's already cropped
dy -= src.height/2;
}
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);
+4
View File
@@ -400,6 +400,10 @@ public class PImage implements PConstants, Cloneable {
int sw = src.width;
int sh = src.height;
if (imageMode == CENTER) {
dx -= src.width/2;
dy -= src.height/2;
}
if (dx < 0) { // off left edge
sx -= dx;
sw += dx;
+1
View File
@@ -7,6 +7,7 @@ o write up examples for these instead?
o start an integration section?
X get() in java2d not honoring imageMode or rectMode
X add imageMode(CENTER) implementation
X add a bunch of changes to the reference to support this
cleanup
X switch to requestImage() (done in 0145)
@@ -2457,6 +2457,10 @@ public class PGraphicsOpenGL extends PGraphics3D {
* vertically. Both have their components all swapped to native.
*/
public void set(int x, int y, PImage source) {
if (imageMode == CENTER) {
x -= source.width / 2;
y -= source.height / 2;
}
int backup[] = new int[source.pixels.length];
System.arraycopy(source.pixels, 0, backup, 0, source.pixels.length);
javaToNativeARGB(source);