one.empty3.feature20220726.ProxyValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of empty3-library-3d Show documentation
Show all versions of empty3-library-3d Show documentation
3D rendering engine. Plus modelling. Expected glsl textures 3d and 2d rendering3D primitives, and a lot of scenes' samples to test.+ Game Jogl reworked, Calculator (numbers and vectors). Java code parser implementation starts (<=1.2)
The newest version!
/*
*
* * Copyright (c) 2024. Manuel Daniel Dahmen
* *
* *
* * Copyright 2024 Manuel Daniel Dahmen
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/
package one.empty3.feature20220726;
import java.io.File;
import one.empty3.library.Point3D;
import one.empty3.io.ProcessFile;
import javaAnd.awt.image.imageio.ImageIO;
import one.empty3.feature20220726.*;
import java.util.logging.*;
public class ProxyValue extends ProcessFile {
public boolean process(File in, File out) {
double min = 0.3;
if (!in.getName().endsWith(".jpg"))
return false;
File file = in;
PixM original = null;
try {
original = PixM.getPixM(ImageIO.read(in), maxRes);
} catch (Exception ex) {
ex.printStackTrace();
return false;
// assertTrue(false);
}
int p = 0;
PixM copy = new PixM(original.getColumns(), original.getLines());
for (int i = 0; i < original.getColumns(); i++)
for (int j = 0; j < original.getLines(); j++)
if (original.luminance(i, j) < min) {
searchFromTo(original, copy, i, j, min * 2);
p++;
} else {
copy.set(i, j, original.get(i, j));
}
try {
ImageIO.write(copy.getImage(), "jpg", out);
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
System.out.println("point " + p);
return true;
}
public void searchFromTo(
PixM original, PixM copy, int i, int j, double min) {
Point3D p = null;
int i2 = i, j2 = j;
/* for(int k=0; k -1; i3 += incr[(sq + 2)]) {
for (int j3 = incr[(sq + 1)]; j3 < l && pass > -1; j3 += incr[(sq + 3)]) {
pass++;
i2 = i + i3;
j2 = j + j3;
p = null;
if (original.luminance(i2, j2) >= min) {
copyPixel(original, i2,
j2,
copy, i, j);
return;
}
if (pass > 2 * l) pass = -1;
}
}
}
}
// System.out.println("error not found");
return;
}
public void copyPixel(PixM m1, int i, int j,
PixM m2, int i2, int j2) {
for (int c = 0; c < 3; c++) {
m1.setCompNo(c);
m2.setCompNo(c);
m2.set(i2, j2, m1.get(i, j));
}
}
}