医院证明图片制作生成工具,病假条证明图片生成器, 医院报告单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;
}

}

相关文章
|
5月前
|
前端开发 JavaScript
医院证明p图软件在线制作,医院缴费单p图一键生成,网页端实现这个效果【仅供学习】
完整的医院缴费单生成器实现,包含HTML、CSS和JS代码,支持表单填写、预览和PDF导出功能。当然仅供学习,仅供学习
|
3月前
|
前端开发
Promise.all()方法接收的可迭代对象中,如果有一个Promise被拒绝,会发生什么?
Promise.all()方法接收的可迭代对象中,如果有一个Promise被拒绝,会发生什么?
263 108
|
4月前
|
数据安全/隐私保护 计算机视觉 iOS开发
拼多多订单截图生成器,拼多多订单p图软件,python版本
这段代码实现了一个完整的拼多多订单截图生成器,包含了订单数据生成、图像处理和二维码生成等功能
|
5月前
|
存储 前端开发 安全
病历单生成器在线制作,病历单生成器app,HTML+CSS+JS恶搞工具
本项目为医疗病历模拟生成器,旨在为医学教学和软件开发测试提供数据支持,严格遵守《医疗机构病历管理规定》。
|
5月前
|
前端开发 JavaScript
医院报告单p图软件,诊断报告p图, 在线制作仿真病历【js框架】
完整的仿真病历生成系统。以下是使用HTML、CSS和JavaScript实现的完整代码,包含表单输入、样式设计和病历生成功能
|
5月前
|
前端开发 容器
处方单图片生成器, 处方单在线制作免费,js+css+html恶搞神器
这是一个电子处方模拟生成系统,使用html2canvas库实现图片导出功能。系统生成的处方单包含多重防伪标识,并明确标注为模拟数据,仅供学习
|
3月前
|
存储 人工智能 安全
阿里云服务器热门配置2核4G与4核8G配置最新收费标准、活动价格及实例选择参考
阿里云服务器2核4G与4核8G配置是众多个人开发者、中小企业及初创企业选择云服务器配置时的热门配置。现在企业用户购买通用算力型u1实例2核4G5M带宽80G ESSD Entry云盘特惠价199元1年,个人用户则是531.79元1年起,4核8G配置价格目前通用算力型u1实例,4核8G活动价格955.58元1年起。本文将为大家解析这两款热门配置的实例规格、价格策略及适用场景,以供选择参考。
|
5月前
|
前端开发 JavaScript 容器
制作b超单生成器, 假怀孕b超单图片制作, p图医院证明【css+html+js装逼恶搞神器】
本资源提供一个适合用于熟人之间恶搞的工具,效果逼真,仅供学习参考与娱乐。包含前端技术学习要点:语义化布局、响应式设计、Flexbox、图片自适应
|
5月前
|
存储 Java
在线制作仿真病历, 病例制作app生成器, 住院证明电子版【娱乐版本】
这个Java项目实现了医院诊断单的生成功能,包含三个主要类:MedicalReportGenerator是核心类,负责生成诊
|
5月前
|
前端开发 JavaScript 容器
在线制作仿真病历, 病例制作app生成器, 住院证明电子版【js+css+html娱乐必备】
纯前端实现的住院证明电子版生成器,仅供娱乐使用。包含完整的HTML结构、CSS样式和JavaScript交互功能