Advertisement
Guest User

test2

a guest
Apr 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. void Paint::on_pushButton_5_clicked()
  2. {
  3. int ii=0;
  4. char b=0;
  5.  
  6. unsigned char lcd_word_array[8][128]={{0}};
  7.  
  8. QFile fileIn("example.bmp");
  9. QFile fileOut("example.txt");
  10. if(!fileIn.open(QFile::ReadOnly)){
  11. qDebug() << "File not exists";
  12. }
  13. if(!fileOut.open(QFile::WriteOnly)){
  14. qDebug() << "File not exists";
  15. }
  16.  
  17. fileIn.seek(SEEK_SET);
  18.  
  19. QTextStream stream(&fileIn);
  20. char *ch = new char();
  21.  
  22. int i = 0;
  23. int j = 0;
  24.  
  25. while(!fileIn.atEnd()){
  26. b = fileIn.getChar(ch);
  27. b = ~ b;
  28. lcd_word_array[i][j] = b;
  29. qDebug() << b;
  30. if(i < 7) {i++;}
  31. else {j++; i = 0;}
  32. ii++;
  33. if(ii > 1023) break;
  34.  
  35. }
  36. fileIn.close();
  37.  
  38. i = 0;
  39. j = 0;
  40.  
  41. fileOut.write("const byte satan[8][128]={");
  42. fileOut.write("\r\n");
  43. for(i = 7; i >= 0; i--){
  44. fileOut.write("{");
  45. for(j = 0; j < 128; j++){
  46. if(j > 0 && j != 128) fileOut.write(", ");
  47.  
  48. if(lcd_word_array[i][j] == 0x00) {fileOut.write("0x00");}
  49.  
  50. else{
  51. if(lcd_word_array[i][j] <= 0x0F) {fileOut.write(QString("0x0%1").arg(lcd_word_array[i][j], 0, 16).toUtf8());}
  52. else
  53. fileOut.write(QString("0x%1").arg(lcd_word_array[i][j] & 0xFF, 0, 16).toUtf8());
  54. }
  55. }
  56. if(i != 0) fileOut.write("},\r\n");
  57. else fileOut.write("}");
  58. }
  59. fileOut.write("\r\n};");
  60. fileOut.close();
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement