• 大小: 12.72MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-05
  • 语言: C#
  • 标签: HEIC  JPG  

资源简介

一款用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个文件信息

评论

共有 条评论