mirror of
https://github.com/csharpee/Map-Projections.git
synced 2025-12-11 00:00:15 -05:00
handle transparency correctly
yeah, a little surprising I hadn’t done this before now.
This commit is contained in:
parent
eaaadbb188
commit
96e96d07e3
@ -17,27 +17,9 @@
|
|||||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library name="mfc.jar">
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$USER_HOME$/eclipse-workspace/JTEM/mfc.jar!/" />
|
<root url="jar://C:/Program Files/Java/javafx-sdk-19.0.2.1/lib/javafx-swt.jar!/" />
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</orderEntry>
|
|
||||||
<orderEntry type="module-library">
|
|
||||||
<library name="ellipticFunctions.jar">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/eclipse-workspace/JTEM/ellipticFunctions.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</orderEntry>
|
|
||||||
<orderEntry type="module-library">
|
|
||||||
<library name="commons-math3-3.6.1.jar">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/eclipse-workspace/commons-math3-3.6.1/commons-math3-3.6.1.jar!/" />
|
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
@ -46,7 +28,7 @@
|
|||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library>
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://C:/Program Files/Java/javafx-sdk-11.0.2/lib/javafx-swt.jar!/" />
|
<root url="jar://C:/Program Files/Java/javafx-sdk-19.0.2.1/lib/javafx.base.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
@ -55,7 +37,7 @@
|
|||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library>
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://C:/Program Files/Java/javafx-sdk-11.0.2/lib/javafx.base.jar!/" />
|
<root url="jar://C:/Program Files/Java/javafx-sdk-19.0.2.1/lib/javafx.controls.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
@ -64,7 +46,7 @@
|
|||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library>
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://C:/Program Files/Java/javafx-sdk-11.0.2/lib/javafx.controls.jar!/" />
|
<root url="jar://C:/Program Files/Java/javafx-sdk-19.0.2.1/lib/javafx.fxml.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
@ -73,7 +55,7 @@
|
|||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library>
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://C:/Program Files/Java/javafx-sdk-11.0.2/lib/javafx.fxml.jar!/" />
|
<root url="jar://C:/Program Files/Java/javafx-sdk-19.0.2.1/lib/javafx.graphics.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
@ -82,7 +64,7 @@
|
|||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library>
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://C:/Program Files/Java/javafx-sdk-11.0.2/lib/javafx.graphics.jar!/" />
|
<root url="jar://C:/Program Files/Java/javafx-sdk-19.0.2.1/lib/javafx.media.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
@ -91,7 +73,7 @@
|
|||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library>
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://C:/Program Files/Java/javafx-sdk-11.0.2/lib/javafx.media.jar!/" />
|
<root url="jar://C:/Program Files/Java/javafx-sdk-19.0.2.1/lib/javafx.swing.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
@ -100,7 +82,38 @@
|
|||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library>
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://C:/Program Files/Java/javafx-sdk-11.0.2/lib/javafx.swing.jar!/" />
|
<root url="jar://C:/Program Files/Java/javafx-sdk-19.0.2.1/lib/javafx.web.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://C:/Program Files/Java/ellipticFunctions.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://C:/Program Files/Java/ellipticFunctions.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://C:/Program Files/Java/mfc.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://C:/Program Files/Java/mfc.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://C:/Program Files/Java/commons-math3-3.6.1/commons-math3-3.6.1.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES />
|
<SOURCES />
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public class MapConverter {
|
|||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
||||||
// the directory with the equirectangular maps to convert
|
// the directory with the equirectangular maps to convert
|
||||||
String directory = "C:/Users/Justin Kunimune/Downloads/AR Dymaxion Selections-20220212T141615Z-001/AR Dymaxion Selections";
|
String directory = "C:\\Users\\justi\\Downloads\\new_dymaxion_maps";
|
||||||
// the desired map projection
|
// the desired map projection
|
||||||
Projection projection = Polyhedral.DYMAXION;
|
Projection projection = Polyhedral.DYMAXION;
|
||||||
|
|
||||||
@ -53,8 +53,10 @@ public class MapConverter {
|
|||||||
// iterate thru the directory
|
// iterate thru the directory
|
||||||
for (Path inputPath: pathIterable) {
|
for (Path inputPath: pathIterable) {
|
||||||
// look for images that are not dymaxion projections
|
// look for images that are not dymaxion projections
|
||||||
if (inputPath.toString().endsWith(".png") &&
|
if (inputPath.toString().endsWith(".jpg") ||
|
||||||
!inputPath.toString().endsWith(".dymaxion.png")) {
|
inputPath.toString().endsWith(".tif") ||
|
||||||
|
inputPath.toString().endsWith(".png") &&
|
||||||
|
!inputPath.toString().endsWith(".dymaxion.png")) {
|
||||||
System.out.println(inputPath);
|
System.out.println(inputPath);
|
||||||
PixelMap inputImage = new PixelMap(inputPath.toFile());
|
PixelMap inputImage = new PixelMap(inputPath.toFile());
|
||||||
|
|
||||||
@ -71,8 +73,10 @@ public class MapConverter {
|
|||||||
null, null, null);
|
null, null, null);
|
||||||
|
|
||||||
// update the filename and save to disk
|
// update the filename and save to disk
|
||||||
String outputPath = inputPath.toString().replace(
|
String outputPath = inputPath.toString();
|
||||||
".png", ".dymaxion.png");
|
outputPath = outputPath.replace(".jpg", ".png");
|
||||||
|
outputPath = outputPath.replace(".tif", ".png");
|
||||||
|
outputPath = outputPath.replace(".png", ".dymaxion.png");
|
||||||
SavableImage.savable(outputImage).save(new File(outputPath));
|
SavableImage.savable(outputImage).save(new File(outputPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,9 @@
|
|||||||
*/
|
*/
|
||||||
package image;
|
package image;
|
||||||
|
|
||||||
|
import java.awt.Transparency;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.WritableRaster;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -37,10 +39,12 @@ import javax.imageio.ImageIO;
|
|||||||
public class PixelMap {
|
public class PixelMap {
|
||||||
|
|
||||||
private final BufferedImage pixels;
|
private final BufferedImage pixels;
|
||||||
|
private final WritableRaster alphaPixels;
|
||||||
|
|
||||||
|
|
||||||
public PixelMap(File f) throws IOException {
|
public PixelMap(File f) throws IOException {
|
||||||
pixels = ImageIO.read(f);
|
pixels = ImageIO.read(f);
|
||||||
|
alphaPixels = pixels.getAlphaRaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -63,7 +67,14 @@ public class PixelMap {
|
|||||||
y = 0;
|
y = 0;
|
||||||
else if (y >= pixels.getHeight())
|
else if (y >= pixels.getHeight())
|
||||||
y = pixels.getHeight() - 1;
|
y = pixels.getHeight() - 1;
|
||||||
|
|
||||||
|
int alpha;
|
||||||
|
if (pixels.getTransparency() != Transparency.OPAQUE)
|
||||||
|
alpha = alphaPixels.getPixel((int) x, (int) y, new int[1])[0];
|
||||||
|
else
|
||||||
|
alpha = 0xFF;
|
||||||
|
int rgb = pixels.getRGB((int) x, (int) y);
|
||||||
|
|
||||||
return (0xFF000000) | pixels.getRGB((int) x, (int) y);
|
return (alpha << 24) | rgb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user