()
| 458 | } |
| 459 | |
| 460 | int getLength() throws IOException { |
| 461 | int b0 = getByte(); |
| 462 | int b1 = getByte(); |
| 463 | int b2 = getByte(); |
| 464 | int b3 = getByte(); |
| 465 | |
| 466 | // We cannot know whether the VR is implicit or explicit |
| 467 | // without the full DICOM Data Dictionary for public and |
| 468 | // private groups. |
| 469 | |
| 470 | // We will assume the VR is explicit if the two bytes |
| 471 | // match the known codes. It is possible that these two |
| 472 | // bytes are part of a 32-bit length for an implicit VR. |
| 473 | |
| 474 | vr = (b0<<8) + b1; |
| 475 | |
| 476 | switch (vr) { |
| 477 | case OB: case OW: case SQ: case UN: case UT: |
| 478 | case OF: case OL: case OD: case UC: case UR: |
| 479 | case OV: case SV: case UV: |
| 480 | // Explicit VR with 32-bit length if other two bytes are zero |
| 481 | if ( (b2 == 0) || (b3 == 0) ) return getInt(); |
| 482 | // Implicit VR with 32-bit length |
| 483 | vr = IMPLICIT_VR; |
| 484 | if (littleEndian) |
| 485 | return ((b3<<24) + (b2<<16) + (b1<<8) + b0); |
| 486 | else |
| 487 | return ((b0<<24) + (b1<<16) + (b2<<8) + b3); |
| 488 | case AE: case AS: case AT: case CS: case DA: case DS: case DT: case FD: |
| 489 | case FL: case IS: case LO: case LT: case PN: case SH: case SL: case SS: |
| 490 | case ST: case TM: case UI: case UL: case US: case QQ: |
| 491 | // Explicit vr with 16-bit length |
| 492 | if (littleEndian) |
| 493 | return ((b3<<8) + b2); |
| 494 | else |
| 495 | return ((b2<<8) + b3); |
| 496 | default: |
| 497 | // Implicit VR with 32-bit length... |
| 498 | vr = IMPLICIT_VR; |
| 499 | if (littleEndian) |
| 500 | return ((b3<<24) + (b2<<16) + (b1<<8) + b0); |
| 501 | else |
| 502 | return ((b0<<24) + (b1<<16) + (b2<<8) + b3); |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | int getNextTag() throws IOException { |
| 507 | int groupWord = getShort(); |
no test coverage detected