資源簡介
一款用C#寫成的可以批量保質保量的轉換HEIC文件,可以查看HEIC文件,轉換HEIC文件為JGP文件。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Runtime.InteropServices;
using?System.IO;
using?System.Drawing.Imaging;
namespace?heic2jpg
{
????class?invoke_dll
????{
????????[DllImport(“HUD.dll“?CharSet?=?CharSet.Auto?CallingConvention?=?CallingConvention.Cdecl)]
????????private?unsafe?extern?static?void?heif2jpg(byte*?heif_bin?int?input_buffer_size?int?jpg_quality?byte*?ouput_buffer?int?output_buffer_size?byte*?temp_filename);
????????public?static?byte[]?read_heif(string?filename)
????????{
????????????FileStream?fs?=?null;
????????????try
????????????{
????????????????fs?=?new?FileStream(filename?FileMode.Open);
????????????????System.IO.BinaryReader?br?=?new?BinaryReader(fs);
????????????????byte[]?byte_array?=?br.ReadBytes((int)fs.Length);
????????????????fs.Close();
????????????????return?byte_array;
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????fs.Close();
????????????????throw?ex;
????????????}
????????}
????????public?static?unsafe?Image?invoke_heif_to_jpg(byte[]?heif_bin?int?jpg_quality?string?temp_filename)
????????{
????????????var?output_buffer?=?new?byte[heif_bin.Length?*?10];
????????????byte[]?temp_filename_byte_array?=?System.Text.Encoding.Default.GetBytes(temp_filename);
????????????fixed?(byte*?input?=?&heif_bin[0]?output?=?&output_buffer[0]?temp_filename_byte?=?&temp_filename_byte_array[0])
????????????{
????????????????heif2jpg(input?heif_bin.Length?jpg_quality?output?heif_bin.Length?*?10?temp_filename_byte);
????????????}
????????????return?Image.FromStream(new?MemoryStream(output_buffer));
????????}
????}??
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????var?heif_data?=?invoke_dll.read_heif(@“C:\Users\Administrator.PC-20161113KXWI\Desktop\Heic\IMG_0827.jpg“);
????????????invoke_dll.invoke_heif_to_jpg(heif_data?80?@“D:\2.jpgtmp“).Save(@“D:\3.jpg“?ImageFormat.Jpeg);
????????????Console.ReadLine();?
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-02-14?16:00??heic轉jpg源碼\
?????目錄???????????0??2019-02-14?16:00??heic轉jpg源碼\heic2?jpg\
?????文件????????2022??2018-03-02?17:26??heic轉jpg源碼\heic2?jpg\Form1.Designer.cs
?????文件????????2304??2018-03-02?17:41??heic轉jpg源碼\heic2?jpg\Form1.cs
?????文件????????5817??2018-03-02?17:26??heic轉jpg源碼\heic2?jpg\Form1.resx
?????文件?????????489??2018-03-02?17:26??heic轉jpg源碼\heic2?jpg\Program.cs
?????目錄???????????0??2019-02-14?16:00??heic轉jpg源碼\heic2?jpg\Properties\
?????文件????????1366??2018-03-02?17:26??heic轉jpg源碼\heic2?jpg\Properties\AssemblyInfo.cs
?????文件????????2868??2018-03-02?17:26??heic轉jpg源碼\heic2?jpg\Properties\Resources.Designer.cs
?????文件????????5612??2018-03-02?17:26??heic轉jpg源碼\heic2?jpg\Properties\Resources.resx
?????文件????????1095??2018-03-02?17:26??heic轉jpg源碼\heic2?jpg\Properties\Settings.Designer.cs
?????文件?????????249??2018-03-02?17:26??heic轉jpg源碼\heic2?jpg\Properties\Settings.settings
?????目錄???????????0??2019-02-14?16:00??heic轉jpg源碼\heic2?jpg\bin\
?????目錄???????????0??2019-02-14?16:00??heic轉jpg源碼\heic2?jpg\bin\Debug\
?????文件??????164352??2017-10-18?10:14??heic轉jpg源碼\heic2?jpg\bin\Debug\HEIF-Utility.exe
?????文件??????577536??2017-09-29?10:50??heic轉jpg源碼\heic2?jpg\bin\Debug\HUD.dll
?????文件???????????8??2019-02-14?16:00??heic轉jpg源碼\heic2?jpg\bin\Debug\MainWindowSize
?????文件?????1671337??2018-03-02?15:27??heic轉jpg源碼\heic2?jpg\bin\Debug\batch_temp0
?????文件?????1327163??2018-03-02?15:27??heic轉jpg源碼\heic2?jpg\bin\Debug\batch_temp1
?????文件?????????382??2018-03-02?16:07??heic轉jpg源碼\heic2?jpg\bin\Debug\heic.pl
?????文件????????9728??2018-03-02?17:36??heic轉jpg源碼\heic2?jpg\bin\Debug\heic2jpg.exe
?????文件???????26112??2018-03-02?17:36??heic轉jpg源碼\heic2?jpg\bin\Debug\heic2jpg.pdb
?????文件???????11600??2018-03-20?09:07??heic轉jpg源碼\heic2?jpg\bin\Debug\heic2jpg.vshost.exe
?????文件?????????490??2015-10-22?09:54??heic轉jpg源碼\heic2?jpg\bin\Debug\heic2jpg.vshost.exe.manifest
?????文件????17806336??2017-09-24?18:45??heic轉jpg源碼\heic2?jpg\bin\Debug\opencv_ffmpeg330_64.dll
?????文件?????5963264??2017-09-24?18:45??heic轉jpg源碼\heic2?jpg\bin\Debug\opencv_world330.dll
?????文件??????447276??2018-03-02?15:15??heic轉jpg源碼\heic2?jpg\bin\Debug\temp_bitstream.hevc
?????文件????????3724??2018-03-02?17:31??heic轉jpg源碼\heic2?jpg\heic2jpg.csproj
?????目錄???????????0??2019-02-14?16:00??heic轉jpg源碼\heic2?jpg\obj\
?????目錄???????????0??2019-02-14?16:00??heic轉jpg源碼\heic2?jpg\obj\x86\
?????目錄???????????0??2019-02-14?16:00??heic轉jpg源碼\heic2?jpg\obj\x86\Debug\
............此處省略11個文件信息
評論
共有 條評論