医院证明图片制作生成工具,病假条证明图片生成器, 医院报告单p图软件【仅供娱乐】

简介: 报告单P图软件的Java实现,包含多个模块,仅供娱乐用途。代码实现了基本的图像处理和文本叠加功能。

下载地址:https://www.pan38.com/share.php?code=pvvmX 提取码:8888 【仅供学习娱乐测试】

报告单P图软件的Java实现,包含多个模块,仅供娱乐用途。代码实现了基本的图像处理和文本叠加功能。

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class MedicalReportGenerator {
private static final String TEMPLATE_PATH = "template.jpg";
private static final String OUTPUT_PATH = "output/";
private static final String FONT_NAME = "Microsoft YaHei";

private BufferedImage templateImage;
private Map<String, Point> textPositions;
private Random random;

public MedicalReportGenerator() {
    this.random = new Random();
    loadTemplate();
    initTextPositions();
}

private void loadTemplate() {
    try {
        this.templateImage = ImageIO.read(new File(TEMPLATE_PATH));
    } catch (IOException e) {
        System.err.println("无法加载模板图片: " + e.getMessage());
        System.exit(1);
    }
}

private void initTextPositions() {
    textPositions = new HashMap<>();
    textPositions.put("hospitalName", new Point(300, 100));
    textPositions.put("patientName", new Point(200, 180));
    textPositions.put("patientGender", new Point(400, 180));
    textPositions.put("patientAge", new Point(500, 180));
    textPositions.put("patientID", new Point(200, 220));
    textPositions.put("examDate", new Point(500, 220));
    textPositions.put("examType", new Point(300, 260));
    textPositions.put("diagnosis", new Point(200, 300));
    textPositions.put("doctorName", new Point(200, 500));
    textPositions.put("reportDate", new Point(500, 500));
}

public void generateReport(PatientInfo patientInfo) {
    BufferedImage outputImage = new BufferedImage(
        templateImage.getWidth(),
        templateImage.getHeight(),
        BufferedImage.TYPE_INT_RGB
    );

    Graphics2D graphics = outputImage.createGraphics();
    graphics.drawImage(templateImage, 0, 0, null);

    graphics.setColor(Color.BLACK);
    graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    // 绘制医院名称
    drawText(graphics, "hospitalName", patientInfo.getHospitalName(), 28, Font.BOLD);

    // 绘制患者基本信息
    drawText(graphics, "patientName", "姓名: " + patientInfo.getName(), 16, Font.PLAIN);
    drawText(graphics, "patientGender", "性别: " + patientInfo.getGender(), 16, Font.PLAIN);
    drawText(graphics, "patientAge", "年龄: " + patientInfo.getAge(), 16, Font.PLAIN);
    drawText(graphics, "patientID", "身份证号: " + patientInfo.getIdNumber(), 16, Font.PLAIN);

    // 绘制检查日期
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
    drawText(graphics, "examDate", "检查日期: " + sdf.format(patientInfo.getExamDate()), 16, Font.PLAIN);

    // 绘制检查类型
    drawText(graphics, "examType", "检查项目: " + patientInfo.getExamType(), 18, Font.BOLD);

    // 绘制诊断结果
    drawMultiLineText(graphics, "diagnosis", "诊断结果: " + patientInfo.getDiagnosis(), 16, Font.PLAIN, 600);

    // 绘制医生签名和报告日期
    drawText(graphics, "doctorName", "医师签名: " + patientInfo.getDoctorName(), 16, Font.PLAIN);
    drawText(graphics, "reportDate", "报告日期: " + sdf.format(new Date()), 16, Font.PLAIN);

    graphics.dispose();

    saveImage(outputImage, patientInfo.getName());
}

private void drawText(Graphics2D graphics, String positionKey, String text, int fontSize, int fontStyle) {
    Point position = textPositions.get(positionKey);
    if (position != null) {
        Font font = new Font(FONT_NAME, fontStyle, fontSize);
        graphics.setFont(font);
        graphics.drawString(text, position.x, position.y);
    }
}

private void drawMultiLineText(Graphics2D graphics, String positionKey, String text, int fontSize, int fontStyle, int maxWidth) {
    Point position = textPositions.get(positionKey);
    if (position == null) return;

    Font font = new Font(FONT_NAME, fontStyle, fontSize);
    graphics.setFont(font);
    FontMetrics metrics = graphics.getFontMetrics();

    String[] words = text.split(" ");
    StringBuilder currentLine = new StringBuilder();
    int y = position.y;

    for (String word : words) {
        if (metrics.stringWidth(currentLine + " " + word) < maxWidth) {
            currentLine.append(word).append(" ");
        } else {
            graphics.drawString(currentLine.toString(), position.x, y);
            y += metrics.getHeight();
            currentLine = new StringBuilder(word + " ");
        }
    }

    if (!currentLine.isEmpty()) {
        graphics.drawString(currentLine.toString(), position.x, y);
    }
}

private void saveImage(BufferedImage image, String patientName) {
    File outputDir = new File(OUTPUT_PATH);
    if (!outputDir.exists()) {
        outputDir.mkdirs();
    }

    String fileName = OUTPUT_PATH + patientName + "_" + 
                     new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".jpg";

    try {
        ImageIO.write(image, "jpg", new File(fileName));
        System.out.println("报告单已生成: " + fileName);
    } catch (IOException e) {
        System.err.println("保存图片失败: " + e.getMessage());
    }
}

public static void main(String[] args) {
    MedicalReportGenerator generator = new MedicalReportGenerator();

    PatientInfo patient = new PatientInfo();
    patient.setName("张三");
    patient.setGender("男");
    patient.setAge(35);
    patient.setIdNumber("123456198801011234");
    patient.setHospitalName("北京协和医院");
    patient.setExamDate(new Date());
    patient.setExamType("胸部CT平扫");
    patient.setDiagnosis("1. 右肺上叶见一结节影,大小约1.2cm×1.0cm,边界尚清,建议3个月后复查;2. 双肺纹理增粗;3. 心脏大小形态正常;4. 纵隔内未见明显肿大淋巴结。");
    patient.setDoctorName("李四");

    generator.generateReport(patient);
}

}

