Merge branch 'dev' into 'master'
Dev See merge request namophice/ink-photo-album!3
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>icu.namophice</groupId>
|
<groupId>icu.namophice</groupId>
|
||||||
<artifactId>ink-photo-album</artifactId>
|
<artifactId>ink-photo-album</artifactId>
|
||||||
<version>1.1-SNAPSHOT</version>
|
<version>1.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
|||||||
@@ -5,14 +5,8 @@ import icu.namophice.inkphotoalbum.driver.EPaper;
|
|||||||
import icu.namophice.inkphotoalbum.utils.CommonUtil;
|
import icu.namophice.inkphotoalbum.utils.CommonUtil;
|
||||||
import icu.namophice.inkphotoalbum.utils.ImageUtil;
|
import icu.namophice.inkphotoalbum.utils.ImageUtil;
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -84,56 +78,14 @@ public class MasterService {
|
|||||||
DefaultConfig.imageIndex = 0;
|
DefaultConfig.imageIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder imageUrlStr = new StringBuilder();
|
BufferedImage targetImage = ImageUtil.getImageToScreen(
|
||||||
try {
|
DefaultConfig.imageUrlArr[new Random().nextInt(DefaultConfig.imageUrlArr.length)],
|
||||||
final URL url = new URL(DefaultConfig.imageUrlArr[new Random().nextInt(DefaultConfig.imageUrlArr.length)]);
|
true
|
||||||
|
);
|
||||||
|
|
||||||
trustAllHttpsCertificates();
|
CommonUtil.printLogToConsole("Print images to screen ...");
|
||||||
HostnameVerifier hv = (urlHostName, session) -> {
|
ePaper.drawImage(targetImage);
|
||||||
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
|
DefaultConfig.imageIndex++;
|
||||||
return true;
|
|
||||||
};
|
|
||||||
HttpsURLConnection.setDefaultHostnameVerifier(hv);
|
|
||||||
|
|
||||||
final HttpURLConnection conn = (HttpURLConnection) (url.openConnection());
|
|
||||||
final URL imageUrl = conn.getURL();
|
|
||||||
imageUrlStr.append(imageUrl.getProtocol()).append("://").append(imageUrl.getHost()).append(imageUrl.getPath());
|
|
||||||
} catch (IOException e) {
|
|
||||||
DefaultConfig.imageIndex = 0;
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (imageUrlStr.length() > 0) {
|
|
||||||
BufferedImage targetImage = ImageUtil.getImageToScreen(imageUrlStr.toString(), true);
|
|
||||||
|
|
||||||
CommonUtil.printLogToConsole("Print images to screen ...");
|
|
||||||
ePaper.drawImage(targetImage);
|
|
||||||
DefaultConfig.imageIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 跳过SSL证书验证
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
private static void trustAllHttpsCertificates() throws Exception {
|
|
||||||
javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
|
|
||||||
javax.net.ssl.TrustManager tm = new miTM();
|
|
||||||
trustAllCerts[0] = tm;
|
|
||||||
javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
|
|
||||||
sc.init(null, trustAllCerts, null);
|
|
||||||
javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
|
|
||||||
@Override
|
|
||||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
|
|
||||||
@Override
|
|
||||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
|
|
||||||
@Override
|
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,10 @@ import java.io.FileReader;
|
|||||||
public class DefaultConfig {
|
public class DefaultConfig {
|
||||||
|
|
||||||
public static final String[] imageUrlArr = {
|
public static final String[] imageUrlArr = {
|
||||||
"https://api.ixiaowai.cn/api/api.php",
|
"https://www.dmoe.cc/random.php",
|
||||||
"https://api.ixiaowai.cn/api/api2.php",
|
"https://cdn.seovx.com/d/?mom=302",
|
||||||
"https://api.ixiaowai.cn/mcapi/mcapi.php",
|
"https://api.paugram.com/wallpaper/",
|
||||||
"https://api.ixiaowai.cn/mcapi/mcapi2.php",
|
"https://api.yimian.xyz/img"
|
||||||
"https://api.ixiaowai.cn/gqapi/gqapi.php",
|
|
||||||
"https://api.ixiaowai.cn/gqapi/gqapi2.php"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final String configFileName = "conf.json";
|
public static final String configFileName = "conf.json";
|
||||||
|
|||||||
@@ -317,6 +317,7 @@ public class ImageUtil {
|
|||||||
final int height = originImage.getHeight();
|
final int height = originImage.getHeight();
|
||||||
|
|
||||||
BufferedImage targetImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
|
BufferedImage targetImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
|
||||||
|
final int maxValue = 0xf73140, minValue = 0x83fd10;
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < width; i++) {
|
||||||
for (int j = 0; j < height; j++) {
|
for (int j = 0; j < height; j++) {
|
||||||
int rgb = originImage.getRGB(i, j);
|
int rgb = originImage.getRGB(i, j);
|
||||||
@@ -325,14 +326,18 @@ public class ImageUtil {
|
|||||||
int binValue;
|
int binValue;
|
||||||
|
|
||||||
// 0是黑 1是白 ,或者说数值小就靠近黑色,数值大就靠近白色
|
// 0是黑 1是白 ,或者说数值小就靠近黑色,数值大就靠近白色
|
||||||
if(oneGate > 0xec82e0) { // 大于一定数值,直接用白点
|
if (oneGate > maxValue) { // 大于一定数值,直接用白点
|
||||||
binValue = 0xffffff;
|
binValue = 0xffffff;
|
||||||
} else if(oneGate < 0x6ea050) { // 小于一定数值直接用黑点
|
} else if (oneGate < minValue) { // 小于一定数值直接用黑点
|
||||||
binValue = 0;
|
binValue = 0;
|
||||||
} else if(oneGate > randomNum) { // 模拟灰阶使用随机数画白点
|
|
||||||
binValue = 0xffffff;
|
|
||||||
} else {
|
} else {
|
||||||
binValue = 0;
|
// 模拟灰阶使用随机数画白点
|
||||||
|
final int random = new Random().nextInt(100);
|
||||||
|
if (oneGate > ((maxValue - minValue) / 2) + minValue) {
|
||||||
|
binValue = random < 60 ? 0xffffff : 0;
|
||||||
|
} else {
|
||||||
|
binValue = random < 80 ? 0 : 0xffffff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
targetImage.setRGB(i, j, binValue);
|
targetImage.setRGB(i, j, binValue);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 6.8 MiB |
2
start.sh
2
start.sh
@@ -5,6 +5,6 @@
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
cd /opt/software/ink-photo-album
|
cd /opt/software/ink-photo-album
|
||||||
/usr/bin/sudo /usr/bin/java -jar /opt/software/ink-photo-album/ink-photo-album-1.0-SNAPSHOT-all.jar
|
/usr/bin/sudo /usr/bin/java -jar /opt/software/ink-photo-album/ink-photo-album-1.0.jar
|
||||||
sleep 5m
|
sleep 5m
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user