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());}}
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/79698.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/79698.shtml
英文地址,請注明出處:http://en.pswp.cn/web/79698.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

LlamaIndex 第八篇 MilvusVectorStore

本指南演示了如何使用 LlamaIndex 和 Milvus 構建一個檢索增強生成&#xff08;RAG&#xff09;系統。 RAG 系統將檢索系統與生成模型相結合&#xff0c;根據給定的提示生成新的文本。該系統首先使用 Milvus 等向量相似性搜索引擎從語料庫中檢索相關文檔&#xff0c;然后使用生…

淺聊一下數據庫的索引優化

背景 這里的索引說的是關系數據庫&#xff08;MSSQL&#xff09;中的索引。 本篇不是純技術性的內容&#xff0c;只是聊一次性能調優的經歷&#xff0c;包含到一些粗淺的實現和驗證手段&#xff0c;所以&#xff0c;大神忽略即可。 額…對了&#xff0c;筆者對數據庫的優化手段…

【android bluetooth 框架分析 02】【Module詳解 7】【VendorSpecificEventManager 模塊介紹】

1. 背景 我們在 gd_shim_module 介紹章節中&#xff0c;看到 我們將 VendorSpecificEventManager 模塊加入到了 modules 中。 // system/main/shim/stack.cc modules.add<hci::VendorSpecificEventManager>();在 ModuleRegistry::Start 函數中我們對 加入的所有 module…

小剛說C語言刷題—1080質因子

1.題目描述 任意輸入一正整數 N &#xff0c;求出它的所有質因子。如&#xff1a;10&#xff1d;25&#xff0c;20&#xff1d;225。 輸入 輸入只有一行&#xff0c;包括 11個整數 n (1≤n≤32768) 輸出 輸出若干行&#xff0c;按從小到大的順序給出這個數的所有質因子&am…

C語言中的宏

1.防止頭文件重復包含 1.#pragma once #pragma once 是一個編譯器指令&#xff0c;用于防止頭文件被重復包含。它的核心作用是通過簡單語法替代傳統的頭文件保護宏&#xff08;#ifndef/#define/#endif&#xff09;&#xff0c;提升代碼簡潔性和可維護性。 作用詳解 防止重復…

MapReduce 模型

?引言? MapReduce 是分布式計算領域的里程碑式模型&#xff0c;由 Google 在 2004 年論文中首次提出&#xff0c;旨在簡化海量數據處理的復雜性。其核心思想是通過函數式編程的 ?Map? &#xff08;映射&#xff09;和 ?Reduce? &#xff08;歸約&#xff09;階段&#x…

Linux文件編程——標準庫函數fopen、fread、fwrite等函數

1. fopen — 打開文件 函數原型&#xff1a; FILE *fopen(const char *filename, const char *mode);參數&#xff1a; filename&#xff1a;要打開的文件名&#xff0c;可以是相對路徑或絕對路徑。 mode&#xff1a;文件打開模式&#xff0c;表示文件的操作方式&#xff08…

從 Git 到 GitHub - 使用 Git 進行版本控制 - Git 常用命令

希望本貼能從零開始帶您一起學習如何使用 Git 進行版本控制&#xff0c;并結合遠程倉庫 GitHub。這會是一個循序漸進的指南&#xff0c;我們開始吧&#xff01; 學習 Git 和 GitHub 的路線圖&#xff1a; 理解核心概念&#xff1a;什么是版本控制&#xff1f;Git 是什么&…

2025.05.11拼多多機考真題算法崗-第四題

?? 點擊直達筆試專欄 ??《大廠筆試突圍》 ?? 春秋招筆試突圍在線OJ ?? 筆試突圍OJ 04. 記憶碎片重組 問題描述 盧小姐正在開發一款名為"記憶碎片"的游戲,玩家需要分析混亂的記憶數據,推測出形成這些記憶的原始序列。游戲中,記憶數據存儲在一個特殊的數…

Android Exoplayer多路不同時長音視頻混合播放

在上一篇Android Exoplayer 實現多個音視頻文件混合播放以及音軌切換中我們提到一個問題&#xff0c;如果視頻和音頻時長不一致&#xff0c;特別是想混合多個音頻和多個視頻時就會出問題&#xff0c;無法播放。報錯如下&#xff1a; E/ExoPlayerImplInternal(11191): Playback…

