TRAD_PXL 22-APR-1986 14:39:32 VAX C V2.1-007 Page 1 V1.0 24-JAN-1986 10:36:55 TRAD_PXL.C;1 (1) 1 2 /* 3 * Traduction des formats de PXL en Integer et inversement 4 */ 5 6 #include 64 65 extern char pxl_buf[]; 66 /* Buffer de travail - Raster modifies */ 67 extern char pxm_raster[]; 68 /* Dictionnaire temporaire */ 69 extern char pxm_dict[]; 70 71 /* Definition de structures - Utiliser pour les traductions */ 72 /* Dans l'hyphothese de la translation des octets sous VMS*/ 73 74 75 union TYPE_LONG { 76 char c[4]; 77 long int l; 78 }; 79 80 union TYPE_WORD { 81 char c[2]; 82 short int w; 83 }; 84 /* 85 Routines de conversion entre les buffers en octets et des entiers 86 */ 87 88 pxl_to_long(c) 89 int c; 90 { 91 1 union TYPE_LONG mot; 92 1 register i; 93 1 94 1 for (i=0; i<4; i++) 95 1 mot.c[i] = pxl_buf[c-i+3]; 96 1 97 1 return (mot.l); 98 1 } 99 100 pxl_to_word(c) 101 int c; 102 { 103 1 union TYPE_WORD mot; 104 1 register i; 105 1 106 1 for (i=0; i<2; i++) 107 1 mot.c[i] = pxl_buf[c-i+1]; 108 1 109 1 return (mot.w); 110 1 } 111 112 pxm_to_long(c) TRAD_PXL 22-APR-1986 14:39:32 VAX C V2.1-007 Page 2 V1.0 24-JAN-1986 10:36:55 TRAD_PXL.C;1 (1) 113 int c; 114 { 115 1 union TYPE_LONG mot; 116 1 register i; 117 1 118 1 for (i=0; i<4; i++) 119 1 mot.c[i] = pxm_raster[c-i+3]; 120 1 121 1 return (mot.l); 122 1 } 123 124 pxm_to_word(c) 125 int c; 126 { 127 1 union TYPE_WORD mot; 128 1 register i; 129 1 130 1 for (i=0; i<2; i++) 131 1 mot.c[i] = pxm_raster[c-i+1]; 132 1 133 1 return (mot.w); 134 1 } 135 136 dict_to_long(c) 137 int c; 138 { 139 1 union TYPE_LONG mot; 140 1 register i; 141 1 142 1 for (i=0; i<4; i++) 143 1 mot.c[i] = pxm_dict[c-i+3]; 144 1 145 1 return (mot.l); 146 1 } 147 148 dict_to_word(c) 149 int c; 150 { 151 1 union TYPE_WORD mot; 152 1 register i; 153 1 154 1 for (i=0; i<2; i++) 155 1 mot.c[i] = pxm_dict[c-i+1]; 156 1 157 1 return (mot.w); 158 1 } 159 160 word_to_dict (offset, value) 161 int offset, value; 162 { 163 1 pxm_dict[offset] = value / 256; 164 1 pxm_dict[offset+1] = value % 256; 165 1 if (dict_to_word(offset) != value) 166 1 printf(">>> La fonction WORD_TO_DICT est incorrecte\n"); 167 1 } 168 169 long_to_dict (offset, value) TRAD_PXL 22-APR-1986 14:39:32 VAX C V2.1-007 Page 3 V1.0 24-JAN-1986 10:36:55 TRAD_PXL.C;1 (1) 170 int offset, value; 171 { 172 1 word_to_dict(offset, value / (256*256)); /* Attention a l'ordre*/ 173 1 word_to_dict(offset+2, value % (256*256)); 174 1 if (dict_to_long(offset) != value) 175 1 printf(">>> La fonction LONG_TO_DICT est incorrecte"); 176 1 } 177 178 long_to_pxm (offset, value) 179 int offset, value; 180 { 181 1 int i; 182 1 int low_value, high_value; 183 1 184 1 low_value = value / (256*256); 185 1 high_value= value % (256*256); 186 1 pxm_raster[offset+0] = low_value / 256; 187 1 pxm_raster[offset+1] = low_value % 256; 188 1 pxm_raster[offset+2] = high_value / 256; 189 1 pxm_raster[offset+3] = high_value % 256; 190 1 if (pxm_to_long(offset) != value) 191 1 { 192 2 printf(">>> LONG_TO_PXM erreur pour l'offset %d\n", 193 2 offset); 194 2 printf(" Value :%d\n",value); 195 2 printf(" PXM_TO_LONG :%d\n",pxm_to_long(offset)); 196 2 for (i=offset; i