diff --git a/.idea/artifacts/main.xml b/.idea/artifacts/main.xml
new file mode 100644
index 0000000..adb1a0b
--- /dev/null
+++ b/.idea/artifacts/main.xml
@@ -0,0 +1,10 @@
+
+
+ $PROJECT_DIR$/out/artifacts/main
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_2.xml b/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_2.xml
deleted file mode 100644
index 1c380d0..0000000
--- a/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_sf_jopt_simple_jopt_simple_4_6.xml b/.idea/libraries/Maven__net_sf_jopt_simple_jopt_simple_4_6.xml
deleted file mode 100644
index 18ea23b..0000000
--- a/.idea/libraries/Maven__net_sf_jopt_simple_jopt_simple_4_6.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_commons_commons_math3_3_2.xml b/.idea/libraries/Maven__org_apache_commons_commons_math3_3_2.xml
deleted file mode 100644
index dde81ab..0000000
--- a/.idea/libraries/Maven__org_apache_commons_commons_math3_3_2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_17_1.xml b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_17_1.xml
deleted file mode 100644
index a54efd2..0000000
--- a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_17_1.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_core_2_17_1.xml b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_core_2_17_1.xml
deleted file mode 100644
index 9048f38..0000000
--- a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_core_2_17_1.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_ejml_ejml_core_0_38.xml b/.idea/libraries/Maven__org_ejml_ejml_core_0_38.xml
deleted file mode 100644
index 12bf403..0000000
--- a/.idea/libraries/Maven__org_ejml_ejml_core_0_38.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_ejml_ejml_ddense_0_38.xml b/.idea/libraries/Maven__org_ejml_ejml_ddense_0_38.xml
deleted file mode 100644
index 6fc9945..0000000
--- a/.idea/libraries/Maven__org_ejml_ejml_ddense_0_38.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_ejml_ejml_dsparse_0_38.xml b/.idea/libraries/Maven__org_ejml_ejml_dsparse_0_38.xml
deleted file mode 100644
index d476d75..0000000
--- a/.idea/libraries/Maven__org_ejml_ejml_dsparse_0_38.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_ejml_ejml_simple_0_38.xml b/.idea/libraries/Maven__org_ejml_ejml_simple_0_38.xml
deleted file mode 100644
index 08d8765..0000000
--- a/.idea/libraries/Maven__org_ejml_ejml_simple_0_38.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_openjdk_jmh_jmh_core_1_29.xml b/.idea/libraries/Maven__org_openjdk_jmh_jmh_core_1_29.xml
deleted file mode 100644
index beb0339..0000000
--- a/.idea/libraries/Maven__org_openjdk_jmh_jmh_core_1_29.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/EPQ 3D renderer.iml b/EPQ 3D renderer.iml
index 12135f4..cf6689e 100644
--- a/EPQ 3D renderer.iml
+++ b/EPQ 3D renderer.iml
@@ -17,16 +17,6 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/config.json b/config.json
index 108103e..8e79734 100644
--- a/config.json
+++ b/config.json
@@ -7,7 +7,6 @@
"playerSpeed":2.0,
"playerSprintModifier":2.0,
"debug":{
- "__comment":"values are: enabled/disabled",
"masterDebugToggle":"enabled",
"drawDebugHud":"disabled",
"drawLines":"false",
diff --git a/jsonTextures.json b/jsonTextures.json
index a932656..8d375a3 100644
--- a/jsonTextures.json
+++ b/jsonTextures.json
@@ -1,6 +1,6 @@
{"textures": [
{"name": "Black", "type": "solid", "color": "060606", "imgPath": "/", "randomValue": 0.1},
-{"name": "Camera", "type": "camera", "color": "cccccc", "imgPath": "/", "randomValue": 0.0},
+{"name": "Camera", "type": "solid", "color": "cccccc", "imgPath": "/Screenshot from 2022-06-06 18-52-12.png", "randomValue": 0.0},
{"name": "Concrete", "type": "solid", "color": "4d4d4d", "imgPath": "/", "randomValue": 0.1},
{"name": "Concrete.001", "type": "solid", "color": "535353", "imgPath": "/", "randomValue": 0.1},
{"name": "Crown", "type": "solid", "color": "064208", "imgPath": "/", "randomValue": 0.0},
diff --git a/pom.xml b/pom.xml
index a6371a2..a85476b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,6 +14,29 @@
11
+
+ maven-assembly-plugin
+ 3.5.0
+
+
+ jar-with-dependencies
+
+
+
+ uk.org.floop.epq3d.App
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
EPQ 3D Renderer
diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..09e83ca
--- /dev/null
+++ b/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: uk.org.floop.epq3d.App
+
diff --git a/src/main/java/uk/org/floop/epq3d/HTTPPost.java b/src/main/java/uk/org/floop/epq3d/HTTPPost.java
deleted file mode 100644
index 6701a9d..0000000
--- a/src/main/java/uk/org/floop/epq3d/HTTPPost.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package uk.org.floop.epq3d;
-
-public class HTTPPost {
- /* public void invokePost(JsonWriter json) {
-
- try {
- String requestBody = json.file.toJSONString();
- HttpClient client = HttpClient.newHttpClient();
- HttpRequest request = HttpRequest
- .newBuilder()
- .uri(URI.create("http://localhost:8080"))
- .POST(HttpRequest.BodyPublishers.ofString(requestBody))
- .header("Accept", "application/json")
- .build();
-
- HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
-
- //System.out.println(response.body());
- } catch (IOException | InterruptedException e) {
- e.printStackTrace();
- }
- }
-
-// private String prepareRequest() throws JsonProcessingException {
-// var values = new HashMap() {
-// {
-// put("Id", "12345");
-// put("Customer", "Roger Moose");
-// put("Quantity", "3");
-// put("Price","167.35");
-// }
-// };
-//
-// var objectMapper = new ObjectMapper();
-// String requestBody = objectMapper.writeValueAsString(values);
-// return requestBody;
-// }
-*/
-}
-
diff --git a/src/main/java/uk/org/floop/epq3d/JsonReader.java b/src/main/java/uk/org/floop/epq3d/JsonReader.java
index 0bba395..23cb6f1 100644
--- a/src/main/java/uk/org/floop/epq3d/JsonReader.java
+++ b/src/main/java/uk/org/floop/epq3d/JsonReader.java
@@ -112,13 +112,15 @@
Texture[] result = new Texture[textures.size()];
for(int i = 0; i < textures.size(); i += 1){
JSONObject JsonTexture = (JSONObject) textures.get(i);
+ String colour = (String)JsonTexture.get("color");
+ if(colour == null) colour = "000000";
if(Objects.equals(JsonTexture.get("type"), "solid")){
result[i] = new Texture(JsonTexture.get("name").toString(),
- Color.decode('#' + (String) JsonTexture.get("color")),
+ Color.decode('#' + colour),
(double)JsonTexture.get("randomValue"));
} else if(Objects.equals(JsonTexture.get("type"), "image")){
result[i] = new Texture(JsonTexture.get("name").toString(),
- Color.decode('#' + (String) JsonTexture.get("color")),
+ Color.decode('#' + colour),
(String) JsonTexture.get("imgPath"));
} else if(Objects.equals(JsonTexture.get("type"), "camera")){
result[i] = new Texture(JsonTexture.get("name").toString());
diff --git a/src/main/java/uk/org/floop/epq3d/Object3d.java b/src/main/java/uk/org/floop/epq3d/Object3d.java
index a96adcd..0c1b00f 100644
--- a/src/main/java/uk/org/floop/epq3d/Object3d.java
+++ b/src/main/java/uk/org/floop/epq3d/Object3d.java
@@ -29,14 +29,14 @@
}
- public void invalidate() {
+ public void invalidate(drawData drawData) {
for (Face face :
faces) {
face.invalidate();
}
for (Texture texture:
textures){
- texture.invalidate();
+ texture.invalidate(drawData);
}
}
diff --git a/src/main/java/uk/org/floop/epq3d/ObjectCollection.java b/src/main/java/uk/org/floop/epq3d/ObjectCollection.java
index f8a0c09..0890c33 100644
--- a/src/main/java/uk/org/floop/epq3d/ObjectCollection.java
+++ b/src/main/java/uk/org/floop/epq3d/ObjectCollection.java
@@ -62,7 +62,7 @@
boundingSphereR = Math.max(boundingSphereR, distance);
}
}
- public void invalidate(boolean invalidatePoints){
+ public void invalidate(drawData drawData, boolean invalidatePoints){
// the first level of object collections should contain all the points for the sublevels.
// this means that we only need to invalidate them at the top level
if(invalidatePoints){for (PointComp point:
@@ -71,11 +71,11 @@
}}
for(ObjectCollection subCollection:
subCollections){
- subCollection.invalidate(false);
+ subCollection.invalidate(drawData, false);
}
for(Object3d object:
objects){
- object.invalidate();
+ object.invalidate(drawData);
}
}
diff --git a/src/main/java/uk/org/floop/epq3d/Player.java b/src/main/java/uk/org/floop/epq3d/Player.java
index 5500254..19d0c56 100644
--- a/src/main/java/uk/org/floop/epq3d/Player.java
+++ b/src/main/java/uk/org/floop/epq3d/Player.java
@@ -15,8 +15,8 @@
public boolean isSprinting = false;
// movement variables
- private final Point3D position = new Point3D(0,0,0);
- private final Point3D rotation = new Point3D(0,Math.PI / 2, 0);
+ private final Point3D position = new Point3D(0,0,1);
+ private final Point3D rotation = new Point3D(0,Math.PI / 2, 4);
private final Vector3D direction = new Vector3D(0,0,0);
// button variables
@@ -77,12 +77,15 @@
case KeyEvent.VK_4:
drawData.zBufferDisabled = !drawData.zBufferDisabled;
break;
+ case KeyEvent.VK_5:
+ drawData.texturesDisabled = !drawData.texturesDisabled;
+ break;
case KeyEvent.VK_9:
- drawData.frustumCullingOverridePercent += 10;
+ drawData.frustumCullingOverridePercent += 2;
break;
case KeyEvent.VK_0:
drawData.frustumCullingOverridePercent = Math.max(0,
- drawData.frustumCullingOverridePercent - 10);
+ drawData.frustumCullingOverridePercent - 2);
break;
}
}
diff --git a/src/main/java/uk/org/floop/epq3d/Screen.java b/src/main/java/uk/org/floop/epq3d/Screen.java
index 16134c7..4316f18 100644
--- a/src/main/java/uk/org/floop/epq3d/Screen.java
+++ b/src/main/java/uk/org/floop/epq3d/Screen.java
@@ -23,9 +23,6 @@
// mainCollection stores all the background information in the scene
public ObjectCollection mainCollection;
- // stores the skybox
- // I should probably make this work at some point
- public Object3d skyBox;
// suppress serialization warning (future me says ??)
private static final long serialVersionUID = 490905409104883233L;
@@ -51,11 +48,10 @@
BufferedImage cursorImage = new BufferedImage(1, 1, BufferedImage.TRANSLUCENT);
invisibleCursor = toolkit.createCustomCursor(cursorImage, hotSpot, "InvisibleCursor");
-
// initialize the game state
player = new Player(drawData);
lastTime = System.nanoTime();
- // this frameTimer will call the actionPerformed() method every DELAY ms
+ // calls actionPerformed() method
frameTimer = new Timer(drawData.delay, this);
frameTimer.start();
initialised = true;
@@ -74,23 +70,20 @@
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
-
// draw graphics.
drawScreen(g);
- // player.draw(g, this);
Toolkit.getDefaultToolkit().sync();
}
private void drawScreen(Graphics g) {
drawData.lastFrameTime = (System.nanoTime()- lastTime)/1000000d;
lastTime = System.nanoTime();
- mainCollection.invalidate(true);
+ mainCollection.invalidate(drawData, true);
ArrayList FrustumInfo = new ArrayList<>();
for(int i = 0; i<6; i += 1){FrustumInfo.add(i);}
mainCollection.draw(drawData, FrustumInfo);
// DEBUG DRAWING
{
- //debugImg.getGraphics().drawString(Math.round(1000 / (float) (System.currentTimeMillis() - lastTime)) + " fps", 10, 10);
drawData.debugImg.getGraphics().drawString("FrameTime: " + (drawData.lastFrameTime) + " millis", 10, 10);
if(drawData.debugHud) {
drawData.debugImg.getGraphics().drawString("fpPos: " +
diff --git a/src/main/java/uk/org/floop/epq3d/Texture.java b/src/main/java/uk/org/floop/epq3d/Texture.java
index 0df48ee..bed1ea9 100644
--- a/src/main/java/uk/org/floop/epq3d/Texture.java
+++ b/src/main/java/uk/org/floop/epq3d/Texture.java
@@ -44,8 +44,8 @@
camera = Webcam.getDefault();
camera.open(true);
}
- public void invalidate(){
- if(Objects.equals(type, "camera")){
+ public void invalidate(drawData drawData){
+ if(Objects.equals(type, "camera") && !drawData.texturesDisabled){
index += 1;
if(index == 10){
nextFrame();
diff --git a/src/main/java/uk/org/floop/epq3d/Triangle.java b/src/main/java/uk/org/floop/epq3d/Triangle.java
index 2c58db6..d8ebfb6 100644
--- a/src/main/java/uk/org/floop/epq3d/Triangle.java
+++ b/src/main/java/uk/org/floop/epq3d/Triangle.java
@@ -262,7 +262,7 @@
yzGradient = 0;
}
// if the triangle is textured, calculate a matrix to apply the texture
- if(isTextured) {
+ if(isTextured && !drawData.texturesDisabled) {
// temporary object for multiplying
Matrix MultMat = new Matrix(3, 3);
// temporary unit up vector for reference
@@ -349,10 +349,10 @@
drawData.zBuf[x][y] = newZ;
// project result
int pixColor;
- if(isTextured){
+ if(isTextured && !drawData.texturesDisabled){
double[] pos = textureMappingMatrix.multiplyPoint2raw(x, y);
//pixColor = texture.getColor(ang, 0, 0);
- pixColor = texture.getColor(ang, (int)(pos[0]*1920), 1080-(int)(pos[1]*1080));
+ pixColor = texture.getColor(ang, (int)(pos[0]*texture.image.getWidth()), texture.image.getHeight()-(int)(pos[1]*texture.image.getHeight()));
// Math.floorMod((int)(pos[0]*texture.image.getWidth()), texture.image.getWidth()),
// Math.floorMod(-1-(int)(pos[1]*texture.image.getHeight()), texture.image.getHeight())
//);
@@ -361,7 +361,7 @@
pixColor = texture.getColor(ang, random);
}
if(drawData.drawZBuffer){
- drawData.drawImg.setElem(x + y*drawData.scrX, Color.getHSBColor(0, 0, (float)newZ/2147483648f + 0.5f).getRGB());
+ drawData.drawImg.setElem(x + y*drawData.scrX, Color.getHSBColor(0, 0, (float)newZ/16384f + 0.5f).getRGB());
//drawData.drawImg[x][y] = Color.getHSBColor(0, 0, (float)newZ/2147483648f + 0.5f).getRGB();
} else{
drawData.drawImg.setElem(x + y*drawData.scrX, pixColor);
diff --git a/src/main/java/uk/org/floop/epq3d/drawData.java b/src/main/java/uk/org/floop/epq3d/drawData.java
index 7878749..a7ea7a2 100644
--- a/src/main/java/uk/org/floop/epq3d/drawData.java
+++ b/src/main/java/uk/org/floop/epq3d/drawData.java
@@ -33,7 +33,7 @@
// player
public double playerSpeed;
public double playerSprintModifier;
- public simpleImage simImg;
+ public boolean texturesDisabled = false;
// draw onto
BufferedImage bufImg;
public DataBuffer drawImg;
@@ -82,7 +82,6 @@
frustumCullingOverridePercent = (int)(long)debugFile.get("frustumCullingOverridePercent");
drawZBuffer = toBoolean(debugFile.get("drawZBuffer"));
drawLines = toBoolean(debugFile.get("drawLines"));
-
}
// init varaibles
bufImg = new BufferedImage(scrX, scrY, BufferedImage.TYPE_INT_ARGB);
diff --git a/src/main/java/uk/org/floop/epq3d/simpleGraphics.java b/src/main/java/uk/org/floop/epq3d/simpleGraphics.java
deleted file mode 100644
index f6d9ae1..0000000
--- a/src/main/java/uk/org/floop/epq3d/simpleGraphics.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package uk.org.floop.epq3d;
-
-import java.awt.*;
-import java.awt.image.ImageObserver;
-import java.text.AttributedCharacterIterator;
-
-public class simpleGraphics extends Graphics {
- @Override
- public Graphics create() {
- return null;
- }
-
- @Override
- public void translate(int x, int y) {
-
- }
-
- @Override
- public Color getColor() {
- return null;
- }
-
- @Override
- public void setColor(Color c) {
-
- }
-
- @Override
- public void setPaintMode() {
-
- }
-
- @Override
- public void setXORMode(Color c1) {
-
- }
-
- @Override
- public Font getFont() {
- return null;
- }
-
- @Override
- public void setFont(Font font) {
-
- }
-
- @Override
- public FontMetrics getFontMetrics(Font f) {
- return null;
- }
-
- @Override
- public Rectangle getClipBounds() {
- return null;
- }
-
- @Override
- public void clipRect(int x, int y, int width, int height) {
-
- }
-
- @Override
- public void setClip(int x, int y, int width, int height) {
-
- }
-
- @Override
- public Shape getClip() {
- return null;
- }
-
- @Override
- public void setClip(Shape clip) {
-
- }
-
- @Override
- public void copyArea(int x, int y, int width, int height, int dx, int dy) {
-
- }
-
- @Override
- public void drawLine(int x1, int y1, int x2, int y2) {
-
- }
-
- @Override
- public void fillRect(int x, int y, int width, int height) {
-
- }
-
- @Override
- public void clearRect(int x, int y, int width, int height) {
-
- }
-
- @Override
- public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
-
- }
-
- @Override
- public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
-
- }
-
- @Override
- public void drawOval(int x, int y, int width, int height) {
-
- }
-
- @Override
- public void fillOval(int x, int y, int width, int height) {
-
- }
-
- @Override
- public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
-
- }
-
- @Override
- public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
-
- }
-
- @Override
- public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) {
-
- }
-
- @Override
- public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
-
- }
-
- @Override
- public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
-
- }
-
- @Override
- public void drawString(String str, int x, int y) {
-
- }
-
- @Override
- public void drawString(AttributedCharacterIterator iterator, int x, int y) {
-
- }
-
- @Override
- public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
- return false;
- }
-
- @Override
- public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
- return false;
- }
-
- @Override
- public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) {
- return false;
- }
-
- @Override
- public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) {
- return false;
- }
-
- @Override
- public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {
- return false;
- }
-
- @Override
- public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) {
- return false;
- }
-
- @Override
- public void dispose() {
-
- }
-}
diff --git a/src/main/java/uk/org/floop/epq3d/simpleImage.java b/src/main/java/uk/org/floop/epq3d/simpleImage.java
index 472b78c..a26b1c4 100644
--- a/src/main/java/uk/org/floop/epq3d/simpleImage.java
+++ b/src/main/java/uk/org/floop/epq3d/simpleImage.java
@@ -47,26 +47,31 @@
return null;
}
public int[] getPixel(int x, int y){
- switch (type){
- case BufferedImage.TYPE_INT_RGB:
- return new int[]{
- Byte.toUnsignedInt(data[3*(y*width + x)+1]),
- Byte.toUnsignedInt(data[3*(y*width + x)+2]),
- Byte.toUnsignedInt(data[3*(y*width + x)+3])};
- case BufferedImage.TYPE_4BYTE_ABGR:
- return new int[]{
- Byte.toUnsignedInt(data[4*(y*width + x)+3]),
- Byte.toUnsignedInt(data[4*(y*width + x)+2]),
- Byte.toUnsignedInt(data[4*(y*width + x)+1])};
- case BufferedImage.TYPE_CUSTOM: // but why
- try {
+ try {
+ switch (type) {
+ case BufferedImage.TYPE_INT_RGB:
return new int[]{
- Byte.toUnsignedInt(data[3 * (y * width + x) + 3]),
Byte.toUnsignedInt(data[3 * (y * width + x) + 1]),
- Byte.toUnsignedInt(data[3 * (y * width + x) + 2])};
- } catch (Exception e){
- return new int[]{0,0,0};
- }
+ Byte.toUnsignedInt(data[3 * (y * width + x) + 2]),
+ Byte.toUnsignedInt(data[3 * (y * width + x) + 3])};
+ case BufferedImage.TYPE_4BYTE_ABGR:
+ return new int[]{
+ Byte.toUnsignedInt(data[4 * (y * width + x) + 3]),
+ Byte.toUnsignedInt(data[4 * (y * width + x) + 2]),
+ Byte.toUnsignedInt(data[4 * (y * width + x) + 1])};
+ case BufferedImage.TYPE_CUSTOM: // but why
+ try {
+ return new int[]{
+ Byte.toUnsignedInt(data[3 * (y * width + x) + 3]),
+ Byte.toUnsignedInt(data[3 * (y * width + x) + 1]),
+ Byte.toUnsignedInt(data[3 * (y * width + x) + 2])};
+ } catch (Exception e) {
+ return new int[]{0, 0, 0};
+ }
+ }
+ }
+ catch (Exception e){
+ return new int[]{0, 0, 0};
}
throw new RuntimeException("I didn't add this image format: " + type);
}