support additional image types from ImageIO.read(), check alpha on unknown images (fixes #3442), other notes

This commit is contained in:
Ben Fry
2015-07-14 11:51:48 -04:00
parent 005bd4b7d9
commit 5e82cbe636
6 changed files with 57 additions and 14 deletions
@@ -2903,6 +2903,9 @@ public class PGraphicsJava2D extends PGraphics {
if ((sourceX == 0) && (sourceY == 0) &&
(sourceWidth == sourceImage.width) &&
(sourceHeight == sourceImage.height)) {
// System.out.format("%d %d %dx%d %d%n", targetX, targetY,
// sourceImage.width, sourceImage.height,
// sourceImage.pixels.length);
raster.setDataElements(targetX, targetY,
sourceImage.width, sourceImage.height,
sourceImage.pixels);
+2 -1
View File
@@ -5294,7 +5294,8 @@ public class PApplet implements PConstants {
}
// if it's a .gif image, test to see if it has transparency
if (extension.equals("gif") || extension.equals("png")) {
if (extension.equals("gif") || extension.equals("png") ||
extension.equals("unknown")) {
image.checkAlpha();
}
+30 -9
View File
@@ -309,18 +309,31 @@ public class PImage implements PConstants, Cloneable {
BufferedImage bi = (BufferedImage) img;
width = bi.getWidth();
height = bi.getHeight();
pixels = new int[width * height];
pixels = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();
int type = bi.getType();
if (type == BufferedImage.TYPE_INT_ARGB) {
format = ARGB;
} else if (type == BufferedImage.TYPE_INT_RGB) {
for (int i = 0; i < pixels.length; i++) {
pixels[i] = 0xFF000000 | pixels[i];
if (type == BufferedImage.TYPE_3BYTE_BGR ||
type == BufferedImage.TYPE_4BYTE_ABGR) {
pixels = new int[width * height];
bi.getRGB(0, 0, width, height, pixels, 0, width);
if (type == BufferedImage.TYPE_4BYTE_ABGR) {
format = ARGB;
} else {
opaque();
}
} else {
DataBuffer db = bi.getRaster().getDataBuffer();
if (db instanceof DataBufferInt) {
pixels = ((DataBufferInt) db).getData();
if (type == BufferedImage.TYPE_INT_ARGB) {
format = ARGB;
} else if (type == BufferedImage.TYPE_INT_RGB) {
opaque();
}
}
}
} else { // go the old school java 1.0 route
}
// Implements fall-through if not DataBufferInt above, or not a
// known type, or not DataBufferInt for the data itself.
if (pixels == null) { // go the old school Java 1.0 route
width = img.getWidth(null);
height = img.getHeight(null);
pixels = new int[width * height];
@@ -1263,6 +1276,14 @@ public class PImage implements PConstants, Cloneable {
}
/** Set the high bits of all pixels to opaque. */
protected void opaque() {
for (int i = 0; i < pixels.length; i++) {
pixels[i] = 0xFF000000 | pixels[i];
}
}
/**
* Optimized code for building the blur kernel.
* further optimized blur code (approx. 15% for radius=20)
@@ -71,6 +71,7 @@ public class ThinkDifferent {
}
// Called via reflection from PSurfaceAWT and others
static public void setIconImage(Image image) {
// When already set, is a sun.awt.image.MultiResolutionCachedImage on OS X
// Image current = application.getDockIconImage();
+14 -4
View File
@@ -46,6 +46,8 @@ X https://github.com/processing/processing/issues/3413
X SVG briefly broken for Java2D
X https://github.com/processing/processing/issues/3417
X change how font metrics are pulled to fix text width issues
X check alpha when image extension is "unknown"
X https://github.com/processing/processing/issues/3442
threading headaches
X sketch not always showing with empty draw()
@@ -93,6 +95,10 @@ X errors with loading SVGs in P3D/P2D
X https://github.com/processing/processing/issues/3379
X sketch window briefly appears on top left corner when using OpenGL
X https://github.com/processing/processing/issues/3308
X add attrib() method
X https://github.com/processing/processing/issues/2963
X andres needs input on how the api works
o assign this to DXF as well?
contribs
X Fix NullPointerException in DepthSorter
@@ -127,9 +133,17 @@ _ on Export to Application, this has an impact
_ update wiki/docs to say "don't override sketchXxxx() methods"
_ change "PythonMode contains an incompatible Mode" message
_ to "PythonMode is not compatible with Processing 3"
_ another "incompatible tool" case
java.lang.AbstractMethodError
at processing.app.contrib.ToolContribution.init(ToolContribution.java:134)
beta
X move Java2D and JavaFX classes to their own packages
_ make notes about this in the README
_ move AWT image loading into PImageAWT
_ look into how GL and FX will handle from there
_ run only the necessary pieces on the EDT
_ in part because FX doesn't even use the EDT
_ re-check the Linux frame visibility stuff
@@ -175,10 +189,6 @@ _ https://www.linkedin.com/pulse/oracle-just-removed-javafx-support-arm-jan-sn
opengl
_ hard crash at 1920x1080, mirrored, Casey's GT 650M 1GB
_ add attrib() method
_ https://github.com/processing/processing/issues/2963
_ andres needs input on how the api works
_ assign this to DXF as well?
_ window loses focus after maximizing
_ https://github.com/processing/processing/issues/3339
+7
View File
@@ -42,6 +42,8 @@ X https://github.com/processing/processing/issues/3111
X Re-enable export to application with command line
X https://github.com/processing/processing/pull/3451
X https://github.com/processing/processing/issues/2760
X change undefined constructor error message for clarity
X https://github.com/processing/processing/issues/3434
gsoc
X Mode problems window wasn't doing line breaks
@@ -65,6 +67,10 @@ X https://github.com/processing/processing/issues/3429
X https://github.com/processing/processing/pull/3438
X CM with updated statusPanel and error popup
X https://github.com/processing/processing/pull/3452
X allow modes to import other modes
X https://github.com/processing/processing/pull/3444
X CM list converted into table
X https://github.com/processing/processing/pull/3454
cleaning
o libraries in java tabs (separate .java files) are reported missing
@@ -134,6 +140,7 @@ _ recent menu gets huge with other p5 versions on osx
pde/build
_ Cannot find "processing.core" library. Line 12 in tab sketch_150704a
_ dim out the Run button if there are compile errors detected
_ the AST checker has better error message handling for those cases
_ and hitting Run replaces the useful error with something weird