当前位置: 首页 > article >正文

JPG与PDF格式转换器

 该插件可实现JPG与PDF格式的互转。

 

MainForm.Designer.cs

using System.Windows.Forms;
namespace JpgToPdfConverter
{partial class MainForm{private System.ComponentModel.IContainer components = null;protected override void Dispose(bool disposing){if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);}#region Windows Form Designer generated codeprivate void InitializeComponent(){this.btnSelectJpgFiles = new System.Windows.Forms.Button();this.lstJpgFiles = new System.Windows.Forms.ListBox();this.btnConvertJpgToPdf = new System.Windows.Forms.Button();this.lblJpgStatus = new System.Windows.Forms.Label();this.btnClearJpg = new System.Windows.Forms.Button();this.btnSelectPdfFiles = new System.Windows.Forms.Button();this.lstPdfFiles = new System.Windows.Forms.ListBox();this.btnConvertPdfToJpg = new System.Windows.Forms.Button();this.lblPdfStatus = new System.Windows.Forms.Label();this.btnClearPdf = new System.Windows.Forms.Button();this.tabControl1 = new System.Windows.Forms.TabControl();this.tabPageJpgToPdf = new System.Windows.Forms.TabPage();this.tabPagePdfToJpg = new System.Windows.Forms.TabPage();this.label1 = new System.Windows.Forms.Label();this.nudDpi = new System.Windows.Forms.NumericUpDown();this.tabControl1.SuspendLayout();this.tabPageJpgToPdf.SuspendLayout();this.tabPagePdfToJpg.SuspendLayout();((System.ComponentModel.ISupportInitialize)(this.nudDpi)).BeginInit();this.SuspendLayout();// // btnSelectJpgFiles// this.btnSelectJpgFiles.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnSelectJpgFiles.Location = new System.Drawing.Point(5, 5);this.btnSelectJpgFiles.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.btnSelectJpgFiles.Name = "btnSelectJpgFiles";this.btnSelectJpgFiles.Size = new System.Drawing.Size(111, 24);this.btnSelectJpgFiles.TabIndex = 0;this.btnSelectJpgFiles.Text = "选择JPG文件";this.btnSelectJpgFiles.UseVisualStyleBackColor = true;this.btnSelectJpgFiles.Click += new System.EventHandler(this.btnSelectJpgFiles_Click);// // lstJpgFiles// this.lstJpgFiles.FormattingEnabled = true;this.lstJpgFiles.HorizontalScrollbar = true;this.lstJpgFiles.ItemHeight = 12;this.lstJpgFiles.Location = new System.Drawing.Point(5, 34);this.lstJpgFiles.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.lstJpgFiles.Name = "lstJpgFiles";this.lstJpgFiles.Size = new System.Drawing.Size(388, 172);this.lstJpgFiles.TabIndex = 1;// // btnConvertJpgToPdf// this.btnConvertJpgToPdf.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnConvertJpgToPdf.Location = new System.Drawing.Point(5, 210);this.btnConvertJpgToPdf.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.btnConvertJpgToPdf.Name = "btnConvertJpgToPdf";this.btnConvertJpgToPdf.Size = new System.Drawing.Size(111, 24);this.btnConvertJpgToPdf.TabIndex = 2;this.btnConvertJpgToPdf.Text = "转换为PDF";this.btnConvertJpgToPdf.UseVisualStyleBackColor = true;this.btnConvertJpgToPdf.Click += new System.EventHandler(this.btnConvertJpgToPdf_Click);// // lblJpgStatus// this.lblJpgStatus.AutoSize = true;this.lblJpgStatus.Location = new System.Drawing.Point(122, 218);this.lblJpgStatus.Name = "lblJpgStatus";this.lblJpgStatus.Size = new System.Drawing.Size(0, 12);this.lblJpgStatus.TabIndex = 3;// // btnClearJpg// this.btnClearJpg.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnClearJpg.Location = new System.Drawing.Point(281, 210);this.btnClearJpg.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.btnClearJpg.Name = "btnClearJpg";this.btnClearJpg.Size = new System.Drawing.Size(111, 24);this.btnClearJpg.TabIndex = 4;this.btnClearJpg.Text = "清除列表";this.btnClearJpg.UseVisualStyleBackColor = true;this.btnClearJpg.Click += new System.EventHandler(this.btnClearJpg_Click);// // btnSelectPdfFiles// this.btnSelectPdfFiles.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnSelectPdfFiles.Location = new System.Drawing.Point(5, 5);this.btnSelectPdfFiles.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.btnSelectPdfFiles.Name = "btnSelectPdfFiles";this.btnSelectPdfFiles.Size = new System.Drawing.Size(111, 24);this.btnSelectPdfFiles.TabIndex = 5;this.btnSelectPdfFiles.Text = "选择PDF文件";this.btnSelectPdfFiles.UseVisualStyleBackColor = true;this.btnSelectPdfFiles.Click += new System.EventHandler(this.btnSelectPdfFiles_Click);// // lstPdfFiles// this.lstPdfFiles.FormattingEnabled = true;this.lstPdfFiles.HorizontalScrollbar = true;this.lstPdfFiles.ItemHeight = 12;this.lstPdfFiles.Location = new System.Drawing.Point(5, 34);this.lstPdfFiles.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.lstPdfFiles.Name = "lstPdfFiles";this.lstPdfFiles.Size = new System.Drawing.Size(388, 136);this.lstPdfFiles.TabIndex = 6;// // btnConvertPdfToJpg// this.btnConvertPdfToJpg.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnConvertPdfToJpg.Location = new System.Drawing.Point(5, 210);this.btnConvertPdfToJpg.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.btnConvertPdfToJpg.Name = "btnConvertPdfToJpg";this.btnConvertPdfToJpg.Size = new System.Drawing.Size(111, 24);this.btnConvertPdfToJpg.TabIndex = 7;this.btnConvertPdfToJpg.Text = "转换为JPG";this.btnConvertPdfToJpg.UseVisualStyleBackColor = true;this.btnConvertPdfToJpg.Click += new System.EventHandler(this.btnConvertPdfToJpg_Click);// // lblPdfStatus// this.lblPdfStatus.AutoSize = true;this.lblPdfStatus.Location = new System.Drawing.Point(122, 218);this.lblPdfStatus.Name = "lblPdfStatus";this.lblPdfStatus.Size = new System.Drawing.Size(0, 12);this.lblPdfStatus.TabIndex = 8;// // btnClearPdf// this.btnClearPdf.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.btnClearPdf.Location = new System.Drawing.Point(281, 210);this.btnClearPdf.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.btnClearPdf.Name = "btnClearPdf";this.btnClearPdf.Size = new System.Drawing.Size(111, 24);this.btnClearPdf.TabIndex = 9;this.btnClearPdf.Text = "清除列表";this.btnClearPdf.UseVisualStyleBackColor = true;this.btnClearPdf.Click += new System.EventHandler(this.btnClearPdf_Click);// // tabControl1// this.tabControl1.Controls.Add(this.tabPageJpgToPdf);this.tabControl1.Controls.Add(this.tabPagePdfToJpg);this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;this.tabControl1.Location = new System.Drawing.Point(0, 0);this.tabControl1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.tabControl1.Name = "tabControl1";this.tabControl1.SelectedIndex = 0;this.tabControl1.Size = new System.Drawing.Size(422, 277);this.tabControl1.TabIndex = 10;// // tabPageJpgToPdf// this.tabPageJpgToPdf.Controls.Add(this.btnSelectJpgFiles);this.tabPageJpgToPdf.Controls.Add(this.btnClearJpg);this.tabPageJpgToPdf.Controls.Add(this.lstJpgFiles);this.tabPageJpgToPdf.Controls.Add(this.lblJpgStatus);this.tabPageJpgToPdf.Controls.Add(this.btnConvertJpgToPdf);this.tabPageJpgToPdf.Location = new System.Drawing.Point(4, 22);this.tabPageJpgToPdf.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.tabPageJpgToPdf.Name = "tabPageJpgToPdf";this.tabPageJpgToPdf.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);this.tabPageJpgToPdf.Size = new System.Drawing.Size(414, 251);this.tabPageJpgToPdf.TabIndex = 0;this.tabPageJpgToPdf.Text = "JPG转PDF";this.tabPageJpgToPdf.UseVisualStyleBackColor = true;// // tabPagePdfToJpg// this.tabPagePdfToJpg.Controls.Add(this.label1);this.tabPagePdfToJpg.Controls.Add(this.nudDpi);this.tabPagePdfToJpg.Controls.Add(this.btnSelectPdfFiles);this.tabPagePdfToJpg.Controls.Add(this.lstPdfFiles);this.tabPagePdfToJpg.Controls.Add(this.btnConvertPdfToJpg);this.tabPagePdfToJpg.Controls.Add(this.btnClearPdf);this.tabPagePdfToJpg.Controls.Add(this.lblPdfStatus);this.tabPagePdfToJpg.Location = new System.Drawing.Point(4, 22);this.tabPagePdfToJpg.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.tabPagePdfToJpg.Name = "tabPagePdfToJpg";this.tabPagePdfToJpg.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);this.tabPagePdfToJpg.Size = new System.Drawing.Size(402, 241);this.tabPagePdfToJpg.TabIndex = 1;this.tabPagePdfToJpg.Text = "PDF转JPG";this.tabPagePdfToJpg.UseVisualStyleBackColor = true;// // label1// this.label1.AutoSize = true;this.label1.Location = new System.Drawing.Point(213, 180);this.label1.Name = "label1";this.label1.Size = new System.Drawing.Size(101, 12);this.label1.TabIndex = 11;this.label1.Text = "输出图片DPI设置:";// // nudDpi// this.nudDpi.Location = new System.Drawing.Point(318, 176);this.nudDpi.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.nudDpi.Maximum = new decimal(new int[] {600,0,0,0});this.nudDpi.Minimum = new decimal(new int[] {72,0,0,0});this.nudDpi.Name = "nudDpi";this.nudDpi.Size = new System.Drawing.Size(74, 21);this.nudDpi.TabIndex = 10;this.nudDpi.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;this.nudDpi.Value = new decimal(new int[] {300,0,0,0});// // MainForm// this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;this.ClientSize = new System.Drawing.Size(422, 277);this.Controls.Add(this.tabControl1);this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);this.MaximizeBox = false;this.MinimizeBox = false;this.Name = "MainForm";this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;this.Text = "JPG/PDF转换器  作者: 山水(qq443440204)";this.tabControl1.ResumeLayout(false);this.tabPageJpgToPdf.ResumeLayout(false);this.tabPageJpgToPdf.PerformLayout();this.tabPagePdfToJpg.ResumeLayout(false);this.tabPagePdfToJpg.PerformLayout();((System.ComponentModel.ISupportInitialize)(this.nudDpi)).EndInit();this.ResumeLayout(false);}#endregionprivate System.Windows.Forms.Button btnSelectJpgFiles;private System.Windows.Forms.ListBox lstJpgFiles;private System.Windows.Forms.Button btnConvertJpgToPdf;private System.Windows.Forms.Label lblJpgStatus;private System.Windows.Forms.Button btnClearJpg;private System.Windows.Forms.Button btnSelectPdfFiles;private System.Windows.Forms.ListBox lstPdfFiles;private System.Windows.Forms.Button btnConvertPdfToJpg;private System.Windows.Forms.Label lblPdfStatus;private System.Windows.Forms.Button btnClearPdf;private System.Windows.Forms.TabControl tabControl1;private System.Windows.Forms.TabPage tabPageJpgToPdf;private System.Windows.Forms.TabPage tabPagePdfToJpg;private System.Windows.Forms.NumericUpDown nudDpi;private System.Windows.Forms.Label label1;}
}

