Skip to content

Commit

Permalink
Test image transform optimizations for Rpi
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkao committed Aug 7, 2016
1 parent 8671fc1 commit 9dc3ed0
Showing 1 changed file with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,28 +294,34 @@ public BufferedImage applyImageTransforms(DataAid aid, BufferedImage img, int wi
throw new IllegalStateException("BufferedImage is null");
}

BufferedImage after = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
// if(aid.affineTransform.getScaleY() == -1) {
// aid.affineTransform.translate(0., -height);
// }
// after.getMinX() + i
// aid.affineTransform.translate(img.getMinX() - after.getMinX(), img.getMinY() - after.getMinY());
double yOff = -(height - (aid.affineTransform.getScaleY()*height))/2;
double xOff = -(width - (aid.affineTransform.getScaleX()*width))/2;
aid.affineTransform.translate(xOff, yOff);
AffineTransformOp transOp =
new AffineTransformOp(aid.affineTransform, AffineTransformOp.TYPE_BILINEAR);
after = transOp.filter(img, after);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
//image.setRGB(x, y, Color.black);
if (after.getRGB(x, y) == 0) {
// after.setRGB(x, y, -16777216);
after.setRGB(x, y, Color.black.getRGB());
}
}
}
//System.out.println("affineTranform's yscale = " + aid.affineTransform.getScaleY());
BufferedImage after = img;

if (!aid.affineTransform.isIdentity()) {
after = new BufferedImage(width, height, img.getType());

((Graphics2D)img.getGraphics()).setBackground(Color.black);
((Graphics2D)after.getGraphics()).setBackground(Color.black);

double yOff = -(height - (aid.affineTransform.getScaleY()*height))/2;
double xOff = -(width - (aid.affineTransform.getScaleX()*width))/2;
aid.affineTransform.translate(xOff, yOff);
AffineTransformOp transOp =
new AffineTransformOp(aid.affineTransform, AffineTransformOp.TYPE_BILINEAR);
after = transOp.filter(img, after);

/*
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
//image.setRGB(x, y, Color.black);
if (after.getRGB(x, y) == 0) {
// after.setRGB(x, y, -16777216);
after.setRGB(x, y, Color.black.getRGB());
}
}
*/
}

applyBulbMask(aid, (Graphics2D)after.getGraphics(), width, height);
return after;

Expand Down

0 comments on commit 9dc3ed0

Please sign in to comment.