下载资源后端资源详情
源文件.zip
大小:2.89KB
价格:10积分
下载量:0
评分:
5.0
上传者:weixin_48971883
更新日期:2024-09-25

Python获取图片ARGB值并生成代码

资源文件列表(大概)

文件名
大小
generateImageFile.sh
475B
ImageAnalysis.py
3.03KB
WriteFile.py
8.21KB

资源内容介绍

实际代码文件和shell文件
import osgReplaceName = [ 'IDS_TT_', 'IDS_SPDIG_', 'IDS_AT_', 'IDS_ADAS_ADAS_', ]gTelltaleDataInfoText = '/**********************************************************************************************************************/\n'gTelltaleDataText = '/**********************************************************************************************************************/\n'gTelltaleTypedefText = '/**********************************************************************************************************************/\n'gTelltaleVariableText = '/**********************************************************************************************************************/\n'gSpeedDataInfoText = '/**********************************************************************************************************************/\n'gSpeedDataText = '/**********************************************************************************************************************/\n'gSpeedTypedefText = '/**********************************************************************************************************************/\n'gSpeedVariableText = '/**********************************************************************************************************************/\n'gGearDataInfoText = '/**********************************************************************************************************************/\n'gGearDataText = '/**********************************************************************************************************************/\n'gGearTypedefText = '/**********************************************************************************************************************/\n'gGearVariableText = '/**********************************************************************************************************************/\n'gAdasDataInfoText = '/**********************************************************************************************************************/\n'gAdasDataText = '/**********************************************************************************************************************/\n'gADASTypedefText = '/**********************************************************************************************************************/\n'gADASVariableText = '/**********************************************************************************************************************/\n'gDataInfoText = 0gDataText = 1gTypedefText = 2gVariableText = 3gUncompressedImageText = { 'Telltale': [gTelltaleDataInfoText, gTelltaleDataText, gTelltaleTypedefText, gTelltaleVariableText], 'Speed': [gSpeedDataInfoText, gSpeedDataText, gSpeedTypedefText, gSpeedVariableText ], 'Gear': [gGearDataInfoText, gGearDataText, gGearTypedefText, gGearVariableText ], 'ADAS': [gAdasDataInfoText, gAdasDataText, gADASTypedefText, gADASVariableText ]}class ClassWriteFile: def __init__(self) -> None: pass def CheckFileIsExist(self, FileName): if os.path.exists(FileName + '.c') : os.remove(FileName + '.c') if os.path.exists(FileName + '.h') : os.remove(FileName + '.h') def WriteARGBintoCFile(self, PictureName, ARGBhex, FileName, gIsConstFlag) : cFileName = FileName + '.c' if os.path.exists(cFileName) : cFileOpen = open(cFileName, 'a+') else : cFileOpen = open(cFileName, 'w') text = '#include <stdint.h>\n'\ '#include <stdio.h>\n'\ '#include "Log_print_api.h"\n'\ '#include "' + FileName + '.h"\n'\ '\n' cFileOpen.write(text) if gIsConstFlag == 1 : text = 'const static uint32_t s_' + PictureName + '[] = {' elif gIsConstFlag == 0 : text = 'static uint32_t ' + 's_' + PictureName + '[] = {' text += ', '.join(['0x%08XU'%count for count in ARGBhex]) text += '};\n' cFileOpen.write(text) cFileOpen.write('\n') cFileOpen.close() def WriteModuleFile(self, ModuleName, FileName, pictureName, gIsConstFlag) : # Head File HeadFileName = FileName + '.h' macro = HeadFileName.upper().replace('.', '_') hfile = open(HeadFileName, "w") hfile.write('#ifndef ' + macro + '\n') hfile.write('#define ' + macro + '\n\n') text = '#include <stdint.h>\n'\ '\n' hfile.write(text) if ModuleName in gUncompressedImageText: text = gUncompressedImageText[ModuleName][gTypedefText] hfile.write(text) hfile.write('typedef enum {\n') moduleName = ModuleName + '_Image_' for count in pictureName: upperName = count[0].upper() name = str(upperName) for name_count in gReplaceName : if name_count in name : name = name.replace(name_count, moduleName) hfile.write(' ' + name + ',\n') hfile.write(' ' + ModuleName + '_Image_Count\n') hfile.write('} ' + ModuleName + '_Image_ID_t;\n\n') text = 'typedef struct {\n'\ ' uint32_t ImageX;\n'\ ' uint32_t ImageY;\n'\ ' uint32_t ImageWidth;\n'\ ' uint32_t ImageHeight;\n'\ '} ' + ModuleName + '_Image_Info_t;\n'\ '\n'\ '' + ModuleName + '_Image_Info_t get' + ModuleName + 'ImageGeometry(' + ModuleName + '_Image_ID_t id);\n'\ '\n'\ 'const uint32_t* get' + ModuleName + 'ImageData(' + ModuleName + '_Image_ID_t id);\n'\ '\n' hfile.write(text) hfile.write('#endif\n') hfile.close() # C File CFileName = FileName + '.c' cfile = open(CFileName, 'a+') if ModuleName in gUncompressedImageText: text = gUncompressedImageText[ModuleName][gVariableText] cfile.write(text) text = 'const static uint32_t* s_' + ModuleName + '_Image_Data[' + ModuleName + '_Image_Count] = {\n' const_count = 0 for count in pictureName : if gIsConstFlag[const_count] == 1 : text += ' ' + 's_' + count[0] + ',\n' elif gIsConstFlag[const_count] == 0 : text += ' ' + 's_' + count[0] + ',\n' const_count = const_count + 1 text += '};\n\n' cfile.write(text) if ModuleName in gUncompressedImageText: text = gUncompressedImageText[ModuleName][gDataInfoText] cfile.write(text) text = '' + ModuleName + '_Image_Info_t get' + ModuleName + 'ImageGeometry(' + ModuleName + '_Image_ID_t id) {\n'\ ' ' + ModuleName + '_Image_Info_t info = {0};\n'\ '\n'\ ' if (id >= ' + ModuleName + '_Image_Count) {\n'\ ' K_LogE("[RGUI_' + ModuleName + '_Info] ' + ModuleName + ' info receive error id[0x%02x]\\r\\n", id);\n'\ ' } else {\n'\ ' const uint32_t* data = s_' + ModuleName + '_Image_Data[id];\n'\ ' info.ImageX = (uint32_t)data[0];\n'\ ' info.ImageY = (uint32_t)data[1];\n'\ ' info.ImageWidth = (uint32_t)data[2];\n'\ ' info.ImageHeight = (uint32_t)data[3];\n'\ ' }\n'\ '\n'\ ' return info;\n'\ '}\n' cfile.write(text) text = '\n' cfile.write(text) if ModuleName in gUncompressedImageText: text = gUncompressedImageText[ModuleName][gDataText] cfile.write(text) text = 'const uint32_t* get' + ModuleName + 'ImageData(' + ModuleName + '_Image_ID_t id) {\n'\ ' if (id >= ' +