MainForm.cs

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using static System.Net.Mime.MediaTypeNames;
using Image = System.Drawing.Image;namespace JpgToPdfConverter
{public partial class MainForm : Form{// 存储选择的文件路径private List<string> selectedJpgFiles = new List<string>();private List<string> selectedPdfFiles = new List<string>();public MainForm(){InitializeComponent();}#region JPG转PDF功能// 选择JPG文件按钮点击事件private void btnSelectJpgFiles_Click(object sender, EventArgs e){using (OpenFileDialog openFileDialog = new OpenFileDialog()){openFileDialog.Filter = "JPG文件 (*.jpg;*.jpeg)|*.jpg;*.jpeg|所有文件 (*.*)|*.*";openFileDialog.Multiselect = true;openFileDialog.Title = "选择JPG文件";if (openFileDialog.ShowDialog() == DialogResult.OK){selectedJpgFiles.AddRange(openFileDialog.FileNames);UpdateJpgFileList();}}}// 更新JPG文件列表显示private void UpdateJpgFileList(){lstJpgFiles.Items.Clear();foreach (string file in selectedJpgFiles){lstJpgFiles.Items.Add(Path.GetFileName(file));}UpdateJpgStatus($"已选择 {selectedJpgFiles.Count} 个文件");}// 更新JPG转换状态private void UpdateJpgStatus(string message){lblJpgStatus.Text = message;}// 清除JPG文件列表private void btnClearJpg_Click(object sender, EventArgs e){selectedJpgFiles.Clear();UpdateJpgFileList();}// JPG转PDF按钮点击事件private void btnConvertJpgToPdf_Click(object sender, EventArgs e){if (selectedJpgFiles.Count == 0){MessageBox.Show("请先选择JPG文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);return;}using (SaveFileDialog saveFileDialog = new SaveFileDialog()){saveFileDialog.Filter = "PDF文件 (*.pdf)|*.pdf|所有文件 (*.*)|*.*";saveFileDialog.Title = "保存PDF文件";saveFileDialog.FileName = "转换结果.pdf";if (saveFileDialog.ShowDialog() == DialogResult.OK){try{UpdateJpgStatus("正在转换...");Cursor = Cursors.WaitCursor;ConvertJpgToPdf(selectedJpgFiles, saveFileDialog.FileName);UpdateJpgStatus("转换完成!");MessageBox.Show($"PDF文件已保存至:{saveFileDialog.FileName}", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);}catch (Exception ex){UpdateJpgStatus("转换失败!");MessageBox.Show($"转换过程中发生错误:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);}finally{Cursor = Cursors.Default;}}}}// JPG转PDF核心方法//private void ConvertJpgToPdf(List<string> jpgFiles, string pdfPath)//{//    using (PdfDocument pdf = new PdfDocument())//    {//        foreach (string jpgFile in jpgFiles)//        {//            try//            {//                // 获取图像尺寸//                using (Image image = Image.FromFile(jpgFile))//                {//                    PdfPage page = pdf.AddPage();//                    page.Width = image.Width;//                    page.Height = image.Height;//                }//                // 从文件加载图像到PDF//                PdfPage pdfPage = pdf.Pages[pdf.Pages.Count - 1];//                XGraphics gfx = XGraphics.FromPdfPage(pdfPage);//                XImage xImage = XImage.FromFile(jpgFile);//                gfx.DrawImage(xImage, 0, 0);//            }//            catch (Exception ex)//            {//                MessageBox.Show($"处理文件 {Path.GetFileName(jpgFile)} 时出错:{ex.Message}", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);//            }//        }//        pdf.Save(pdfPath);//    }//}#endregionprivate void ConvertJpgToPdf(List<string> jpgFiles, string pdfPath){using (PdfDocument pdf = new PdfDocument()){foreach (string jpgFile in jpgFiles){using (Image image = Image.FromFile(jpgFile)){PdfPage page = pdf.AddPage();// 直接按像素数设置页面尺寸(1点=1像素)page.Width = image.Width;page.Height = image.Height;XGraphics gfx = XGraphics.FromPdfPage(page);XImage xImage = XImage.FromFile(jpgFile);gfx.DrawImage(xImage, 0, 0, page.Width, page.Height);}}pdf.Save(pdfPath);}}#region PDF转JPG功能// 选择PDF文件按钮点击事件private void btnSelectPdfFiles_Click(object sender, EventArgs e){using (OpenFileDialog openFileDialog = new OpenFileDialog()){openFileDialog.Filter = "PDF文件 (*.pdf)|*.pdf|所有文件 (*.*)|*.*";openFileDialog.Multiselect = true;openFileDialog.Title = "选择PDF文件";if (openFileDialog.ShowDialog() == DialogResult.OK){selectedPdfFiles.AddRange(openFileDialog.FileNames);UpdatePdfFileList();}}}// 更新PDF文件列表显示private void UpdatePdfFileList(){lstPdfFiles.Items.Clear();foreach (string file in selectedPdfFiles){lstPdfFiles.Items.Add(Path.GetFileName(file));}UpdatePdfStatus($"已选择 {selectedPdfFiles.Count} 个文件");}// 更新PDF转换状态private void UpdatePdfStatus(string message){lblPdfStatus.Text = message;}// 清除PDF文件列表private void btnClearPdf_Click(object sender, EventArgs e){selectedPdfFiles.Clear();UpdatePdfFileList();}// PDF转JPG按钮点击事件private void btnConvertPdfToJpg_Click(object sender, EventArgs e){if (selectedPdfFiles.Count == 0){MessageBox.Show("请先选择PDF文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);return;}using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()){folderBrowserDialog.Description = "选择保存JPG文件的文件夹";if (folderBrowserDialog.ShowDialog() == DialogResult.OK){try{UpdatePdfStatus("正在转换...");Cursor = Cursors.WaitCursor;int dpi = (int)nudDpi.Value;ConvertPdfToJpg(selectedPdfFiles, folderBrowserDialog.SelectedPath, dpi);UpdatePdfStatus("转换完成!");MessageBox.Show($"JPG文件已保存至:{folderBrowserDialog.SelectedPath}", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);}catch (Exception ex){UpdatePdfStatus("转换失败!");MessageBox.Show($"转换过程中发生错误:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);}finally{Cursor = Cursors.Default;}}}}// PDF转JPG核心方法private void ConvertPdfToJpg(List<string> pdfFiles, string outputFolder, int dpi){foreach (string pdfFile in pdfFiles){try{string fileNameWithoutExt = Path.GetFileNameWithoutExtension(pdfFile);string fileOutputFolder = Path.Combine(outputFolder, fileNameWithoutExt);// 为每个PDF创建单独的文件夹Directory.CreateDirectory(fileOutputFolder);using (PdfiumViewer.PdfDocument document = PdfiumViewer.PdfDocument.Load(pdfFile)){int pageCount = document.PageCount;for (int i = 0; i < pageCount; i++){string outputPath = Path.Combine(fileOutputFolder, $"{fileNameWithoutExt}_第{i + 1}页.jpg");using (Bitmap image = (Bitmap)document.Render(i, dpi, dpi, false)){image.Save(outputPath, System.Drawing.Imaging.ImageFormat.Jpeg);}}}}catch (Exception ex){MessageBox.Show($"处理文件 {Path.GetFileName(pdfFile)} 时出错:{ex.Message}", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);return;}}}#endregion}
}

Program.cs

using System;
using System.Windows.Forms;namespace JpgToPdfConverter
{static class Program{[STAThread]static void Main(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new MainForm());}}
}

