487 |
487 |
488 header := ByteArray uninitializedNew:4. |
488 header := ByteArray uninitializedNew:4. |
489 aStream nextBytes:4 into:header. |
489 aStream nextBytes:4 into:header. |
490 |
490 |
491 (header startsWith:#(66 77)) ifTrue:[ "BM" |
491 (header startsWith:#(66 77)) ifTrue:[ "BM" |
492 aStream position:1. |
492 aStream position1Based:1. |
493 "/ 'WinIconReader [info]: Win3.x or OS/2 vsn 2 BM format' infoPrintNL. |
493 "/ 'WinIconReader [info]: Win3.x or OS/2 vsn 2 BM format' infoPrintNL. |
494 ^ self fromWindowsBMPStream:aStream |
494 ^ self fromWindowsBMPStream:aStream |
495 ]. |
495 ]. |
496 (header startsWith:#(66 65)) ifTrue:[ "BA" |
496 (header startsWith:#(66 65)) ifTrue:[ "BA" |
497 aStream position:1. |
497 aStream position1Based:1. |
498 "/ 'WinIconReader [info]: OS/2 vsn 2 BA format' infoPrintNL. |
498 "/ 'WinIconReader [info]: OS/2 vsn 2 BA format' infoPrintNL. |
499 ^ self fromOS2Stream:aStream |
499 ^ self fromOS2Stream:aStream |
500 ]. |
500 ]. |
501 (header startsWith:#(67 73)) ifTrue:[ "CI" |
501 (header startsWith:#(67 73)) ifTrue:[ "CI" |
502 'WinIconReader [warning]: OS/2 CI format not supported:' infoPrintNL. |
502 'WinIconReader [warning]: OS/2 CI format not supported:' infoPrintCR. |
503 ^ nil. |
503 ^ nil. |
504 aStream position:1. |
504 aStream position1Based:1. |
505 "/ 'WinIconReader [info]: OS/2 vsn 2 BA format' infoPrintNL. |
505 "/ 'WinIconReader [info]: OS/2 vsn 2 BA format' infoPrintNL. |
506 ^ self fromOS2Stream:aStream |
506 ^ self fromOS2Stream:aStream |
507 ]. |
507 ]. |
508 (header startsWith:#(73 67)) ifTrue:[ "IC" |
508 (header startsWith:#(73 67)) ifTrue:[ "IC" |
509 aStream position:1. |
509 aStream position1Based:1. |
510 "/ 'WinIconReader [info]: OS/2 IC format' infoPrintNL. |
510 "/ 'WinIconReader [info]: OS/2 IC format' infoPrintNL. |
511 ^ self fromOS2Stream:aStream |
511 ^ self fromOS2Stream:aStream |
512 ]. |
512 ]. |
513 (header startsWith:#(80 84)) ifTrue:[ "PT" |
513 (header startsWith:#(80 84)) ifTrue:[ "PT" |
514 aStream position:1. |
514 aStream position1Based:1. |
515 "/ 'WinIconReader [info]: OS/2 PT format' infoPrintNL. |
515 "/ 'WinIconReader [info]: OS/2 PT format' infoPrintNL. |
516 ^ self fromOS2Stream:aStream |
516 ^ self fromOS2Stream:aStream |
517 ]. |
517 ]. |
518 (header startsWith:#(16r53 16r5A)) ifTrue:[ "SZ" |
518 (header startsWith:#(16r53 16r5A)) ifTrue:[ "SZ" |
519 'WinIconReader [warning]: OS/2 SZ format not supported:' infoPrintNL. |
519 'WinIconReader [warning]: OS/2 SZ format not supported:' infoPrintCR. |
520 ^ nil. |
520 ^ nil. |
521 "/ aStream position:1. |
521 "/ aStream position1Based:1. |
522 "/ 'WinIconReader [info]: OS/2 SZ format' infoPrintNL. |
522 "/ 'WinIconReader [info]: OS/2 SZ format' infoPrintNL. |
523 "/ ^ self fromOS2Stream:aStream |
523 "/ ^ self fromOS2Stream:aStream |
524 ]. |
524 ]. |
525 (header startsWith:#(0 0 1 0)) ifTrue:[ |
525 (header startsWith:#(0 0 1 0)) ifTrue:[ |
526 aStream position:1. |
526 aStream position1Based:1. |
527 "/ 'WinIconReader [info]: Win3.x ICO format' infoPrintNL. |
527 "/ 'WinIconReader [info]: Win3.x ICO format' infoPrintNL. |
528 ^ self fromWindowsICOStream:aStream |
528 ^ self fromWindowsICOStream:aStream |
529 ]. |
529 ]. |
530 ^ self fileFormatError:('format not supported:' |
530 ^ self fileFormatError:('format not supported:' |
531 , ((header at:1) printStringRadix:16) |
531 , ((header at:1) printStringRadix:16) |
912 self writeLong:(bfOffBits + biSizeImage). "Entire file size in bytes" |
912 self writeLong:(bfOffBits + biSizeImage). "Entire file size in bytes" |
913 self writeLong:0. "bfReserved" |
913 self writeLong:0. "bfReserved" |
914 self writeLong:bfOffBits. "Offset of bitmap data from start of hdr (and file)" |
914 self writeLong:bfOffBits. "Offset of bitmap data from start of hdr (and file)" |
915 |
915 |
916 "Write the bitmap info header" |
916 "Write the bitmap info header" |
917 outStream position: bhSize+1. |
917 outStream position1Based: bhSize+1. |
918 self writeLong:biSize. "info header size in bytes" |
918 self writeLong:biSize. "info header size in bytes" |
919 self writeLong:width. "biWidth" |
919 self writeLong:width. "biWidth" |
920 self writeLong:height. "biHeight" |
920 self writeLong:height. "biHeight" |
921 self writeShort:1. "biPlanes" |
921 self writeShort:1. "biPlanes" |
922 self writeShort:(depth min:24). "biBitCount" |
922 self writeShort:(depth min:24). "biBitCount" |