File indexing completed on 2024-04-14 15:50:45
0001 /***************************************************************************** 0002 * Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU Lesser General Public License as * 0006 * published by the Free Software Foundation; either version 2.1 of the * 0007 * License, or (at your option) version 3, or any later version accepted * 0008 * by the membership of KDE e.V. (or its successor approved by the * 0009 * membership of KDE e.V.), which shall act as a proxy defined in * 0010 * Section 6 of version 3 of the license. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0015 * Lesser General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU Lesser General Public * 0018 * License along with this library. If not, * 0019 * see <http://www.gnu.org/licenses/>. * 0020 *****************************************************************************/ 0021 0022 #include "stdio.h" 0023 0024 int 0025 main(int argc, char **argv) 0026 { 0027 if (argc < 4) 0028 return 1; 0029 const char *filename = argv[1]; 0030 const char *varname = argv[2]; 0031 const char *outputname = argv[3]; 0032 FILE *outputfile = fopen(outputname, "w"); 0033 fprintf(outputfile, "#ifndef __QTC_IMAGE_HDR_%s__\n" 0034 "#define __QTC_IMAGE_HDR_%s__\n", varname, varname); 0035 fprintf(outputfile, 0036 "static constexpr unsigned char _%s_data[] = {", varname); 0037 int size = 0; 0038 unsigned char buff; 0039 FILE *inputfile = fopen(filename, "r"); 0040 while (fread(&buff, 1, 1, inputfile)) { 0041 fprintf(outputfile, "%u,", (unsigned)buff); 0042 size++; 0043 } 0044 fclose(inputfile); 0045 fprintf(outputfile, "};\n" 0046 "static const QImage %s __attribute__((unused)) = " 0047 "QImage::fromData(_%s_data, %d);\n" 0048 "#endif\n", varname, varname, size); 0049 fclose(outputfile); 0050 return 0; 0051 }