Datawhale PyPOTS時間序列5月第1次筆記

課程原地址&#xff1a; https://github.com/WenjieDu/PyPOTS&#xff08;Package地址&#xff09; https://github.com/WenjieDu/BrewPOTS/tree/datawhale/202505_datawhale&#xff08;Tutorial地址&#xff09; 2.1 PyPOTS簡介 PyPOTS 是一個專為處理部分觀測時間序列&a…

網安學途—流量分析 attack.pcap

attack.pacp 使用Wireshark查看并分析虛擬機windows 7桌面下的attack.pcapng數據包文件&#xff0c;通過分析數據包attack.pcapng找出黑客的IP地址&#xff0c;并將黑客的IP地址作為FLAG &#xff08;形式&#xff1a;[IP地址]&#xff09;提交&#xff1a; 過濾器篩選&#x…

【大模型】DeepResearcher:通用智能體通過強化學習探索優化

DeepResearcher&#xff1a;通過強化學習在真實環境中擴展深度研究 一、引言二、技術原理&#xff08;一&#xff09;強化學習與深度研究代理&#xff08;二&#xff09;認知行為的出現&#xff08;三&#xff09;模型架構 三、實戰運行方式&#xff08;一&#xff09;環境搭建…

go語言實現IP歸屬地查詢

效果: 實現代碼main.go package mainimport ("encoding/json""fmt""io/ioutil""net/http""os" )type AreaData struct {Continent string json:"continent"Country string json:"country"ZipCode …

基于STM32、HAL庫的SGTL5000XNLA3R2音頻接口芯片驅動程序設計

一、簡介: SGTL5000XNLA3R2 是 Cirrus Logic 推出的高性能、低功耗音頻編解碼器,專為便攜式和電池供電設備設計。它集成了立體聲 ADC、DAC、麥克風前置放大器、耳機放大器和數字信號處理功能,支持 I2S/PCM 音頻接口和 I2C 控制接口,非常適合與 STM32 微控制器配合使用。 二…

window 顯示驅動開發-報告圖形內存(一)

計算圖形內存 在 VidMm 能夠向客戶端報告準確的帳戶之前&#xff0c;它必須首先計算圖形內存的總量。 VidMm 使用以下內存類型和公式來計算圖形內存&#xff1a; 系統總內存 此值是操作系統可訪問的系統內存總量。 BIOS 分配的內存不會出現在此數字中。 例如&#xff0c;一臺…

[FA1C4] 博客鏈接

Blog Link 博客已經從 CSDN 轉移 高情商&#xff1a;博客是給人看的 低情商&#xff1a;CSDN 已經爛了根本不能看 鏈接: https://fa1c4.github.io/

python通過curl訪問deepseek的API調用案例

廢話少說&#xff0c;開干&#xff01; API申請和充值 下面是deepeek的API網站 https://platform.deepseek.com/ 進去先注冊&#xff0c;是不是手機賬號密碼都不重要&#xff0c;都一樣&#xff0c;完事充值打米&#xff0c;主要是打米后左側API Keys里面創建一個API Keys&am…

【計算機視覺】OpenCV項目實戰:基于face_recognition庫的實時人臉識別系統深度解析

基于face_recognition庫的實時人臉識別系統深度解析 1. 項目概述2. 技術原理與算法設計2.1 人臉檢測模塊2.2 特征編碼2.3 相似度計算 3. 實戰部署指南3.1 環境配置3.2 數據準備3.3 實時識別流程 4. 常見問題與解決方案4.1 dlib安裝失敗4.2 人臉檢測性能差4.3 誤識別率高 5. 關鍵…

第6章: SEO與交互指標

第6章: SEO與交互指標 在當今的SEO環境中&#xff0c;Google越來越重視用戶交互指標&#xff0c;如頁面停留時長、交互性能等。本章將深入探討如何優化網頁速度和用戶交互體驗&#xff0c;以提升SEO效果和用戶滿意度。 1. Google的新時代SEO指標 隨著互聯網技術的發展&#xff…