相关文章:

JPG与PDF格式转换器

该插件可实现JPG与PDF格式的互转。 MainForm.Designer.cs using System.Windows.Forms; namespace JpgToPdfConverter {partial class MainForm{private System.ComponentModel.IContainer components null;protected override void Dispose(bool disposing){if (disposing &…...

如何在 CentOS 7 虚拟机上配置静态 IP 地址并保持重启后 SSH 连接

在使用 CentOS 7 的虚拟机时&#xff0c;我们通常需要配置静态 IP 地址&#xff0c;以确保在每次虚拟机重启后能够通过 SSH 连接。本文将介绍如何在 CentOS 7 系统中配置静态 IP 地址&#xff0c;并确保配置在系统重启后依然生效。 步骤 1&#xff1a;检查虚拟机网络接口 首先…...

手搓传染病模型(SEIARW)

在传染病传播的研究中&#xff0c;水传播途径是一个重要的考量因素。SEAIRW 模型&#xff08;易感者 S - 暴露者 E - 感染者 I - 无症状感染者 A - 康复者 R - 水中病原体 W&#xff09;综合考虑了人与人接触传播以及水传播的双重机制&#xff0c;为分析此类传染病提供了全面的…...

【Mac 从 0 到 1 保姆级配置教程 15】- Python 环境一键安装与配置,就是这么的丝滑

文章目录 前言安装 Python 环境VSCode 配置Python 环境NeoVim 配置 Python 环境&#xff08;选看&#xff09;1. Python LSP 配置2. 打开 python 语言支持 最后参考资料系列教程 Mac 从 0 到 1 保姆级配置教程目录&#xff0c;点击即可跳转对应文章&#xff1a; 【Mac 从 0 到 …...

【递归、搜索与回溯】专题一:递归(二)

&#x1f4dd;前言说明&#xff1a; 本专栏主要记录本人递归&#xff0c;搜索与回溯算法的学习以及LeetCode刷题记录&#xff0c;按专题划分每题主要记录&#xff1a;&#xff08;1&#xff09;本人解法 本人屎山代码&#xff1b;&#xff08;2&#xff09;优质解法 优质代码…...

Spark缓存-cache

一、RDD持久化 1.什么时候该使用持久化&#xff08;缓存&#xff09; 2. RDD cache & persist 缓存 3. RDD CheckPoint 检查点 4. cache & persist & checkpoint 的特点和区别 特点 区别 二、cache & persist 的持久化级别及策略选择 Spark的几种持久化…...

记录算法笔记(2025.5.13)二叉树的最大深度

给定一个二叉树 root &#xff0c;返回其最大深度。 二叉树的 最大深度 是指从根节点到最远叶子节点的最长路径上的节点数。 示例 1&#xff1a; 输入&#xff1a;root [3,9,20,null,null,15,7] 输出&#xff1a;3 示例 2&#xff1a; 输入&#xff1a;root [1,null,2] …...

【Linux】简单设计libc库

&#x1f4dd;前言&#xff1a; 经过之间两篇文章&#xff0c;【Linux】基础IO&#xff08;一&#xff09;和【Linux】基础IO&#xff08;二&#xff09;的学些&#xff0c;我们对文件的基础IO已经有了一定的理解。 这篇文章我们来简单设计一下libc库&#xff0c;来复习一下文…...

milvus+flask山寨《从零构建向量数据库》第7章case2

继续流水账完这本书&#xff0c;这个案例是打造文字形式的个人知识库雏形。 create_context_db: # Milvus Setup Arguments COLLECTION_NAME text_content_search DIMENSION 2048 MILVUS_HOST "localhost" MILVUS_PORT "19530"# Inference Arguments…...

岩土拉压试验机

岩土拉压试验机&#xff0c;专门用于检测黄土的在压缩、拉伸状态下的力学特性试验。主要由试验机主机、控制系统、控制软件三部分部分组成。 主要技术参数、配置如下&#xff1a; 主 要 技 术 指 标 及 参 数 最大试验力&#xff08;kN&#xff09; 5 试验精度等级 0.5级 …...

.Net HttpClient 使用准则

HttpClient 使用准则 System.Net.Http.HttpClient 类用于发送 HTTP 请求以及从 URI 所标识的资源接收 HTTP 响应。 HttpClient 实例是应用于该实例执行的所有请求的设置集合&#xff0c;每个实例使用自身的连接池&#xff0c;该池将其请求与其他请求隔离开来。 从 .NET Core …...

【Canda】常用命令+虚拟环境创建到选择

目录 一、conda常用命令 二、conda 环境 2.1 创建虚拟环境 2.2 conda环境切换 2.3 查看conda环境 2.4 删除某个conda环境 2.5 克隆环境 三、依赖包管理 3.1 安装命令 3.2 更新包 3.3 卸载包 3.4 查看环境中所有包 3.5 查看某个包的版本信息 3.6 搜索包 四、环境…...

Lighthouse Core Web Vitals 指标详解与优化指南

vLighthouse Core Web Vitals 指标详解与优化指南 一、Core Web Vitals 概述 Google 在 2020 年推出的 Core Web Vitals(核心网页指标)是衡量用户体验质量的关键指标集合,现已成为搜索引擎排名的重要因素。Lighthouse 作为 Google 官方的网页质量评估工具,提供了对这些指…...

Qt进阶开发:QTcpServer的详解

文章目录 一、QTcpServer 简介二、常用成员函数的使用三、信号函数的使用四、虚函数的使用五、连接多客户端-服务端示例一、QTcpServer 简介 QTcpServer 是 Qt 网络模块中的一个核心类,用于实现 基于 TCP 协议的服务端(Server),它负责监听端口、接收客户端连接请求,并通过…...

Leetcode 3544. Subtree Inversion Sum

Leetcode 3544. Subtree Inversion Sum 1. 解题思路2. 代码实现 题目链接&#xff1a;3544. Subtree Inversion Sum 1. 解题思路 这一题我的思路上就是一个动态规划的思路&#xff0c;因为原则上我们只需要遍历一下所有的状态即可&#xff0c;但是这样显然时间复杂度过高&am…...

物理:由基本粒子组成的个体能否提炼和重组?

个体差异源于基本粒子组合的复杂性与随机性,这一假设若成立,确实可能为生物医学带来革命性突破——但需要突破技术、理论与系统层级的多重壁垒。以下从科学逻辑与技术路径展开分析: 一、随机组合中的共性与稳定结构 1. 自然界的自组织规律 涌现性(Emergence):尽管粒子组…...

信息学奥赛一本通 1535:【例 1】数列操作

【题目链接】 ybt 1535&#xff1a;【例 1】数列操作 【题目考点】 1. 树状数组 【解题思路】 本题为树状数组模板题&#xff0c;维护区间和&#xff0c;进行单点修改&#xff0c;区间查询。 详细讲解见&#xff1a;洛谷 P3374 【模板】树状数组 1&#xff08;树状数组解法…...

【登录认证】JWT令牌

一、概述 JWT全称:**JSON Web Token **(https://jwt.io/)定义了一种简洁的、自包含的格式&#xff0c;用于通信双方以json数据格式安全的传输信息。组成: ①第一部分:Header(头)&#xff0c;记录令牌类型、签名算法等。例如: (“alg”:" HS256"," type":“…...

手撕算法(定制整理版2)

最长无重复子字符串 class Solution(object):def lengthOfLongestSubstring(self, s):""":type s: str:rtype: int"""if not s:return 0max_len 0tp []for a in s:while a in tp:del tp[0]tp.append(a)if len(tp) > max_len:max_len len(…...

python3:文件与异常

本来这篇教程是打算在base python数据类型之后出的&#xff0c;但是计划赶不上变化&#xff0c;反正最后都要融会贯通&#xff0c;今日有时间、今天遇到了类似的问题&#xff0c;就今天做这一模块的整理&#xff0c;顺序不是重点。 参考我的上一篇博客&#xff1a;https://blo…...

【兽医电子处方软件】佳易王宠物医院电子处方管理系统:宠物医院诊所用什么软件?一键导入配方模板软件程序实操教程 #操作简单 #宠物医院软件下载安装

一、概述 软件试用版资源文件下载方法&#xff1a; 【进入头像主页第一篇文章最后 卡片按钮 可点击了解详细资料 或左上角本博客主页 右侧按钮了解具体资料信息】 本实例以 佳易王宠物医院电子处方管理系统软件 为例说明&#xff0c;其他版本可参考本实例。试用版软…...

centos7.x下,使用宝塔进行主从复制的原理和实践

操作原理&#xff1a; 一、主库配置 1.修改 MySQL 配置文件 # 编辑主库配置文件&#xff08;路径根据实际系统可能不同&#xff09; vim /etc/my.cnf # 添加以下配置 [mysqld] server-id 1 # 唯一 ID&#xff0c;主库设置为 1 log-bin mysql-bin …...

langchain学习

无门槛免费申请OpenAI ChatGPT API搭建自己的ChatGPT聊天工具 https://nuowa.net/872 基本概念 LangChain 能解决大模型的两个痛点&#xff0c;包括模型接口复杂、输入长度受限离不开自己精心设计的模块。根据LangChain 的最新文档&#xff0c;目前在 LangChain 中一共有六大…...

从“听不懂”到“能对话”,声网AI让语音交互不再难用

人们谁懂啊&#xff01;做智能客服系统的真的被传统语音机器整怕了&#xff01;以前那些基于规则的 IVR 系统&#xff0c;“卡顿感” 拉满还总答非所问&#xff0c;用户说啥都像在对牛弹琴。不能打断、没有上下文、流程死板到离谱&#xff0c;动不动就来句 “请再说一遍”&…...

VSCode设置SSH免密登录

引言 2025年05月13日20:21:14 原来一直用的PyCharn来完成代码在远程服务器上的运行&#xff0c;但是PyCharm时不时同步代码会有问题。因此&#xff0c;尝试用VSCode来完成代码SSH远程运行。由于VSCode每次进行SSH连接的时候都要手动输入密码&#xff0c;为了解决这个问题在本…...

Windows Java gRPC 示例

gRPC是一个开源高性能远程过程调用(RPC)框架,因为这个框架最早是由Goolge开发的,这里的g 代表的也即是Google。 关于gRPC更多的概念介绍可以参考: gRPC 基本介绍 本篇快速介绍在Windows环境下使用 Java 语言如何实现 gRPC 的服务端和客户端调用。 1. 环境准备 JDK 21Ma…...

问题及解决02-处理后的图像在坐标轴外显示

一、问题 在使用matlab的appdesigner工具来设计界面&#xff0c;可以通过点击处理按钮来处理图像&#xff0c;并将处理后的图像显示在坐标轴上&#xff0c;但是图像超出了指定的坐标轴&#xff0c;即处理后的图像在坐标轴外显示。 问题图如下图所示。 原来的坐标轴如下图所…...

EasyX开发——绘制跟随鼠标移动的小球

游戏主循环&#xff1a; #include<graphics.h>int main() {initgraph(1280, 720);while (true){}return 0; } peekmessage函数&#xff1a;如果成功拉取到了消息&#xff0c;函数就会返回true&#xff0c;反之就会返回false 使用另外一个循环来不断地从消息队列当中拉取…...

【Qt开发】信号与槽

目录 1&#xff0c;信号与槽的介绍 2&#xff0c;信号与槽的运用 3&#xff0c;自定义信号 1&#xff0c;信号与槽的介绍 在Qt框架中&#xff0c;信号与槽机制是一种用于对象间通信的强大工具。它是在Qt中实现事件处理和回调函数的主要方法。 信号&#xff1a;窗口中&#x…...

APS排程系统(Advanced Planning and Scheduling,高级计划与排程系统)

APS排程系统&#xff08;Advanced Planning and Scheduling&#xff0c;高级计划与排程系统&#xff09;是一种基于供应链管理和约束理论的智能生产管理工具&#xff0c;旨在通过动态优化资源分配和生产流程&#xff0c;解决制造业中的复杂计划问题。以下是其核心要点解析&…...