12.14总结
生病ing
package Vfx;
import okhttp3.*;
import org.json.JSONObject;
import javax.imageio.ImageIO;
import javax.swing.;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
public class Enhance {
public static final String API_KEY = "azh8NUHqQ6xfYxsycMj5064k";
public static final String SECRET_KEY = "RCrBgDCGT0gA0H0XuHHf8POXX5ExAi4G";
static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
static String accessToken;
public static void main(String[] args) {
JFrame frame = new JFrame("Image Processing");
frame.setSize(800, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel imageLabel = new JLabel();
imageLabel.setBounds(0, 100, 300, 300);
JLabel enhancedImageLabel = new JLabel();
enhancedImageLabel.setBounds(350, 100, 300, 300);
JButton addButton = new JButton("添加图片");
JButton enhanceButton = new JButton("图像清晰度增强");
addButton.setBounds(50, 50, 150, 30);
enhanceButton.setBounds(400, 50, 150, 30);
addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "jpg", "jpeg", "png", "gif");
fileChooser.setFileFilter(filter);
int result = fileChooser.showOpenDialog(null);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
String imagePath = selectedFile.getAbsolutePath();
// 显示选择的图片并缩放大小
ImageIcon imageIcon = new ImageIcon(imagePath);
Image originalImage = imageIcon.getImage();
int originalWidth = originalImage.getWidth(null);
int originalHeight = originalImage.getHeight(null);
int newWidth = 300;
int newHeight = (int) (originalHeight * ((double) newWidth / originalWidth));
Image scaledImage = originalImage.getScaledInstance(newWidth, newHeight, Image.SCALE_DEFAULT);
ImageIcon scaledImageIcon = new ImageIcon(scaledImage);
imageLabel.setIcon(scaledImageIcon);
}
}
});
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