相关文章推荐
酒量小的椰子  ·  js ...·  1 年前    · 
鬼畜的番茄  ·  DMStar ...·  1 年前    · 

******************************点我下载@@@@@@@@@@@@@@@@@@@@

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace jpgTo16
    public partial class Form1 : Form
        public Form1()
            InitializeComponent();
        private void Form1_Load(object sender, EventArgs e)
            textBox1.Text = @"E:\D盘数据\draft\EleTVtest";
        private void button1_Click(object sender, EventArgs e)
            String[] fileNames = Directory.GetFiles(textBox1.Text);
            List<string> jpgNames = new List<string>();
            foreach (var item in fileNames)
                if (item.EndsWith(".jpg"))
                    string jpgName = Path.GetFileName(item);
                    richTextBox1.Text += jpgName + "\n";
                    jpgNames.Add(jpgName);
            StreamWriter sw = new StreamWriter(textBox1.Text + @"\" + "time.h");
            for (int i = 0; i < jpgNames.Count(); i++)
                //从文件目录中将图片读入到IO流中
                FileStream fs = new FileStream(textBox1.Text+@"\"+ jpgNames[i], FileMode.Open, FileAccess.Read);
                //对数据流进行编码八位二进制
                BinaryReader br = new BinaryReader(fs);
                //形成十六进制最后存储的txt文件
                //得到数据流的长度
                int length = (int)fs.Length;
                sw.WriteLine("#include <pgmspace.h>");
                sw.WriteLine("const unsigned char gImage_m"+i+"[] PROGMEM = {");
                while (length > 0)
                    byte tempByte = br.ReadByte();
                    //将八位二进制转换为十六进制字符串形式
                    string tempStr = "0X";
                    tempStr += Convert.ToString(tempByte, 16);
                    tempStr += ",";
                    //写入txt
                    sw.WriteLine(tempStr);
                    length--;
                sw.WriteLine("};");
                //关闭IO流释放资源
                fs.Close();
                br.Close();
            sw.Close();
            MessageBox.Show("转换完成");

在这里插入图片描述
使用教程:

  1. 将所有图片保存在一个文件夹中
  2. 在地址栏填入文件夹中
  3. 点击按键
  4. 里面的所有jpg文件按顺序将会转换成数组保存在一个.h文件里
  5. 直接引用头文件,使用里面的数组即可显示图片
public static class ImageToHex { public static void main(String[] args) throws Exception { try { StringBuffer sb = new StringBuffer(); FileInputStream fis = new FileInputStream(“C:\Use... I have a jpg file under the tmp folder.upload_path = /tmp/resized-test.jpgI have been using the codes below:Method 1with open(upload_path, "rb") as image_file:encoded_string = base64.b64encode(image_f... const unsigned char gImage_Cry[153600] __attribute__((at(0x08035800))) = {此处写数据}; 参考https://blog.csdn.net/yifeng0710/article/details/74940909 使用之后会发现Ro_data 暴增!!也就是代码大小增加很大 ------增大原因是MDK在代码与指定地址间自动添加了0x0 字符串与图片互转 昨天在完成一个16进制转字符串的任务,觉得有必要记录一下。 import javax.imageio.stream.FileImageOutputStream; import java.io.*; public class Hex2Image { public static void main(String[] args) throws Exception { String str=null; /****将jpeg文件转换成.h文件****/ /***************************************************************************************** 平台:VS2008 C#窗体应用程序 编者:张永辉 2013年6月6日 ******************************************** 2018-11-27日更新:由于没有找到生成.bmp格式图片的好办法,改为使用.wbmp格式,转换和读取都改为.wbmp格式,原来的bmp2hex函数逻辑没有变化,改名为wbmp2hex,并不再使用ImageCreateFromBMP函数,可以收藏一下这个函数还是有用的,最新的代码我也提供了下载在文章末尾准备阶段:pctoLCD2002网上找到的一款取模软件,可以读取.bmp图片并生成字模,当然我... jpeg图片格式详解 1. JPEG文件简介 JPEG的全称是JointPhotographicExpertsGroup(联合图像专家小组),它是一种常用的图像存储格式, jpg/jpeg是24位的图像文件格式,也是一种高效率的压缩格式,文件格式是JPEG(联合图像专家组)标准的产物,该标准由ISO与CCI TT(国际电报电话咨询委员会)共同制定,是面向连续色调静止图像的一种压缩标准。其最初目的是使用64Kbps的通信线路传输720×576 分辨率压缩后的图像。通过损失极少的分辨率,可以将图像所需存储量减少 import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; C# 字节流通过转换成图片 // 需引入以下相关命名空间 // using System.IO; // using System.Drawing; // using System.Runtime.Serialization.Formatters.Binary; // using System.Text; protected v...