| 1 | /* --------------- */ | 
|---|
| 2 | /* --- bmpNR.c --- */ | 
|---|
| 3 | /* --------------- */ | 
|---|
| 4 |  | 
|---|
| 5 | // Copyright (c) 2013-2014 Lionel Lacassagne, All Rights Reserved | 
|---|
| 6 | // Laboratoire de Recherche en Informatique | 
|---|
| 7 | // Universite Paris-Sud / CNRS | 
|---|
| 8 |  | 
|---|
| 9 | #include <stdio.h> | 
|---|
| 10 | #include <stdlib.h> | 
|---|
| 11 | #include <math.h> | 
|---|
| 12 |  | 
|---|
| 13 | /* -- image -- */ | 
|---|
| 14 | #ifdef CLI | 
|---|
| 15 | #include "nrc_os_config.h" | 
|---|
| 16 | #include "nrtype.h" | 
|---|
| 17 | #include "nrdef.h" | 
|---|
| 18 | #include "nrmacro.h" | 
|---|
| 19 | #include "nralloc.h" | 
|---|
| 20 | #endif | 
|---|
| 21 |  | 
|---|
| 22 | #if TARGET_OS == LINUX | 
|---|
| 23 | #include <sys/types.h> | 
|---|
| 24 | #include <sys/stat.h> | 
|---|
| 25 | #include <fcntl.h> | 
|---|
| 26 | #include <unistd.h> | 
|---|
| 27 | #endif | 
|---|
| 28 |  | 
|---|
| 29 |  | 
|---|
| 30 | #include "palette.h" | 
|---|
| 31 |  | 
|---|
| 32 | /* -- local -- */ | 
|---|
| 33 |  | 
|---|
| 34 | #include "bmpNR.h" | 
|---|
| 35 |  | 
|---|
| 36 | #define BM 0x4d42 | 
|---|
| 37 | #define BI_RGB 0L | 
|---|
| 38 |  | 
|---|
| 39 | PRIVATE void ReadBMProw  (int fd, long width, uint8 * row); | 
|---|
| 40 | PRIVATE void WriteBMProw (uint8 * row, long width, int fd); | 
|---|
| 41 | //PRIVATE void SetupPalette (RGBQUAD Palette[]); | 
|---|
| 42 |  | 
|---|
| 43 | #if (!defined(WIN32) && !defined(_WINDOWS_) && !defined(_WINGDI_)) | 
|---|
| 44 | //#pragma message("bmpio.h no WINDOWS echo") | 
|---|
| 45 | PRIVATE void Palette_RGBQuad2RGBQUAD(RGBQuad * src, RGBQUAD dst[]); | 
|---|
| 46 | #endif | 
|---|
| 47 |  | 
|---|
| 48 | /* ------------------------------------- */ | 
|---|
| 49 | uint8 *ui8ArrayAppend(uint8 *ptr, uint8 x) | 
|---|
| 50 | /* ------------------------------------- */ | 
|---|
| 51 | { | 
|---|
| 52 | *ptr++ = x; | 
|---|
| 53 | return ptr; | 
|---|
| 54 | } | 
|---|
| 55 | /* ---------------------------------------- */ | 
|---|
| 56 | uint8 *ui16ArrayAppend(uint8 *ptr, uint16 x) | 
|---|
| 57 | /* ---------------------------------------- */ | 
|---|
| 58 | { | 
|---|
| 59 | uint8 x0, x1; | 
|---|
| 60 |  | 
|---|
| 61 | x0 = x & 0xFF; x = x >> 8; | 
|---|
| 62 | x1 = x & 0xFF; x = x >> 8; | 
|---|
| 63 |  | 
|---|
| 64 | *ptr++ = x0; | 
|---|
| 65 | *ptr++ = x1; | 
|---|
| 66 |  | 
|---|
| 67 | return ptr; | 
|---|
| 68 | } | 
|---|
| 69 | /* -------------------------------------- */ | 
|---|
| 70 | uint8 *ui32ArrayAppend(uint8 *ptr, uint32 x) | 
|---|
| 71 | /* -------------------------------------- */ | 
|---|
| 72 | { | 
|---|
| 73 | uint8 x0, x1, x2, x3; | 
|---|
| 74 |  | 
|---|
| 75 | x0 = x & 0xFF; x = x >> 8; | 
|---|
| 76 | x1 = x & 0xFF; x = x >> 8; | 
|---|
| 77 | x2 = x & 0xFF; x = x >> 8; | 
|---|
| 78 | x3 = x & 0xFF; x = x >> 8; | 
|---|
| 79 |  | 
|---|
| 80 | *ptr++ = x0; | 
|---|
| 81 | *ptr++ = x1; | 
|---|
| 82 | *ptr++ = x2; | 
|---|
| 83 | *ptr++ = x3; | 
|---|
| 84 |  | 
|---|
| 85 | return ptr; | 
|---|
| 86 | } | 
|---|
| 87 | // Seul moyen de cache dans la librairie ces putains de types windoze | 
|---|
| 88 |  | 
|---|
| 89 | // -------------------------------------------------------- | 
|---|
| 90 | PRIVATE void ReadBMProw(int fd, long width, uint8 *row) | 
|---|
| 91 | // -------------------------------------------------------- | 
|---|
| 92 | { | 
|---|
| 93 | // Le fichier est ouvert (en lecture) et ne sera pas ferme a la fin | 
|---|
| 94 | read(fd, row, sizeof(uint8) * width); | 
|---|
| 95 | } | 
|---|
| 96 | // --------------------------------------------------------- | 
|---|
| 97 | PRIVATE void WriteBMProw(uint8 *row, long width, int fd) | 
|---|
| 98 | // --------------------------------------------------------- | 
|---|
| 99 | { | 
|---|
| 100 | // Le fichier est deja ouvert et ne sera pas ferme a la fin | 
|---|
| 101 | write(fd, row, sizeof(uint8) * width); | 
|---|
| 102 | } | 
|---|
| 103 | #if (!defined(WIN32) && !defined(_WINDOWS_) && !defined(_WINGDI_)) | 
|---|
| 104 | //#pragma message("bmpio.h no WINDOWS echo") | 
|---|
| 105 | /* ----------------------------------------------------------- */ | 
|---|
| 106 | PRIVATE void Palette_RGBQuad2RGBQUAD(RGBQuad *src, RGBQUAD dst[]) | 
|---|
| 107 | /* ----------------------------------------------------------- */ | 
|---|
| 108 | { | 
|---|
| 109 | int i; | 
|---|
| 110 | for (i = 0; i < 256; i++) { | 
|---|
| 111 | dst[i].rgbBlue     = (byte) src[i].blue; | 
|---|
| 112 | dst[i].rgbGreen    = (byte) src[i].green; | 
|---|
| 113 | dst[i].rgbRed      = (byte) src[i].red; | 
|---|
| 114 | dst[i].rgbReserved = (byte) 0; | 
|---|
| 115 | } | 
|---|
| 116 | } | 
|---|
| 117 | #endif | 
|---|
| 118 |  | 
|---|
| 119 | #if (!defined(WIN32) && !defined(_WINDOWS_) && !defined(_WINGDI_)) | 
|---|
| 120 | //#pragma message("bmpio.h no WINDOWS echo") | 
|---|
| 121 | /* --------------------------------------------------------------------------- */ | 
|---|
| 122 | IMAGE_EXPORT(int) SaveBMP0_ui8matrix(uint8 **m, int width, int height, RGBQuad *palette_RGBQuad, char *filename) | 
|---|
| 123 | /* --------------------------------------------------------------------------- */ | 
|---|
| 124 | /* sauvegarde 'image' au format bmp dans le fichier 'filename' */ | 
|---|
| 125 | { | 
|---|
| 126 | int rc = 0; | 
|---|
| 127 |  | 
|---|
| 128 | int v_offset = 0; // no more implemented image->v_offset; | 
|---|
| 129 | int h_offset = 0; // no more implemented image->h_offset; | 
|---|
| 130 | int vmax = height - v_offset; | 
|---|
| 131 | //int hmax = width - h_offset; | 
|---|
| 132 | int height_utile = height - 2*v_offset; | 
|---|
| 133 | int width_utile = width - 2*h_offset; | 
|---|
| 134 | int taille_utile  = height_utile * width_utile; | 
|---|
| 135 |  | 
|---|
| 136 | //int size; | 
|---|
| 137 | int padding_len; | 
|---|
| 138 |  | 
|---|
| 139 | BITMAPFILEHEADER Bitmap_File_Header; | 
|---|
| 140 | /*BITMAPINFO;      Bitmap_Info; */ | 
|---|
| 141 |  | 
|---|
| 142 | BITMAPINFOHEADER Bitmap_Info_Header; | 
|---|
| 143 | /*RGBQUAD          RGB_Quad; */ | 
|---|
| 144 |  | 
|---|
| 145 | RGBQUAD palette_RGBQUAD[256]; /* Windows */ | 
|---|
| 146 |  | 
|---|
| 147 | uint8 Padding[3]; | 
|---|
| 148 |  | 
|---|
| 149 | uint8 **data = m; | 
|---|
| 150 | int fd; | 
|---|
| 151 | int  i; | 
|---|
| 152 |  | 
|---|
| 153 | Padding[0] = 0; | 
|---|
| 154 | Padding[1] = 0; | 
|---|
| 155 | Padding[2] = 0; | 
|---|
| 156 |  | 
|---|
| 157 | /* --- Header --- */ | 
|---|
| 158 | Bitmap_File_Header.bfType      = (WORD) BM;   /* BM                            */ | 
|---|
| 159 | Bitmap_File_Header.bfSize      = (DWORD) sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+256*sizeof(RGBQuad)+taille_utile;    /* taille avec header et palette */ | 
|---|
| 160 | Bitmap_File_Header.bfReserved1 = (WORD) 0; /* 0                             */ | 
|---|
| 161 | Bitmap_File_Header.bfReserved2 = (WORD) 0; /* 0                             */ | 
|---|
| 162 | Bitmap_File_Header.bfOffBits   = (DWORD) sizeof(BITMAPFILEHEADER) + | 
|---|
| 163 | (DWORD) sizeof(BITMAPINFOHEADER) + | 
|---|
| 164 | (DWORD) sizeof(RGBQUAD)*256;   /* */ | 
|---|
| 165 |  | 
|---|
| 166 |  | 
|---|
| 167 | Bitmap_Info_Header.biSize          = (DWORD) sizeof(BITMAPINFOHEADER); | 
|---|
| 168 | Bitmap_Info_Header.biWidth         = (LONG)  width_utile;  // width sans padding | 
|---|
| 169 | Bitmap_Info_Header.biHeight        = (LONG)  height_utile; // height sans padding | 
|---|
| 170 | Bitmap_Info_Header.biPlanes        = (WORD)  1;            // 1 | 
|---|
| 171 | Bitmap_Info_Header.biBitCount      = (WORD)  8;            // 8 en 256 colors | 
|---|
| 172 | Bitmap_Info_Header.biCompression   = (DWORD) BI_RGB;       // BI_RGB | 
|---|
| 173 | Bitmap_Info_Header.biSizeImage     = (DWORD) 0;            // 0 si BI_RGB | 
|---|
| 174 | Bitmap_Info_Header.biXPelsPerMeter = (LONG)  0;            // ??? | 
|---|
| 175 | Bitmap_Info_Header.biYPelsPerMeter = (LONG)  0;            // ??? | 
|---|
| 176 | Bitmap_Info_Header.biClrUsed       = (DWORD) 256;          // 256 | 
|---|
| 177 | Bitmap_Info_Header.biClrImportant  = (DWORD) 0;            // 0 | 
|---|
| 178 |  | 
|---|
| 179 |  | 
|---|
| 180 | printf("   SaveBMP %s ", filename); | 
|---|
| 181 | printf("[%dx%d] - [%dx%d] = [%dx%d]\n",height,width, v_offset, h_offset, height_utile, width_utile); | 
|---|
| 182 | fd = open(filename, O_CREAT | O_TRUNC); | 
|---|
| 183 | if (fd < 0) { | 
|---|
| 184 | printf("*** Erreur : Ouverture du fichier impossible dans SaveBMP"); | 
|---|
| 185 | } | 
|---|
| 186 |  | 
|---|
| 187 | /* enregistrement de l'image au format bmp */ | 
|---|
| 188 | write(fd, &Bitmap_File_Header, sizeof(BITMAPFILEHEADER)); | 
|---|
| 189 | /*if(size != sizeof(BITMAPFILEHEADER)) { | 
|---|
| 190 | printf("Bitmap File Header : octets ecrits %d attendus %d\n", size, sizeof(BITMAPFILEHEADER)); | 
|---|
| 191 | Error("Erreur d'ecriture du Bitmap File Header"); | 
|---|
| 192 | }*/ | 
|---|
| 193 | write(fd, &Bitmap_Info_Header, sizeof(BITMAPINFOHEADER)); | 
|---|
| 194 | /*if(size != sizeof(BITMAPINFOHEADER) ){ | 
|---|
| 195 | printf("Bitmap Info Header : octets ecrits %d attendus %d\n", size, sizeof(BITMAPINFOHEADER)); | 
|---|
| 196 | Error("Erreur d'ecriture du Bitmap Info Header"); | 
|---|
| 197 | }*/ | 
|---|
| 198 |  | 
|---|
| 199 | Palette_RGBQuad2RGBQUAD(palette_RGBQuad, palette_RGBQUAD); | 
|---|
| 200 | write(fd, palette_RGBQUAD, sizeof(RGBQUAD) * 256); | 
|---|
| 201 | /*if(size != 256*sizeof(RGBQUAD)) { | 
|---|
| 202 | printf("Palette : octets ecrits %d attendus %d\n", size, 256*sizeof(RGBQUAD)); | 
|---|
| 203 | Error("Erreur d'ecriture de la palette"); | 
|---|
| 204 | }*/ | 
|---|
| 205 |  | 
|---|
| 206 | //for(i=v_offset; i<vmax; i++)/ | 
|---|
| 207 |  | 
|---|
| 208 | /* en 2x car le compilo est trop con ... */ | 
|---|
| 209 | padding_len = width_utile % 4; | 
|---|
| 210 | padding_len = (4 - padding_len) % 4; | 
|---|
| 211 |  | 
|---|
| 212 | for (i = vmax - 1; i >= v_offset; i--) { | 
|---|
| 213 | WriteBMProw(data[i] + h_offset, width_utile, fd); | 
|---|
| 214 | write(fd, Padding, sizeof(byte) * padding_len); | 
|---|
| 215 | } | 
|---|
| 216 | close(fd); | 
|---|
| 217 | return rc; | 
|---|
| 218 |  | 
|---|
| 219 | } | 
|---|
| 220 | #endif | 
|---|
| 221 | // ------------------------------------------------------------------------------------------------------------ | 
|---|
| 222 | IMAGE_EXPORT(int) SaveBMP2_ui8matrix(uint8 **m, int width, int height, RGBQuad *palette_RGBQuad, char *filename) | 
|---|
| 223 | // ------------------------------------------------------------------------------------------------------------ | 
|---|
| 224 | // sauvegarde 'image' au format bmp dans le fichier 'filename' | 
|---|
| 225 | { | 
|---|
| 226 | int taille_utile  = height * width; | 
|---|
| 227 |  | 
|---|
| 228 | //int size; | 
|---|
| 229 | int padding_len; | 
|---|
| 230 |  | 
|---|
| 231 | BitmapFileHeader Bitmap_File_Header; | 
|---|
| 232 |  | 
|---|
| 233 | BitmapInfoHeader Bitmap_Info_Header; | 
|---|
| 234 |  | 
|---|
| 235 | //RGBQuad palette_RGBQuad[256]; /* Windows */ | 
|---|
| 236 |  | 
|---|
| 237 | byte Padding[3]; | 
|---|
| 238 | uint8 rawBFH[14], *ptrBFH; // raw Bitmap File Header | 
|---|
| 239 | uint8 rawBIH[40], *ptrBIH; // raw Bitmap Info Header | 
|---|
| 240 |  | 
|---|
| 241 | int fd; | 
|---|
| 242 | int  i; | 
|---|
| 243 |  | 
|---|
| 244 | //#pragma message("BMP warnin' data structure aligment must be 2") | 
|---|
| 245 | //#pragma message("  sizeof( BitmapFileHeader) must = 14, not 16") | 
|---|
| 246 |  | 
|---|
| 247 | //DEBUG(printf("BMP0 : %d %d\n", sizeof( BITMAPFILEHEADER), sizeof( BITMAPINFOHEADER))); | 
|---|
| 248 | //DEBUG(printf("BMP0_: %d %d\n", sizeof(_BITMAPFILEHEADER), sizeof(_BITMAPINFOHEADER))); | 
|---|
| 249 | //DEBUG(printf("BMP  : %d %d\n", sizeof( BitmapFileHeader), sizeof( BitmapInfoHeader))); | 
|---|
| 250 | if (sizeof(BitmapFileHeader) != 14) { | 
|---|
| 251 | printf("*** Error SaveMBP: sizeof(BitmapFileHeader) = %d should be 14...\n", (int) sizeof(BitmapFileHeader)); | 
|---|
| 252 | } | 
|---|
| 253 |  | 
|---|
| 254 | Padding[0] = 0; | 
|---|
| 255 | Padding[1] = 0; | 
|---|
| 256 | Padding[2] = 0; | 
|---|
| 257 |  | 
|---|
| 258 | // --- Header --- | 
|---|
| 259 | Bitmap_File_Header.bfType      = (uint16) BM;   // | 
|---|
| 260 | Bitmap_File_Header.bfSize      = (uint32) sizeof(BitmapFileHeader) + sizeof(BitmapInfoHeader) + 256 * sizeof(RGBQuad) + taille_utile;    /* taille avec header et palette */ | 
|---|
| 261 | Bitmap_File_Header.bfReserved1 = (uint16) 0; /* 0                             */ | 
|---|
| 262 | Bitmap_File_Header.bfReserved2 = (uint16) 0; /* 0                             */ | 
|---|
| 263 | Bitmap_File_Header.bfOffBits   = (uint32) sizeof(BitmapFileHeader) + (uint32) sizeof(BitmapInfoHeader) + (uint32) sizeof(RGBQuad) * 256;   /* */ | 
|---|
| 264 |  | 
|---|
| 265 |  | 
|---|
| 266 | Bitmap_Info_Header.biSize          = (uint32) sizeof(BitmapInfoHeader); | 
|---|
| 267 | Bitmap_Info_Header.biWidth         = (uint32)  width;  // width sans padding | 
|---|
| 268 | Bitmap_Info_Header.biHeight        = (uint32)  height; // height sans padding | 
|---|
| 269 | Bitmap_Info_Header.biPlanes        = (uint16)  1;      // 1 | 
|---|
| 270 | Bitmap_Info_Header.biBitCount      = (uint16)  8;      // 8 en 256 colors | 
|---|
| 271 | Bitmap_Info_Header.biCompression   = (uint32) BI_RGB;  // BI_RGB | 
|---|
| 272 | Bitmap_Info_Header.biSizeImage     = (uint32) 0;       // 0 si BI_RGB | 
|---|
| 273 | Bitmap_Info_Header.biXPelsPerMeter = (uint32)  0;      // ??? | 
|---|
| 274 | Bitmap_Info_Header.biYPelsPerMeter = (uint32)  0;      // ??? | 
|---|
| 275 | Bitmap_Info_Header.biClrUsed       = (uint32) 256;     // 256 | 
|---|
| 276 | Bitmap_Info_Header.biClrImportant  = (uint32) 0;       // 0 | 
|---|
| 277 |  | 
|---|
| 278 | ptrBFH = rawBFH; | 
|---|
| 279 | ptrBFH = ui16ArrayAppend(ptrBFH, Bitmap_File_Header.bfType); | 
|---|
| 280 | ptrBFH = ui32ArrayAppend(ptrBFH, Bitmap_File_Header.bfSize); | 
|---|
| 281 | ptrBFH = ui16ArrayAppend(ptrBFH, Bitmap_File_Header.bfReserved1); | 
|---|
| 282 | ptrBFH = ui16ArrayAppend(ptrBFH, Bitmap_File_Header.bfReserved2); | 
|---|
| 283 | ptrBFH = ui32ArrayAppend(ptrBFH, Bitmap_File_Header.bfOffBits); | 
|---|
| 284 |  | 
|---|
| 285 | ptrBIH = rawBIH; | 
|---|
| 286 | ptrBIH = ui32ArrayAppend(ptrBIH, Bitmap_Info_Header.biSize); | 
|---|
| 287 | ptrBIH = ui32ArrayAppend(ptrBIH, Bitmap_Info_Header.biWidth); | 
|---|
| 288 | ptrBIH = ui32ArrayAppend(ptrBIH, Bitmap_Info_Header.biHeight); | 
|---|
| 289 | ptrBIH = ui16ArrayAppend(ptrBIH, Bitmap_Info_Header.biPlanes); | 
|---|
| 290 | ptrBIH = ui16ArrayAppend(ptrBIH, Bitmap_Info_Header.biBitCount); | 
|---|
| 291 | ptrBIH = ui32ArrayAppend(ptrBIH, Bitmap_Info_Header.biCompression); | 
|---|
| 292 | ptrBIH = ui32ArrayAppend(ptrBIH, Bitmap_Info_Header.biSizeImage); | 
|---|
| 293 | ptrBIH = ui32ArrayAppend(ptrBIH, Bitmap_Info_Header.biXPelsPerMeter); | 
|---|
| 294 | ptrBIH = ui32ArrayAppend(ptrBIH, Bitmap_Info_Header.biYPelsPerMeter); | 
|---|
| 295 | ptrBIH = ui32ArrayAppend(ptrBIH, Bitmap_Info_Header.biClrUsed); | 
|---|
| 296 | ptrBIH = ui32ArrayAppend(ptrBIH, Bitmap_Info_Header.biClrImportant); | 
|---|
| 297 |  | 
|---|
| 298 | //printf("   SaveBMP %s %dx%d\n", filename, width, height); | 
|---|
| 299 |  | 
|---|
| 300 | fd = open(filename, O_CREAT | O_TRUNC); | 
|---|
| 301 | if (fd < 0) { | 
|---|
| 302 | printf("*** Erreur : ouverture du fichier '%s' impossible dans SaveBMP", filename); | 
|---|
| 303 | } | 
|---|
| 304 |  | 
|---|
| 305 | // enregistrement de l'image au format bmp | 
|---|
| 306 | //size = fwrite(&Bitmap_File_Header, sizeof(BitmapFileHeader), 1, file); | 
|---|
| 307 | write(fd, rawBFH, 14); | 
|---|
| 308 | //if(size != sizeof(BITMAPFILEHEADER)) { | 
|---|
| 309 | //  printf("Bitmap File Header : octets ecrits %d attendus %d\n", size, sizeof(BITMAPFILEHEADER)); | 
|---|
| 310 | //  Error("Erreur d'ecriture du Bitmap File Header"); | 
|---|
| 311 | //} | 
|---|
| 312 |  | 
|---|
| 313 | //size = fwrite(&Bitmap_Info_Header, sizeof(BitmapInfoHeader), 1, file); | 
|---|
| 314 | write(fd, rawBIH, 40); | 
|---|
| 315 |  | 
|---|
| 316 | //if(size != sizeof(BITMAPINFOHEADER) ){ | 
|---|
| 317 | //  printf("Bitmap Info Header : octets ecrits %d attendus %d\n", size, sizeof(BITMAPINFOHEADER)); | 
|---|
| 318 | //  Error("Erreur d'ecriture du Bitmap Info Header"); | 
|---|
| 319 | //} | 
|---|
| 320 |  | 
|---|
| 321 | write(fd, palette_RGBQuad, sizeof(RGBQuad) * 256); | 
|---|
| 322 | //if(size != 256*sizeof(RGBQUAD)) { | 
|---|
| 323 | //  printf("Palette : octets ecrits %d attendus %d\n", size, 256*sizeof(RGBQUAD)); | 
|---|
| 324 | //  Error("Erreur d'ecriture de la palette"); | 
|---|
| 325 | //} | 
|---|
| 326 |  | 
|---|
| 327 |  | 
|---|
| 328 | // en 2x car le compilo est trop con ... | 
|---|
| 329 | padding_len = width % 4; | 
|---|
| 330 | padding_len = (4 - padding_len) % 4; | 
|---|
| 331 |  | 
|---|
| 332 | for (i = height - 1; i >= 0; i--) { | 
|---|
| 333 | //WriteBMProw(data[i]+h_offset, width_utile, fichier); | 
|---|
| 334 | WriteBMProw(m[i] + 0, width, fd); | 
|---|
| 335 | write(fd, Padding, sizeof(uint8) * padding_len); | 
|---|
| 336 | } | 
|---|
| 337 | close(fd); | 
|---|
| 338 | return 0; | 
|---|
| 339 | } | 
|---|
| 340 |  | 
|---|