用户评论 (0)

发表评论

captcha

相关资源

数据分析项目-房屋价格预测.zip

内含自写的源代码,下载的参考文献,完整论文和处理前后的数据:1.源代码:提供完整的数据分析流程代码,便于复现分析结果2.参考文献:列出了所有参考的文献资料,方便深入了解相关理论和背景3.完整论文:提供了上万字的详细论文,深入探讨了数据分析的各个方面4.处理前后的数据:分享了原始数据及经过处理后的数据,供进行对比和进一步分析。

22.59MB50积分

数据分析项目-医药电商销售分析.zip

本文题目来源于2022年数据分析大赛的A题,该文章是本人自己创作而成,从医药电商的店铺、药品和品牌分别进行分析预处理和可视化,最后建立起了时间序列模型进行预测。内容详情可以去本人博客去阅读浏览(免费的哦~)!本压缩包内含比赛题目、比赛数据以及自己创写的代码!详情内容:1.进行了数据预处理,包括清洗、整理和转换等步骤,以确保数据的质量和准确性;2.运用可视化工具将数据呈现出来,以便更好地理解数据之间的关系和趋势;3.分析店铺、药品和品牌销售各不同的原因分析以及情况,探讨了品牌选择对店铺业绩的影响;4.利用历史数据对未来的销售情况进行预测。这个模型可以帮助商家做出更准确的决策,提高销售业绩;5.最后通过对医药电商店铺、药品和品牌的综合分析,我为商家提供了有价值的洞察和建议,帮助他们优化运营策略,提升竞争力。

6.74MB27积分

Python基础.zip

压缩包里含有丰富的Python基础的资源和代码,思维导图全程是手打上去,本人非计算机专业,自学数据分析,目前工作岗位是大数据分析;这些基础的内容分享给大家,我明白自学数据分析的不易,内涵许多自己在学习过程的注释,后期我会在自己的博客文章里慢慢的发表内容,对于心急学习的伙伴们就可以下载提取学习,希望可以给各位带来帮助!文章里包涵了:print函数,转义符,保留字,变量三部分,整数类型int( ),浮点类型float( ),布尔类型bool( ),字符串类型str( ),类型转换,算术运算符,赋值运算符,比较运算符,布尔运算符,运算符优先级,选择结构,循环语句,字典,元组,集合,列表,字符串,函数创建,函数返回值,参数总结,变量的作用域,Bug,常见的异常类型,try...except...else...finally结构,面向对象,类的组成,对象实例化,动态绑定,三大特征,模块和包,文件处理,with语句,os模块,os.path模块

10.07MB10积分

pandas121212121212122

pandas121212121212122

24.27KB38积分