Beispiel #1
0
VOID  DumpSMPL( PWAVSMPL pws )
{
   DWORD dwi, val;
   WORD  wi;
   BYTE  b;
   dwi = swabi4(pws->Chunk_ID);
   sprtf("Chunk ID        : %#X (smpl=0x736D706C)\n", dwi ); // "smpl" (0x736D706C) 
   sprtf("Chunk Data Size : %d\n", pws->Chunk_Size ); // 0x04 4 Chunk Data Size 36 + (Num Sample Loops * 24) + Sampler Data 
   // The value is stored with some extra information to enable translation
   // to the value used in a MIDI System Exclusive transmission to the sampler.
   // The high byte indicates the number of low order bytes (1 or 3) that are 
   // valid for the manufacturer code. 
   // For example, the value for Digidesign will be 0x01000013 (0x13) and 
   // the value for Microsoft will be 0x30000041 (0x00, 0x00, 0x41).
   // See the MIDI Manufacturers List for a list.
   // Assume bigendians and swap to little-endiands
   dwi = swabi4(pws->Manufacturer);
   wi = HIWORD(dwi);
   b = HIBYTE(wi);
   if(b == 1)
      val = dwi & 0x0ff;
   else if(b == 2)
      val = dwi & 0x0ffff;
   else if(b == 3)
      val = dwi & 0x0ffffff;
   else
      val = dwi & 0x0ff;   // ok, default to a BYTE only

   sprtf("Manufacturer    : %s (%#x)\n", Get_Manufacturer_String(val), dwi ); // 0x08 4 Manufacturer 0 - 0xFFFFFFFF 
   // DWORD Product;    // 0x0C 4 Product 0 - 0xFFFFFFFF 
   sprtf("Product         : %d\n", pws->Product );
   //DWORD Samp_Period;   // 0x10 4 Sample Period 0 - 0xFFFFFFFF 
   sprtf("Sample Period   : %d\n", pws->Samp_Period );
   //DWORD MIDI_Unit;  // 0x14 4 MIDI Unity Note 0 - 127 
   sprtf("MIDI Unit Note  : %d\n", pws->MIDI_Unit );
   //DWORD MIDI_Pitch; // 0x18 4 MIDI Pitch Fraction 0 - 0xFFFFFFFF 
   sprtf("MIDI Pitch      : %d\n", pws->MIDI_Pitch );
   //DWORD SMPTE_Form; // 0x1C 4 SMPTE Format 0, 24, 25, 29, 30 
   sprtf("SMPTE Format    : %d\n", pws->SMPTE_Form );
   //DWORD SMPTE_Off;  // 0x20 4 SMPTE Offset 0 - 0xFFFFFFFF 
   sprtf("SMPTE Offset    : %d\n", pws->SMPTE_Off );
   //DWORD Samp_Loops; // 0x24 4 Num Sample Loops 0 - 0xFFFFFFFF 
   sprtf("Sample Loops    : %d\n", pws->Samp_Loops );
   //DWORD Samp_Data;  // 0x28 4 Sampler Data 0 - 0xFFFFFFFF 
   sprtf("Sample Data     : %d\n", pws->Samp_Data );
   // 0x2C List of Sample Loops 

}
Beispiel #2
0
void  DumpLTXT( PWAVLTXT plt )
{
   DWORD dwi;
   WORD  wi;
   // Label Chunk Format 
   // typedef struct tagWAVLTXT {
   // Offset Size Description Value 
   // 0x00 4 Chunk ID "ltxt" (0x6C747874) 
   dwi = swabi4(plt->Chunk_ID);
   sprtf("Chunk ID        : %#X (ltxt=0x6C747874)\n", dwi );
   //0x04 4 Chunk Data Size depends on contained text 
   dwi = plt->Chunk_Size;
   sprtf("Chunk Size      : %d\n", dwi );
   // 0x08 4 Cue Point ID 0 - 0xFFFFFFFF 
   dwi = plt->Cue_ID;
   sprtf("Cue Point ID    : %d\n", dwi );
   //0x0c 4 Sample Length 0 - 0xFFFFFFFF 
   dwi = plt->Length;
   sprtf("Length          : %d\n", dwi );
   //0x10 4 Purpose ID 0 - 0xFFFFFFFF 
   dwi = plt->Purpose_ID;
   sprtf("Purpose ID      : %d\n", dwi );
   //0x12 2 Country 0 - 0xFFFF 
   wi = plt->Country;
   sprtf("Country         : %d\n", wi );
   //0x14 2 Language 0 - 0xFFFF 
   wi = plt->Language;
   sprtf("Language        : %d\n", wi );
   //0x16 2 Dialect 0 - 0xFFFF 
   wi = plt->Dialect;
   sprtf("Dialect         : %d\n", wi );
   //0x18 2 Code Page 0 - 0xFFFF 
   wi = plt->Code_page;
   sprtf("Code Page       : %d\n", wi );
   //0x1A Text 
}  // WAVLTXT, * PWAVLTXT;
int main(int argc, char const *argv[]) {
  gdImagePtr im;
  FILE *pFichero, *pngOut;
  int salida;
  char ruta[] = "/home/marcos/WRF_PRD/gshhg_data/wdb_rivers_l.b";
  struct GSHHG_HEADER h;
  struct GSHHG_POINT p;
  double w, e, s, n;
  double x, y;
  int i, k, resx, resy, black, white;

  resx = 400;
  resy = 400;
  im = gdImageCreate( resx, resy );
  white = gdImageColorAllocate( im, 255, 255, 255 );
  black = gdImageColorAllocate( im, 0, 0, 0 );

  pFichero = fopen( ruta, "rb" );
  if ( pFichero == NULL )
  {
    perror( "*** ERROR ***" );
    return -1;
  }
  else
  {
    printf( "Fichero abierto correctamente.\n" );
  }

  for ( k = 0; k < 10000; k++) {
  if ( fread( &h, sizeof( h ), 1, pFichero ) != 1 )
  {
    printf( "No se ha podido leer correctamente el encabezado del polígono\n" );
  }
  h.id = swabi4( h.id );
  h.n = swabi4( h.n );
  h.west = swabi4( h.west );
  h.east = swabi4( h.east );
  h.south = swabi4( h.south );
  h.north = swabi4( h.north );
  w = (double) h.west * GSHHG_SCL;
  e = (double) h.east * GSHHG_SCL;
  s = (double) h.north * GSHHG_SCL;
  n = (double) h.south * GSHHG_SCL;
  printf( "id=%i n=%i\n", h.id, h.n );
  printf( "w=%f e=%f s=%f n=%f\n", w, e, s, n );

  h.flag = swabi4( h.flag );
  int level = h.flag & 255;
  int version = ( h.flag >> 8 ) & 255;
  int greenwich = ( h.flag >> 16) & 3;
  int source = ( h.flag >> 24) & 1;
  int river = ( h.flag >> 25) & 1;
  int elevado_a = h.flag >> 26;

  printf("level=%i\n", level);
  printf("version=%i\n", version);
  printf("greenwich=%i\n", greenwich);
  printf("source=%i\n", source);
  printf("river=%i\n", river);
  printf("elevado_a=%i\n", elevado_a);

for( i = 1; i <= h.n; i++){
  fread( &p, sizeof( p ), 1, pFichero );
  p.x = swabi4( p.x );
  p.y = swabi4( p.y );
  x = (double) p.x * GSHHG_SCL;
  y = (double) p.y * GSHHG_SCL;

  // printf("i=%i x=%f y=%f\n", i, x, y );
  if ( x > 300 )
  {
    x = x - 310;
    gdImageSetPixel( im, (int)x, resy - (int)y - 100, black);
  }
  else
  {
    gdImageSetPixel( im, (int)x+50, resy - (int)y - 100, black);
  }
}
}
  fclose( pFichero );

  pngOut = fopen( "gshhg.png", "wb" );
  gdImagePng( im, pngOut );
  fclose( pngOut );
  gdImageDestroy( im );
  return 0;
}
Beispiel #4
0
void gshhsPolygons::read_gshhs_files()
{
    gshhsP::gshhsP polygon;
    register int lon, lat;
    register int val;
    QPointF tmp_pkt;
    QFile gshhs_fil("C:/3party/gshhs/gshhs_l.b");
    if ( gshhs_fil.open(QIODevice::ReadOnly) )
    {
        while ( not gshhs_fil.atEnd() )
        {
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.id = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.n = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.flag = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.west = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.east = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.south = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.north = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.area = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.area_full = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.container = swabi4((unsigned int)val);
            gshhs_fil.read((char*)&val,sizeof(val));
            polygon.ancestor = swabi4((unsigned int)val);

            for(int i=0; i < polygon.n;i++)
            {

                gshhs_fil.read((char*)&lon,sizeof(lon));
                lon = swabi4((unsigned int)lon);
                //if ( lon > 180000000 ) lon -=180000000;
                gshhs_fil.read((char*)&lat,sizeof(lon));
                lat = swabi4((unsigned int)lat);
                tmp_pkt.setX(lon/1000000.0);
                tmp_pkt.setY(lat/1000000.0);
                polygon.points.push_back(tmp_pkt);
                //polygon.pj_points.push_back(tmp_pkt);
                //std::cout << lon << " " << lat << std::endl;
            }
            polygoner.push_back(polygon);
            polygon.points.clear();
            //polygon.pj_points.clear();
            //qDebug("her");
            //qDebug("id: " + QString::number(polygon.id).toAscii() + " n: " + QString::number(polygon.n).toAscii());
            //break;
        }
        //qDebug("Ferdig while");
        gshhs_fil.close();
    }
}