import java.util.Date;

public class PatientInfo {
private String name;
private String gender;
private int age;
private String idNumber;
private String hospitalName;
private Date examDate;
private String examType;
private String diagnosis;
private String doctorName;

// 省略getter和setter方法

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getGender() {
    return gender;
}

public void setGender(String gender) {
    this.gender = gender;
}

public int getAge() {
    return age;
}

public void setAge(int age) {
    this.age = age;
}

public String getIdNumber() {
    return idNumber;
}

public void setIdNumber(String idNumber) {
    this.idNumber = idNumber;
}

public String getHospitalName() {
    return hospitalName;
}

public void setHospitalName(String hospitalName) {
    this.hospitalName = hospitalName;
}

public Date getExamDate() {
    return examDate;
}

public void setExamDate(Date examDate) {
    this.examDate = examDate;
}

public String getExamType() {
    return examType;
}

public void setExamType(String examType) {
    this.examType = examType;
}

public String getDiagnosis() {
    return diagnosis;
}

public void setDiagnosis(String diagnosis) {
    this.diagnosis = diagnosis;
}

public String getDoctorName() {
    return doctorName;
}

public void setDoctorName(String doctorName) {
    this.doctorName = doctorName;
}

}

相关文章
|
7月前
|
前端开发
Promise.all()方法接收的可迭代对象中,如果有一个Promise被拒绝,会发生什么?
Promise.all()方法接收的可迭代对象中,如果有一个Promise被拒绝,会发生什么?
458 108
|
4月前
|
JavaScript Java 关系型数据库
基于springboot的高校科研管理系统
本文设计并实现了一套基于Java、Spring Boot与MySQL的高校科研管理系统,聚焦纵向项目全流程管理。系统涵盖立项、中期检查、结项及经费管理,结合Vue.js构建友好界面,提升管理效率与数据安全性,推动高校科研管理智能化发展。
|
9月前
|
机器人 API 数据安全/隐私保护
微博评论脚本, 新浪微博自动评论机器人,autojs工具开发
该机器人包含登录验证、内容识别、智能回复和频率控制功能,使用AutoJS的控件操作API实现自动化。
|
9月前
|
存储 JSON 数据可视化
自动发微博工具,定时发微博脚本插件,AUTOJS开源版
Auto.js的微博定时发布插件完整实现,包含多线程调度、异常处理和UI交互模块,包含两个核心模块
豆瓣贴吧顶贴脚本,24小时多账号回复评论插件,贴吧自动顶贴软件【autojs】
该实现包含三个核心模块,主模块实现自动顶贴流程,配置模块支持外部配置加载,异常处理模块保障
|
9月前
|
存储 前端开发 安全
病历单生成器在线制作,病历单生成器app,HTML+CSS+JS恶搞工具
本项目为医疗病历模拟生成器,旨在为医学教学和软件开发测试提供数据支持,严格遵守《医疗机构病历管理规定》。
|
9月前
|
前端开发 JavaScript
医院报告单p图软件,诊断报告p图, 在线制作仿真病历【js框架】
完整的仿真病历生成系统。以下是使用HTML、CSS和JavaScript实现的完整代码,包含表单输入、样式设计和病历生成功能
|
9月前
|
前端开发 JavaScript 容器
在线制作仿真病历, 病例制作app生成器, 住院证明电子版【js+css+html娱乐必备】
纯前端实现的住院证明电子版生成器,仅供娱乐使用。包含完整的HTML结构、CSS样式和JavaScript交互功能
|
9月前
|
存储 Java
在线制作仿真病历, 病例制作app生成器, 住院证明电子版【娱乐版本】
这个Java项目实现了医院诊断单的生成功能,包含三个主要类:MedicalReportGenerator是核心类,负责生成诊

热门文章

最新文章