The “secret” format is available only to meteorologists. There is no software in the network that allows you to open and view it. True, I was assured that from the point of view of the picture, there is the same thing as on JPEG, and the additional information is just text — everyone there, altitude, temperature, speed ...
e0 0a 00 00 e0 0a 00 00 10 00
2784 2784 16
long Find_Image_Pos(FILE *EL_Data,int *res_out) { unsigned int int_data; int resolution; unsigned long filepos; filepos=0; while(!feof(EL_Data)) { fseek(EL_Data,filepos,SEEK_SET); fread((void*)&int_data,sizeof(unsigned int),1,EL_Data); if(int_data==2784||int_data==11136) { resolution=int_data; fread((void*)&int_data,sizeof(unsigned int),1,EL_Data); if(int_data==resolution) { fread((void*)&int_data,sizeof(unsigned int),1,EL_Data); if(int_data==16) { *res_out=resolution; return ftell(EL_Data); } } } filepos++; } return 0; }
2 . void Save_Image(FILE *EL_Data,FILE *EL_Image,long pos,int resolution) { #ifdef P5 char header[50]; sprintf(header,"P5\n%i %i\n1024\n",resolution,resolution); fwrite(&header,strlen(header),1,EL_Image); #else fprintf(EL_Image,"P2\n%i %i\n1024\n",resolution,resolution); #endif int progress=-1; int max=0; int x=0,y=0; int pixel=0; fseek(EL_Data,pos,SEEK_SET); for(y=0;y<resolution;y++) { if(progress<(y*100/resolution)) { progress=(y*100/resolution); cout<<progress<<"%"<<endl; } for(x=0;x<resolution;x++) { fread(&pixel,2,1,EL_Data); #ifdef P5 fwrite(&pixel,1,1,EL_Image); #else fprintf(EL_Image,"%i\n",pixel); #endif if(pixel>max) max=pixel; } } cout<<"100 %"<<endl; cout<<"max="<<max<<endl; }
#include <iostream>; #include <stdio.h> #include <tchar.h> #include <stdlib.h> #include <windows.h> //#define P5 using namespace std; long Find_Image_Pos(FILE *EL_Data,int *res_out); void Save_Image(FILE *EL_Data,FILE *EL_Image,long pos,int resolution); int _tmain(int argc, _TCHAR* argv[]) { FILE *EL_Data,*EL_Image; if(argc==1) return 0; EL_Data=_wfopen(argv[1],L"rb"); if(!EL_Data) return 0; wchar_t out_file[300]; #ifdef P5 wsprintf(out_file,L"%s.P5.pgm",argv[1]); EL_Image=_wfopen(out_file,L"wb"); #else wsprintf(out_file,L"%s.P2.pgm",argv[1]); EL_Image=_wfopen(out_file,L"wt"); #endif if(!EL_Image) return 0; int resolution=0; long pos=Find_Image_Pos(EL_Data,&resolution); if(!pos) return 0; Save_Image(EL_Data,EL_Image,pos,resolution); fclose(EL_Image); fclose(EL_Data); return 0; }
Source: https://habr.com/ru/post/186560/
All Articles