Changeset 068b1fa in thomson for tools/gfx2mo5/png2mo5.c


Ignore:
Timestamp:
Mar 17, 2014, 10:51:11 AM (10 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
05f2b4a
Parents:
87bafa6
Message:

gfx2mo5: make TO mode a run-time option

  • Use getopt for parsing option.
  • The "MO5 gate array fixup" is now option -f
  • The "TO modeis now option -t

git-svn-id: svn://localhost/thomson@49 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gfx2mo5/png2mo5.c

    r87bafa6 r068b1fa  
    11/* GFX2mo5 - png2mo5.c
    22 * CloudStrife - 20080921
     3 * PulkoMandy - 2012-2014
    34 * Diffusé sous licence libre CeCILL v2
    45 * Voir LICENCE
    56 */
    67
     8#include <getopt.h>
    79#include <stdio.h>
    810#include <stdlib.h>
     
    3335
    3436  png_bytep * ptrRow;
     37  int pxsize;
     38
     39  char opt;
     40  int fixup = -1;
     41  bool to = false;
     42
    3543  unsigned char thomheader[] = {
    3644        // Block 1 : address A7C0, 1 byte, select FORME
     
    4654  if(argc < 3)
    4755  {
    48     printf("Utilisation : %s input_filename output_filename options\n",argv[0]);
     56    printf("Utilisation : %s [options] input_filename output_filename\n",argv[0]);
    4957    exit(0);
    5058  }
    5159
    52   inFile = fopen(argv[1],"rb");
     60  while((opt = getopt(argc, argv, "tf:")) != -1) {
     61    switch(opt) {
     62      case 't':
     63                  to = true;
     64                  thomheader[3] = 0xE7;
     65                  thomheader[4] = 0xC3;
     66                  thomheader[5] = 0x65;
     67                  thomheader[9] = 0x40;
     68                  break;
     69          case 'f':
     70                  fixup = atoi(optarg);
     71                  break;
     72        }
     73  }
     74
     75  inFile = fopen(argv[optind++],"rb");
    5376
    5477  if (inFile == NULL)
     
    127150  png_read_image(png_ptr, ptrRow);
    128151
    129   outBuffer = raw2mo5(inBuffer, height, argc > 3 ? atoi(argv[3]):-1);
     152  outBuffer = raw2mo5(inBuffer, height, fixup, to);
    130153
    131   int pxsize = width * height / 8;
     154  pxsize = width * height / 8;
    132155  thomheader[7] = pxsize >> 8;
    133156  thomheader[8] = pxsize;
    134157
    135   outFile = fopen(argv[2], "wb");
     158  outFile = fopen(argv[optind++], "wb");
    136159  fwrite(thomheader, 1, sizeof(thomheader), outFile);
    137160  //write forme data
    138161  fwrite(outBuffer, 1, pxsize, outFile);
    139   thomheader[5] = 0x50;
     162  --thomheader[5];
    140163  fwrite(thomheader, 1, sizeof(thomheader), outFile);
    141164  // write color data
Note: See TracChangeset for help on using the changeset viewer.