ImageReader.st
author Claus Gittinger <cg@exept.de>
Wed, 22 Aug 2018 12:58:11 +0200
changeset 8451 6eafe0433763
parent 8328 9c4240cfee1a
child 8505 5b3de8460594
permissions -rw-r--r--
#QUALITY by cg class: WindowSensor comment/format in: #basicAddDamage:view:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     1
"
6
7ee0cfde237d *** empty log message ***
claus
parents: 5
diff changeset
     2
 COPYRIGHT (c) 1991 by Claus Gittinger
77
da4678fae5c8 *** empty log message ***
claus
parents: 72
diff changeset
     3
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     4
48194c26a46c Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
48194c26a46c Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
48194c26a46c Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
48194c26a46c Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
48194c26a46c Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
48194c26a46c Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
48194c26a46c Initial revision
claus
parents:
diff changeset
    11
"
3260
e4e8e2b99900 use Image>>newForDepth:
Claus Gittinger <cg@exept.de>
parents: 3243
diff changeset
    12
"{ Package: 'stx:libview' }"
e4e8e2b99900 use Image>>newForDepth:
Claus Gittinger <cg@exept.de>
parents: 3243
diff changeset
    13
7142
439177d49d77 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 6902
diff changeset
    14
"{ NameSpace: Smalltalk }"
439177d49d77 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 6902
diff changeset
    15
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    16
Object subclass:#ImageReader
8145
83f792c6d9b1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8129
diff changeset
    17
	instanceVariableNames:'width height data byteOrder inStream outStream photometric depth
1648
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
    18
		samplesPerPixel bitsPerSample colorMap mask maskPixel
7375
9675ac6ee423 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7184
diff changeset
    19
		dimensionCallBack dimensionHolder progressHolder imageSequence
9675ac6ee423 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7184
diff changeset
    20
		metaData'
8129
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
    21
	classVariableNames:'BlackCountTable BlackShiftTable LeftBits ReverseBits
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
    22
		WhiteCountTable WhiteShiftTable'
518
f76da6242336 nicer message
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
    23
	poolDictionaries:''
3843
57d7f752c63b code cleanup (colorMap handling)
Claus Gittinger <cg@exept.de>
parents: 3839
diff changeset
    24
	category:'Graphics-Images-Readers'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    25
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    26
8246
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
    27
Query subclass:#EnforcedImageTypeQuery
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
    28
	instanceVariableNames:''
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
    29
	classVariableNames:''
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
    30
	poolDictionaries:''
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
    31
	privateIn:ImageReader
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
    32
!
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
    33
189
claus
parents: 153
diff changeset
    34
!ImageReader primitiveDefinitions!
claus
parents: 153
diff changeset
    35
%{
1891
0dc56210cbfb VMS stuff
Claus Gittinger <cg@exept.de>
parents: 1828
diff changeset
    36
6062
dc9d34b204a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6061
diff changeset
    37
# define STDC_HEADERS
189
claus
parents: 153
diff changeset
    38
#ifndef _STDIO_H_INCLUDED_
claus
parents: 153
diff changeset
    39
# include <stdio.h>
claus
parents: 153
diff changeset
    40
# define _STDIO_H_INCLUDED_
claus
parents: 153
diff changeset
    41
#endif
5973
028f7d7e7e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5927
diff changeset
    42
6061
285d08698c88 osx include
Claus Gittinger <cg@exept.de>
parents: 6060
diff changeset
    43
#if defined(__osx__)
6062
dc9d34b204a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6061
diff changeset
    44
# include <stdlib.h>
6061
285d08698c88 osx include
Claus Gittinger <cg@exept.de>
parents: 6060
diff changeset
    45
# define _MALLOC_H_INCLUDED_
285d08698c88 osx include
Claus Gittinger <cg@exept.de>
parents: 6060
diff changeset
    46
#endif
285d08698c88 osx include
Claus Gittinger <cg@exept.de>
parents: 6060
diff changeset
    47
4401
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
    48
#ifndef _MALLOC_H_INCLUDED_
5973
028f7d7e7e73 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5927
diff changeset
    49
# if !defined(FREEBSD)
6061
285d08698c88 osx include
Claus Gittinger <cg@exept.de>
parents: 6060
diff changeset
    50
#  include <malloc.h>
285d08698c88 osx include
Claus Gittinger <cg@exept.de>
parents: 6060
diff changeset
    51
#  define _MALLOC_H_INCLUDED_
5527
216f389ffe42 freebsd changes
Michael Beyl <mb@exept.de>
parents: 5481
diff changeset
    52
# endif
4401
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
    53
#endif
2423
416882dbf8cf changes for egcs (__new in stdio.h)
Claus Gittinger <cg@exept.de>
parents: 2261
diff changeset
    54
416882dbf8cf changes for egcs (__new in stdio.h)
Claus Gittinger <cg@exept.de>
parents: 2261
diff changeset
    55
189
claus
parents: 153
diff changeset
    56
%}
claus
parents: 153
diff changeset
    57
! !
claus
parents: 153
diff changeset
    58
89
ea2bf46eb669 *** empty log message ***
claus
parents: 81
diff changeset
    59
!ImageReader primitiveFunctions!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    60
%{
48194c26a46c Initial revision
claus
parents:
diff changeset
    61
48194c26a46c Initial revision
claus
parents:
diff changeset
    62
/*
48194c26a46c Initial revision
claus
parents:
diff changeset
    63
 * ccitt decompression
48194c26a46c Initial revision
claus
parents:
diff changeset
    64
 */
48194c26a46c Initial revision
claus
parents:
diff changeset
    65
static short *whiteCountTable;
48194c26a46c Initial revision
claus
parents:
diff changeset
    66
static char  *whiteShiftTable;
48194c26a46c Initial revision
claus
parents:
diff changeset
    67
static short *blackCountTable;
48194c26a46c Initial revision
claus
parents:
diff changeset
    68
static char  *blackShiftTable;
48194c26a46c Initial revision
claus
parents:
diff changeset
    69
48194c26a46c Initial revision
claus
parents:
diff changeset
    70
struct ccitt_def {
48194c26a46c Initial revision
claus
parents:
diff changeset
    71
    unsigned short bits;
48194c26a46c Initial revision
claus
parents:
diff changeset
    72
    short nBits;
48194c26a46c Initial revision
claus
parents:
diff changeset
    73
};
48194c26a46c Initial revision
claus
parents:
diff changeset
    74
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
    75
static struct ccitt_def
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    76
whiteDef[] = {
48194c26a46c Initial revision
claus
parents:
diff changeset
    77
    { 0x3500, 8 }, /* 0 */
48194c26a46c Initial revision
claus
parents:
diff changeset
    78
    { 0x1c00, 6 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    79
    { 0x7000, 4 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    80
    { 0x8000, 4 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    81
    { 0xb000, 4 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    82
    { 0xc000, 4 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    83
    { 0xe000, 4 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    84
    { 0xf000, 4 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    85
    { 0x9800, 5 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    86
    { 0xA000, 5 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    87
    { 0x3800, 5 }, /* 10 */
48194c26a46c Initial revision
claus
parents:
diff changeset
    88
    { 0x4000, 5 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    89
    { 0x2000, 6 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    90
    { 0x0c00, 6 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    91
    { 0xd000, 6 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    92
    { 0xd400, 6 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    93
    { 0xa800, 6 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    94
    { 0xac00, 6 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    95
    { 0x4e00, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    96
    { 0x1800, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    97
    { 0x1000, 7 }, /* 20 */
48194c26a46c Initial revision
claus
parents:
diff changeset
    98
    { 0x2e00, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
    99
    { 0x0600, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   100
    { 0x0800, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   101
    { 0x5000, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   102
    { 0x5600, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   103
    { 0x2600, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   104
    { 0x4800, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   105
    { 0x3000, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   106
    { 0x0200, 8 },
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   107
    { 0x0300, 8 }, /* 30 */
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   108
    { 0x1a00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   109
    { 0x1b00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   110
    { 0x1200, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   111
    { 0x1300, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   112
    { 0x1400, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   113
    { 0x1500, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   114
    { 0x1600, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   115
    { 0x1700, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   116
    { 0x2800, 8 },
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   117
    { 0x2900, 8 }, /* 40 */
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   118
    { 0x2a00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   119
    { 0x2b00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   120
    { 0x2c00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   121
    { 0x2d00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   122
    { 0x0400, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   123
    { 0x0500, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   124
    { 0x0a00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   125
    { 0x0b00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   126
    { 0x5200, 8 },
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   127
    { 0x5300, 8 }, /* 50 */
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   128
    { 0x5400, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   129
    { 0x5500, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   130
    { 0x2400, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   131
    { 0x2500, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   132
    { 0x5800, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   133
    { 0x5900, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   134
    { 0x5a00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   135
    { 0x5b00, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   136
    { 0x4a00, 8 },
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   137
    { 0x4b00, 8 }, /* 60 */
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   138
    { 0x3200, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   139
    { 0x3300, 8 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   140
    { 0x3400, 8 },
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   141
/* ---------------- */
48194c26a46c Initial revision
claus
parents:
diff changeset
   142
    { 0xd800, 5 }, /* 64 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   143
    { 0x9000, 5 }, /* 128 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   144
    { 0x5c00, 6 }, /* 192 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   145
    { 0x6e00, 7 }, /* 256 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   146
    { 0x3600, 8 }, /* 320 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   147
    { 0x3700, 8 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   148
    { 0x6400, 8 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   149
    { 0x6500, 8 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   150
    { 0x6800, 8 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   151
    { 0x6700, 8 }, /* 640 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   152
    { 0x6600, 9 }, /* 704 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   153
    { 0x6680, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   154
    { 0x6900, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   155
    { 0x6980, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   156
    { 0x6a00, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   157
    { 0x6a80, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   158
    { 0x6b00, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   159
    { 0x6b80, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   160
    { 0x6c00, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   161
    { 0x6c80, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   162
    { 0x6d00, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   163
    { 0x6d80, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   164
    { 0x4c00, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   165
    { 0x4c80, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   166
    { 0x4d00, 9 }, /* 1600 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   167
    { 0x6000, 6 }, /* 1664 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   168
    { 0x4d80, 9 }, /* 1728 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   169
/* -------------------------------- */
48194c26a46c Initial revision
claus
parents:
diff changeset
   170
    { 0x0100, 11 }, /* 1792 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   171
    { 0x0180, 11 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   172
    { 0x01a0, 11 }, /* 1920 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   173
    { 0x0120, 12 }, /* 1984 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   174
    { 0x0130, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   175
    { 0x0140, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   176
    { 0x0150, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   177
    { 0x0160, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   178
    { 0x0170, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   179
    { 0x01c0, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   180
    { 0x01d0, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   181
    { 0x01e0, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   182
    { 0x01f0, 12 }, /* 2560 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   183
/* -------------------------------- */
48194c26a46c Initial revision
claus
parents:
diff changeset
   184
    { 0x0010, 12 }, /* EOL */
48194c26a46c Initial revision
claus
parents:
diff changeset
   185
};
48194c26a46c Initial revision
claus
parents:
diff changeset
   186
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   187
static struct ccitt_def
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   188
blackDef[] = {
48194c26a46c Initial revision
claus
parents:
diff changeset
   189
    { 0x0dc0, 10 }, /* 0 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   190
    { 0x4000, 3 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   191
    { 0xc000, 2 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   192
    { 0x8000, 2 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   193
    { 0x6000, 3 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   194
    { 0x3000, 4 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   195
    { 0x2000, 4 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   196
    { 0x1800, 5 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   197
    { 0x1400, 6 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   198
    { 0x1000, 6 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   199
    { 0x0800, 7 }, /* 10 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   200
    { 0x0a00, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   201
    { 0x0e00, 7 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   202
    { 0x0400, 8 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   203
    { 0x0700, 8 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   204
    { 0x0c00, 9 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   205
    { 0x05c0, 10 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   206
    { 0x0600, 10 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   207
    { 0x0200, 10 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   208
    { 0x0ce0, 11 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   209
    { 0x0d00, 11 }, /* 20 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   210
    { 0x0d80, 11 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   211
    { 0x06e0, 11 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   212
    { 0x0500, 11 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   213
    { 0x02e0, 11 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   214
    { 0x0300, 11 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   215
    { 0x0ca0, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   216
    { 0x0cb0, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   217
    { 0x0cc0, 12 },
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   218
    { 0x0cd0, 12 },
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   219
    { 0x0680, 12 }, /* 30 */
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   220
    { 0x0690, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   221
    { 0x06a0, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   222
    { 0x06b0, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   223
    { 0x0d20, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   224
    { 0x0d30, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   225
    { 0x0d40, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   226
    { 0x0d50, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   227
    { 0x0d60, 12 },
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   228
    { 0x0d70, 12 },
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   229
    { 0x06c0, 12 }, /* 40 */
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   230
    { 0x06d0, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   231
    { 0x0da0, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   232
    { 0x0db0, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   233
    { 0x0540, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   234
    { 0x0550, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   235
    { 0x0560, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   236
    { 0x0570, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   237
    { 0x0640, 12 },
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   238
    { 0x0650, 12 },
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   239
    { 0x0520, 12 }, /* 50 */
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   240
    { 0x0530, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   241
    { 0x0240, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   242
    { 0x0370, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   243
    { 0x0380, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   244
    { 0x0270, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   245
    { 0x0280, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   246
    { 0x0580, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   247
    { 0x0590, 12 },
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   248
    { 0x02b0, 12 },
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   249
    { 0x02c0, 12 }, /* 60 */
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   250
    { 0x05a0, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   251
    { 0x0660, 12 },
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   252
    { 0x0670, 12 },
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   253
/* ---------------- */
48194c26a46c Initial revision
claus
parents:
diff changeset
   254
    { 0x03c0, 10 }, /* 64 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   255
    { 0x0c80, 12 }, /* 128 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   256
    { 0x0c90, 12 }, /* 192 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   257
    { 0x05b0, 12 }, /* 256 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   258
    { 0x0330, 12 }, /* 320 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   259
    { 0x0340, 12 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   260
    { 0x0350, 12 }, /* 448 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   261
    { 0x0360, 13 }, /* 512 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   262
    { 0x0368, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   263
    { 0x0250, 13 }, /* 640 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   264
    { 0x0258, 13 }, /* 704 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   265
    { 0x0260, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   266
    { 0x0268, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   267
    { 0x0390, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   268
    { 0x0398, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   269
    { 0x03a0, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   270
    { 0x03a8, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   271
    { 0x03b0, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   272
    { 0x03b8, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   273
    { 0x0290, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   274
    { 0x0298, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   275
    { 0x02a0, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   276
    { 0x02a8, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   277
    { 0x02d0, 13 },
48194c26a46c Initial revision
claus
parents:
diff changeset
   278
    { 0x02d8, 13 }, /* 1600 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   279
    { 0x0320, 13 }, /* 1664 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   280
    { 0x0328, 13 }, /* 1728 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   281
/* -------------------------------- */
48194c26a46c Initial revision
claus
parents:
diff changeset
   282
};
48194c26a46c Initial revision
claus
parents:
diff changeset
   283
6761
7307a75477f4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6618
diff changeset
   284
static void
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   285
initCCITTTables() {
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
   286
    register int cnt, bits, value;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   287
    int nBits, index;
48194c26a46c Initial revision
claus
parents:
diff changeset
   288
48194c26a46c Initial revision
claus
parents:
diff changeset
   289
    if (whiteCountTable != (short *)0) return;
48194c26a46c Initial revision
claus
parents:
diff changeset
   290
48194c26a46c Initial revision
claus
parents:
diff changeset
   291
    whiteCountTable = (short *) malloc(sizeof(short) * 8192);
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   292
    if (! whiteCountTable) return;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   293
    whiteShiftTable = (char *) malloc(sizeof(char) * 8192);
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   294
    if (! whiteShiftTable) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   295
	goto fail1;
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   296
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   297
    blackCountTable = (short *) malloc(sizeof(short) * 8192);
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   298
    if (! blackCountTable) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   299
	goto fail2;
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   300
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   301
    blackShiftTable = (char *) malloc(sizeof(char) * 8192);
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   302
    if (! blackShiftTable) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   303
	free(blackCountTable); blackCountTable = (short *)0;
95
47ac85948d38 asText eliminated
claus
parents: 89
diff changeset
   304
fail2:
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   305
	free(whiteShiftTable); whiteShiftTable = (char *)0;
95
47ac85948d38 asText eliminated
claus
parents: 89
diff changeset
   306
fail1:
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   307
	free(whiteCountTable); whiteCountTable = (short *)0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   308
	return;
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   309
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   310
48194c26a46c Initial revision
claus
parents:
diff changeset
   311
    for (index = 0; index < 8192; index++) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   312
	whiteCountTable[index] = -1;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   313
	blackCountTable[index] = -1;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   314
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
   315
48194c26a46c Initial revision
claus
parents:
diff changeset
   316
    for (value = 0; value <= 63; value++) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   317
	nBits = whiteDef[value].nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   318
	bits = whiteDef[value].bits >> 3;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   319
	for (cnt = 1 << (13 - nBits); cnt; cnt--, bits++) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   320
	    whiteCountTable[bits] = value;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   321
	    whiteShiftTable[bits] = nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   322
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   323
	nBits = blackDef[value].nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   324
	bits = blackDef[value].bits >> 3;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   325
	for (cnt = 1 << (13 - nBits); cnt; cnt--, bits++) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   326
	    blackCountTable[bits] = value;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   327
	    blackShiftTable[bits] = nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   328
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   329
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
   330
    index = value;
48194c26a46c Initial revision
claus
parents:
diff changeset
   331
48194c26a46c Initial revision
claus
parents:
diff changeset
   332
    for (; value <= 1728; value += 64) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   333
	nBits = whiteDef[index].nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   334
	bits = whiteDef[index].bits >> 3;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   335
	for (cnt = 1 << (13 - nBits); cnt; cnt--, bits++) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   336
	    whiteCountTable[bits] = value;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   337
	    whiteShiftTable[bits] = nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   338
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   339
	nBits = blackDef[index].nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   340
	bits = blackDef[index].bits >> 3;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   341
	for (cnt = 1 << (13 - nBits); cnt; cnt--, bits++) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   342
	    blackCountTable[bits] = value;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   343
	    blackShiftTable[bits] = nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   344
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   345
	index++;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   346
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
   347
48194c26a46c Initial revision
claus
parents:
diff changeset
   348
    for (; value <= 2560; value += 64) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   349
	nBits = whiteDef[index].nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   350
	bits = whiteDef[index].bits >> 3;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   351
	for (cnt = 1 << (13 - nBits); cnt; cnt--, bits++) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   352
	    whiteCountTable[bits] = value;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   353
	    whiteShiftTable[bits] = nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   354
	    blackCountTable[bits] = value;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   355
	    blackShiftTable[bits] = nBits;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   356
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   357
	index++;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   358
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
   359
}
48194c26a46c Initial revision
claus
parents:
diff changeset
   360
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   361
static short
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   362
leftBits[] = {
48194c26a46c Initial revision
claus
parents:
diff changeset
   363
     0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF
48194c26a46c Initial revision
claus
parents:
diff changeset
   364
};
48194c26a46c Initial revision
claus
parents:
diff changeset
   365
189
claus
parents: 153
diff changeset
   366
static int
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
   367
__decodeCCITTgroup3__(unsigned char *from, unsigned char *to, int len)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   368
{
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
   369
    register int cnt;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   370
    register short *countPtr;
48194c26a46c Initial revision
claus
parents:
diff changeset
   371
    register char *shiftPtr;
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
   372
    unsigned int bits, bits13;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   373
    int shift, outCount, nBitsLess13;
48194c26a46c Initial revision
claus
parents:
diff changeset
   374
    int outBitOffset;
48194c26a46c Initial revision
claus
parents:
diff changeset
   375
    int nLeft, t;
48194c26a46c Initial revision
claus
parents:
diff changeset
   376
8107
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
   377
    if (! whiteCountTable) {
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
   378
	initCCITTTables();
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
   379
	if (! whiteCountTable) return 0; /* malloc failed */
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
   380
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   381
48194c26a46c Initial revision
claus
parents:
diff changeset
   382
    countPtr = whiteCountTable;
48194c26a46c Initial revision
claus
parents:
diff changeset
   383
    shiftPtr = whiteShiftTable;
48194c26a46c Initial revision
claus
parents:
diff changeset
   384
    outCount = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   385
    outBitOffset = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   386
    bits = *from++;
48194c26a46c Initial revision
claus
parents:
diff changeset
   387
    bits = (bits << 8) | *from++;
48194c26a46c Initial revision
claus
parents:
diff changeset
   388
    nBitsLess13 = 3;
8107
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
   389
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   390
    for (;;) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   391
	bits13 = (bits >> nBitsLess13) & 0x1FFF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   392
	cnt = countPtr[bits13];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   393
	if (cnt < 0) return 1;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   394
	shift = shiftPtr[bits13];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   395
	outCount += cnt;
8107
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
   396
	if (outCount > len) {
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
   397
	    fprintf(stderr, "CCITT buffer overrun\n");
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
   398
	    return 0;
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
   399
	}
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   400
	if (countPtr == blackCountTable) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   401
	    /* toggle if it was a terminating code */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   402
	    if (cnt < 64) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   403
		countPtr = whiteCountTable;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   404
		shiftPtr = whiteShiftTable;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   405
	    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   406
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   407
	    /* draw cnt black bits */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   408
	    if (cnt) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   409
		if (outBitOffset) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   410
		    nLeft = 8 - outBitOffset;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   411
		    if (cnt < nLeft) nLeft = cnt;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   412
		    t = leftBits[nLeft] >> outBitOffset;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   413
		    *to |= t;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   414
		    cnt -= nLeft;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   415
		    outBitOffset += nLeft;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   416
		    if (outBitOffset >= 8) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   417
			to++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   418
			outBitOffset -= 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   419
		    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   420
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   421
		if (cnt > 256) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   422
		    while ((INT)to & 3) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   423
			*to++ = 0xFF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   424
			cnt -= 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   425
		    }
4401
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   426
#if __POINTER_SIZE__ == 8
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   427
		    while ((INT)to & 7) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   428
			*to++ = 0xFF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   429
			cnt -= 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   430
		    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   431
		    while (cnt >= 64) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   432
			(*(INT *)to) = 0xFFFFFFFFFFFFFFFF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   433
			to += 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   434
			cnt -= 64;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   435
		    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   436
		    if (cnt >= 32) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   437
			(*(long *)to) = 0xFFFFFFFF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   438
			to += 4;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   439
			cnt -= 32;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   440
		    }
4401
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   441
#else
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   442
		    while ((INT)to & 3) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   443
			*to++ = 0xFF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   444
			cnt -= 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   445
		    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   446
		    while (cnt >= 32) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   447
			(*(long *)to) = 0xFFFFFFFF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   448
			to += 4;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   449
			cnt -= 32;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   450
		    }
4401
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   451
#endif
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   452
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   453
		while (cnt >= 8) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   454
		    *to++ = 0xFF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   455
		    cnt -= 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   456
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   457
		*to |= leftBits[cnt];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   458
		outBitOffset += cnt;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   459
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   460
	} else {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   461
	    /* toggle if it was a terminating code */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   462
	    if (cnt < 64) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   463
		countPtr = blackCountTable;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   464
		shiftPtr = blackShiftTable;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   465
	    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   466
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   467
	    /* skip cnt bits */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   468
	    to += cnt >> 3;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   469
	    outBitOffset += cnt & 7;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   470
	    if (outBitOffset >= 8) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   471
		to++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   472
		outBitOffset -= 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   473
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   474
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   475
	if (outCount >= len) return 1;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   476
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   477
	nBitsLess13 -= shift;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   478
	while (nBitsLess13 < 0) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   479
	    bits = (bits << 8) | *from++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   480
	    nBitsLess13 += 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   481
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   482
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
   483
}
48194c26a46c Initial revision
claus
parents:
diff changeset
   484
48194c26a46c Initial revision
claus
parents:
diff changeset
   485
/*
48194c26a46c Initial revision
claus
parents:
diff changeset
   486
 * LZW decompression
48194c26a46c Initial revision
claus
parents:
diff changeset
   487
 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   488
struct buffer {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   489
	struct buffer *prev;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   490
	unsigned char chars[8192 - 4];
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   491
};
189
claus
parents: 153
diff changeset
   492
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   493
static int
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
   494
__decodeLZW__(unsigned char *from, unsigned char *to, int inCount, int fromSize, int toSize)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   495
{
48194c26a46c Initial revision
claus
parents:
diff changeset
   496
    register unsigned code;
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   497
    unsigned char **strings;
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   498
    short *stringLen;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   499
    struct buffer *scratchBuffer;
48194c26a46c Initial revision
claus
parents:
diff changeset
   500
    struct buffer *newBuffer;
48194c26a46c Initial revision
claus
parents:
diff changeset
   501
    unsigned char *scratchPtr;
48194c26a46c Initial revision
claus
parents:
diff changeset
   502
    int nScratch;
1262
61bbba463582 lzw_decode caused a SIGSEGV.
Stefan Vogel <sv@exept.de>
parents: 1175
diff changeset
   503
    unsigned nextCode;
61bbba463582 lzw_decode caused a SIGSEGV.
Stefan Vogel <sv@exept.de>
parents: 1175
diff changeset
   504
    int oldCode = -1;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   505
    register unsigned bits;
48194c26a46c Initial revision
claus
parents:
diff changeset
   506
    int nBits, mask, shift;
48194c26a46c Initial revision
claus
parents:
diff changeset
   507
    int i;
48194c26a46c Initial revision
claus
parents:
diff changeset
   508
    int len;
48194c26a46c Initial revision
claus
parents:
diff changeset
   509
    int codeLen = 9;
1988
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   510
    unsigned char *fromEnd, *toEnd;
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   511
    int ret = 1;        /* return success */
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   512
1988
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   513
    fromEnd = from + fromSize;
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   514
    toEnd = to + toSize;
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   515
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   516
    scratchBuffer = (struct buffer *)malloc(sizeof(struct buffer));
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   517
    if (! scratchBuffer) return 0;
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   518
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   519
    strings = (unsigned char **)malloc(sizeof(unsigned char *) * 4096);
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   520
    if (! strings) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   521
	free(scratchBuffer);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   522
	return 0;
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   523
    }
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   524
    stringLen = (short *)malloc(sizeof(short) * 4096);
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   525
    if (! stringLen) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   526
	free(strings);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   527
	free(scratchBuffer);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   528
	return 0;
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   529
    }
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   530
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   531
    scratchBuffer->prev = (struct buffer *)0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   532
    scratchPtr = scratchBuffer->chars;
48194c26a46c Initial revision
claus
parents:
diff changeset
   533
    nScratch = sizeof(scratchBuffer->chars);
48194c26a46c Initial revision
claus
parents:
diff changeset
   534
48194c26a46c Initial revision
claus
parents:
diff changeset
   535
    for (i = 0; i < 256; i++) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   536
	*scratchPtr = i;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   537
	strings[i] = scratchPtr++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   538
	stringLen[i] = 1;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   539
    }
48194c26a46c Initial revision
claus
parents:
diff changeset
   540
48194c26a46c Initial revision
claus
parents:
diff changeset
   541
    nextCode = 258;
48194c26a46c Initial revision
claus
parents:
diff changeset
   542
    nScratch -= 256;
48194c26a46c Initial revision
claus
parents:
diff changeset
   543
    mask = 0x1FF;
48194c26a46c Initial revision
claus
parents:
diff changeset
   544
    nBits = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   545
    bits = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   546
    while (inCount) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   547
	/* fetch code */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   548
	while (nBits < codeLen) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   549
	    bits = (bits<<8) | *from++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   550
	    inCount--;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   551
	    nBits += 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   552
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   553
	shift = nBits - codeLen;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   554
	code = (bits >> shift) & mask;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   555
	bits &= ~(mask << shift);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   556
	nBits -= codeLen;
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   557
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   558
	if (code == 257) break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   559
	if (code == 256) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   560
	    if (! inCount)
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   561
		break;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   562
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   563
	    /* free stuff */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   564
	    while (scratchBuffer->prev) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   565
		newBuffer = scratchBuffer;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   566
		scratchBuffer = scratchBuffer->prev;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   567
		free(newBuffer);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   568
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   569
	    /* reset everything */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   570
	    scratchPtr = scratchBuffer->chars + 256;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   571
	    nScratch = sizeof(scratchBuffer->chars) - 256;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   572
	    codeLen = 9;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   573
	    nextCode = 258;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   574
	    mask = 0x1FF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   575
	    /* fetch code */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   576
	    while (nBits < codeLen) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   577
		bits = (bits<<8) | *from++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   578
		inCount--;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   579
		nBits += 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   580
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   581
	    shift = nBits - codeLen;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   582
	    code = (bits >> shift) & mask;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   583
	    bits &= ~(mask << shift);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   584
	    nBits -= codeLen;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   585
	    if (code == 257) break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   586
	    /* add to output */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   587
	    if (to >= toEnd) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   588
		if (@global(InfoPrinting) == true) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   589
		    console_fprintf(stderr, "ImageReader [warning]: LZW outBuffer overrun\n");
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   590
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   591
		ret = 0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   592
		break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   593
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   594
	    *to++ = code;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   595
	    oldCode = code;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   596
	} else {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   597
	    if (code < nextCode) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   598
		/* writeString(string[code]) */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   599
		len = stringLen[code];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   600
		bcopy(strings[code], to, len);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   601
		to += len;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   602
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   603
		if (oldCode != -1) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   604
		    /* add( string[oldcode] + first(string[code]) ) */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   605
		    len = stringLen[oldCode] + 1;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   606
		    if (nScratch < len) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   607
			newBuffer = (struct buffer *)malloc(sizeof(struct buffer));
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   608
			if (! newBuffer) goto out;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   609
			newBuffer->prev = scratchBuffer;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   610
			scratchBuffer = newBuffer;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   611
			scratchPtr = scratchBuffer->chars;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   612
			nScratch = sizeof(scratchBuffer->chars);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   613
		    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   614
		    stringLen[nextCode] = len;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   615
		    strings[nextCode] = scratchPtr;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   616
		    bcopy(strings[oldCode], scratchPtr, len-1);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   617
		    scratchPtr += len-1;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   618
		    *scratchPtr++ = strings[code][0];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   619
		    nScratch -= len;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   620
		    nextCode++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   621
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   622
	    } else {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   623
		if (oldCode == -1) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   624
		    /* bad input */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   625
		    ret = 0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   626
		    goto out;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   627
		}
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
   628
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   629
		/* writeString(string[oldCode] + first(string[oldCode]) ) */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   630
		len = stringLen[oldCode];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   631
		if ((to+len) >= toEnd) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   632
		    if (@global(InfoPrinting) == true) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   633
			console_fprintf(stderr, "ImageReader [warning]: LZW outBuffer overrun\n");
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   634
		    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   635
		    ret = 0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   636
		    goto out;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   637
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   638
		bcopy(strings[oldCode], to, len);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   639
		to += len;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   640
		*to++ = strings[oldCode][0];
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   641
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   642
		/* add( string[oldcode] + first(string[oldCode]) ) */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   643
		len++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   644
		if (nScratch < len) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   645
		    newBuffer = (struct buffer *)malloc(sizeof(struct buffer));
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   646
		    if (! newBuffer) goto out;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   647
		    newBuffer->prev = scratchBuffer;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   648
		    scratchBuffer = newBuffer;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   649
		    scratchPtr = scratchBuffer->chars;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   650
		    nScratch = sizeof(scratchBuffer->chars);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   651
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   652
		stringLen[nextCode] = len;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   653
		strings[nextCode] = scratchPtr;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   654
		bcopy(strings[oldCode], scratchPtr, len-1);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   655
		scratchPtr += len-1;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   656
		*scratchPtr++ = strings[oldCode][0];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   657
		nScratch -= len;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   658
		nextCode++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   659
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   660
	    oldCode = code;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   661
	    if (nextCode >= 511) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   662
		if (nextCode == 511) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   663
		    codeLen = 10;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   664
		    mask = 0x3FF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   665
		} else if (nextCode >= 1023) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   666
		    if (nextCode == 1023) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   667
			codeLen = 11;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   668
			mask = 0x7FF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   669
		    } else {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   670
			if (nextCode == 2047) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   671
			    codeLen = 12;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   672
			    mask = 0xFFF;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   673
			}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   674
		    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   675
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   676
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   677
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   678
    }
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   679
out: ;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   680
    /* free stuff */
48194c26a46c Initial revision
claus
parents:
diff changeset
   681
    while (scratchBuffer) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   682
	newBuffer = scratchBuffer;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   683
	scratchBuffer = scratchBuffer->prev;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   684
	free(newBuffer);
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   685
    }
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   686
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   687
    free(strings);
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   688
    free(stringLen);
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   689
1988
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   690
    if (from > fromEnd) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   691
	if (@global(InfoPrinting) == true) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   692
	    console_fprintf(stderr, "ImageReader [warning]: LZW inBuffer overrun\n");
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   693
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   694
	ret = 0;
1988
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   695
    }
1262
61bbba463582 lzw_decode caused a SIGSEGV.
Stefan Vogel <sv@exept.de>
parents: 1175
diff changeset
   696
    return ret;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   697
}
48194c26a46c Initial revision
claus
parents:
diff changeset
   698
48194c26a46c Initial revision
claus
parents:
diff changeset
   699
/*
48194c26a46c Initial revision
claus
parents:
diff changeset
   700
 * delta decoding (TIFF predictor = 2)
48194c26a46c Initial revision
claus
parents:
diff changeset
   701
 */
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   702
static void
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   703
__decodeDelta3__(register unsigned char *bytes, int width, int height)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   704
{
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
   705
	register int w;
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   706
	unsigned char r, g, b;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   707
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   708
	while (height--) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   709
	    r = g = b = 0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   710
	    for (w = width; w; w--) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   711
		r += *bytes;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   712
		*bytes++ = r;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   713
		g += *bytes;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   714
		*bytes++ = g;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   715
		b += *bytes;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   716
		*bytes++ = b;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   717
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   718
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   719
}
48194c26a46c Initial revision
claus
parents:
diff changeset
   720
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   721
/*
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   722
 * delta decoding (TIFF predictor = 2)
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   723
 */
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   724
static void
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   725
__decodeDelta4__(register unsigned char *bytes, int width, int height)
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   726
{
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   727
	register int w;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   728
	unsigned char r, g, b, a;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   729
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   730
	while (height--) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   731
	    r = g = b = a = 0;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   732
	    for (w = width; w; w--) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   733
		r += *bytes;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   734
		*bytes++ = r;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   735
		g += *bytes;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   736
		*bytes++ = g;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   737
		b += *bytes;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   738
		*bytes++ = b;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   739
		a += *bytes;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   740
		*bytes++ = a;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   741
	    }
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   742
	}
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   743
}
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   744
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
   745
/*
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   746
 * GIF decompression
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   747
 */
189
claus
parents: 153
diff changeset
   748
static int
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
   749
__decodeGIF__(unsigned char *from, unsigned char *to, int inCount, int initialCodeLen, int fromSize, int toSize)
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   750
{
48194c26a46c Initial revision
claus
parents:
diff changeset
   751
    register unsigned code;
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
   752
    // #define GIF_PREFIX_SUFFIX_SIZE 4096
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
   753
    #define GIF_PREFIX_SUFFIX_SIZE (4096*2)
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   754
    unsigned short *prefix;
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   755
    unsigned short *suffix;
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   756
    unsigned short *outCode;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   757
    int outCount;
48194c26a46c Initial revision
claus
parents:
diff changeset
   758
    unsigned maxCode, oldCode, fin, inCode, curCode;
48194c26a46c Initial revision
claus
parents:
diff changeset
   759
    register unsigned bits;
48194c26a46c Initial revision
claus
parents:
diff changeset
   760
    register int nBits, mask, shift;
1988
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   761
    int ret = 1;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   762
    int i;
48194c26a46c Initial revision
claus
parents:
diff changeset
   763
    int len;
48194c26a46c Initial revision
claus
parents:
diff changeset
   764
    int endCode, clearCode, freeCode;
48194c26a46c Initial revision
claus
parents:
diff changeset
   765
    int codeLen = initialCodeLen;
1988
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   766
    unsigned char *fromEnd, *toEnd;
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   767
    static int ranges[] = {0, 1, 2, 4, 8, 16, 32, 64,
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   768
			   128, 256, 512, 1024, 2048 };
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   769
1988
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   770
    fromEnd = from + fromSize;
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   771
    toEnd = to + toSize;
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   772
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   773
    if ((unsigned)codeLen > 12) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   774
	if (@global(InfoPrinting) == true) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   775
	    console_fprintf(stderr, "ImageReader [warning]: GIF bad codelen (>12)\n");
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   776
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   777
	return 0;
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   778
    }
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
   779
    prefix = (unsigned short *)malloc(sizeof(short) * GIF_PREFIX_SUFFIX_SIZE);
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   780
    if (! prefix) return 0;
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
   781
    suffix  = (unsigned short *)malloc(sizeof(short) * GIF_PREFIX_SUFFIX_SIZE);
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   782
    if (! suffix) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   783
	free(prefix);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   784
	return 0;
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   785
    }
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
   786
    outCode = (unsigned short *)malloc(sizeof(short) * GIF_PREFIX_SUFFIX_SIZE);
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   787
    if (! outCode) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   788
	free(prefix);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   789
	free(suffix);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   790
	return 0;
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   791
    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   792
    clearCode = ranges[codeLen]; /* 256 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   793
    endCode = clearCode + 1;     /* 257 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   794
    freeCode = clearCode + 2;    /* 258 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   795
    maxCode = clearCode << 1;    /* 512 */
48194c26a46c Initial revision
claus
parents:
diff changeset
   796
    outCount = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   797
48194c26a46c Initial revision
claus
parents:
diff changeset
   798
    mask = maxCode - 1;          /* 1FF */
48194c26a46c Initial revision
claus
parents:
diff changeset
   799
    nBits = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   800
    bits = 0;
48194c26a46c Initial revision
claus
parents:
diff changeset
   801
    while (inCount) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   802
	/* fetch code */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   803
	while (nBits < codeLen) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   804
	    bits = bits | (*from++ << nBits);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   805
	    inCount--;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   806
	    nBits += 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   807
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   808
	if (inCount <= 0)
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   809
	    break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   810
	code = bits & mask;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   811
	bits >>= codeLen;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   812
	nBits -= codeLen;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   813
	if (code == endCode) break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   814
	if (code == clearCode) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   815
	    if (inCount <= 0)
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   816
		break;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   817
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   818
	    codeLen = initialCodeLen;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   819
	    maxCode = clearCode<<1;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   820
	    mask = maxCode - 1;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   821
	    freeCode = clearCode + 2;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   822
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   823
	    /* fetch code */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   824
	    while (nBits < codeLen) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   825
		bits = bits | (*from++ << nBits);
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   826
		inCount--;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   827
		nBits += 8;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   828
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   829
	    if (inCount <= 0)
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   830
		break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   831
	    code = bits & mask;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   832
	    bits >>= codeLen;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   833
	    nBits -= codeLen;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   834
	    if (code == endCode) break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   835
	    /* add to output */
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   836
	    if (to >= toEnd) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   837
		if (@global(InfoPrinting) == true) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   838
		    console_fprintf(stderr, "ImageReader [warning]: GIF outBuffer overrun\n");
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   839
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   840
		ret = 0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   841
		break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   842
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   843
	    *to++ = code;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   844
	    oldCode = fin = curCode = code;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   845
	} else {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   846
	    curCode = inCode = code;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   847
	    if (curCode >= freeCode) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   848
		curCode = oldCode;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   849
		outCode[outCount++] = fin;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   850
	    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   851
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   852
	    while (curCode >= clearCode) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   853
		if (outCount > 1024) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   854
		    goto out;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   855
		}
2261
740be162343e check to avoid overwriting
Claus Gittinger <cg@exept.de>
parents: 2152
diff changeset
   856
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   857
		/* debugging and protecting myself from overwrites */
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
   858
		if (curCode > (GIF_PREFIX_SUFFIX_SIZE-1)) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   859
		    if (@global(InfoPrinting) == true) {
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
   860
			console_fprintf(stderr, "ImageReader [warning]: GIF corrupted input (code > %d)\n", (GIF_PREFIX_SUFFIX_SIZE-1));
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   861
		    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   862
		    ret = 0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   863
		    break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   864
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   865
		outCode[outCount++] = suffix[curCode];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   866
		curCode = prefix[curCode];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   867
	    }
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   868
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   869
	    fin = curCode;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   870
	    outCode[outCount++] = fin;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   871
2014
bcae1c2c32e4 fixed destination-array boundary check (in GIF-decode)
Claus Gittinger <cg@exept.de>
parents: 1988
diff changeset
   872
#if 0
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   873
	    if ((to+outCount) >= toEnd) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   874
		if (@global(InfoPrinting) == true) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   875
		    console_fprintf(stderr, "ImageReader [warning]: GIF outBuffer overrun\n");
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   876
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   877
		ret = 0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   878
		break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   879
	    }
2014
bcae1c2c32e4 fixed destination-array boundary check (in GIF-decode)
Claus Gittinger <cg@exept.de>
parents: 1988
diff changeset
   880
#endif
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   881
	    for (i = outCount - 1; i >= 0; i--) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   882
		if (to >= toEnd) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   883
		    if (@global(InfoPrinting) == true) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   884
			console_fprintf(stderr, "ImageReader [warning]: GIF outBuffer overrun\n");
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   885
		    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   886
		    ret = 0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   887
		    break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   888
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   889
		*to++ = outCode[i];
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   890
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   891
	    outCount = 0;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   892
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   893
	    /* debugging and protecting myself from overwrites */
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
   894
	    if (freeCode > (GIF_PREFIX_SUFFIX_SIZE-1)) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   895
		if (@global(InfoPrinting) == true) {
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
   896
		    console_fprintf(stderr, "ImageReader [warning]: GIF corrupted input (freeCode > %d)\n", (GIF_PREFIX_SUFFIX_SIZE-1));
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   897
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   898
		ret = 0;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   899
		break;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   900
	    }
2261
740be162343e check to avoid overwriting
Claus Gittinger <cg@exept.de>
parents: 2152
diff changeset
   901
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   902
	    prefix[freeCode] = oldCode;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   903
	    suffix[freeCode] = fin;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   904
	    oldCode = inCode;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   905
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   906
	    freeCode++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   907
	    if (freeCode >= maxCode) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   908
		if (codeLen < 12) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   909
		    codeLen++;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   910
		    maxCode *= 2;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   911
		    mask = (1 << codeLen) - 1;
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   912
		}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   913
	    }
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   914
	}
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   915
    }
12
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   916
out: ;
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   917
    free(prefix);
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   918
    free(suffix);
9f0995fac1fa *** empty log message ***
claus
parents: 6
diff changeset
   919
    free(outCode);
46
7b331e9012fd *** empty log message ***
claus
parents: 35
diff changeset
   920
1988
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   921
    if (from > fromEnd) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   922
	if (@global(InfoPrinting) == true) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   923
	    console_fprintf(stderr, "ImageReader [warning]: GIF inBuffer overrun\n");
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   924
	}
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   925
	ret = 0;
1988
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   926
    }
528dbff6ca26 do not overwrite provided output buffer when decompressing
Claus Gittinger <cg@exept.de>
parents: 1983
diff changeset
   927
    return ret;
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   928
}
48194c26a46c Initial revision
claus
parents:
diff changeset
   929
48194c26a46c Initial revision
claus
parents:
diff changeset
   930
%}
77
da4678fae5c8 *** empty log message ***
claus
parents: 72
diff changeset
   931
! !
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   932
1167
4998857f7a9a new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   933
!ImageReader class methodsFor:'documentation'!
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   934
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   935
copyright
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   936
"
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   937
 COPYRIGHT (c) 1991 by Claus Gittinger
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   938
	      All Rights Reserved
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   939
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   940
 This software is furnished under a license and may be used
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   941
 only in accordance with the terms of that license and with the
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   942
 inclusion of the above copyright notice.   This software may not
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   943
 be provided or otherwise made available to, or used by, any
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   944
 other person.  No title to or ownership of the software is
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   945
 hereby transferred.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   946
"
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   947
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   948
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   949
documentation
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   950
"
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   951
    Abstract class to provide common functions for image-readers/writers.
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   952
    (i.e. TIFFReader, GIFReader etc.).
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   953
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   954
    In contrast to what the name suggests, ImageReaders are supposed to support
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   955
    both reading and writing of images
6058
7c5c40861f50 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6057
diff changeset
   956
    (i.e. the name is somewhat outdated, but kept for historic and backward
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   957
    compatibility reasons).
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   958
    They provide functionality similar to Squeak's ImageReaderWriter classes.
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   959
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   960
    ImageReaders are created temporary to read an image from a stream.
618
5d5277119897 commentart
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   961
    Normally, they are not directly used - instead, the image class is
5d5277119897 commentart
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   962
    asked to read some file, and return an instance for it:
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   963
	Image fromFile:<someFileName>
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   964
    The Image class will guess the image's format and forward the task to
618
5d5277119897 commentart
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   965
    some concrete ImageReaderClass.
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
   966
    If that class thinks, that the file's format is incorrect,
6508
589f02f1a068 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6377
diff changeset
   967
    other readers are tried until some reader class finds the file's format acceptable.
618
5d5277119897 commentart
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   968
5d5277119897 commentart
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   969
    Image readers read the stream and collect all relevant information internally.
118
25e775072a89 *** empty log message ***
claus
parents: 105
diff changeset
   970
    Once done with reading, the actual image object is created and
25e775072a89 *** empty log message ***
claus
parents: 105
diff changeset
   971
    data filled in from the imageReaders collected info.
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   972
618
5d5277119897 commentart
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   973
    See the implementation of #fromStream: in concrete subclasses.
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   974
    The public interfaces are:
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   975
	 <ConcreteReaderClass> fromFile:aFilename
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   976
    or:
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   977
	 <ConcreteReaderClass> fromStream:aStream
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   978
6058
7c5c40861f50 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6057
diff changeset
   979
    If you add a new reader, don't forget to add the method #isValidImageFile:
618
5d5277119897 commentart
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   980
    which should return true, if this reader supports reading a given file.
6058
7c5c40861f50 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6057
diff changeset
   981
7c5c40861f50 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6057
diff changeset
   982
    If your new reader class supports writing files, don't forget to add
618
5d5277119897 commentart
Claus Gittinger <cg@exept.de>
parents: 611
diff changeset
   983
    #canRepresent:anImage and return true from this method.
593
a3264954cf83 commentary
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   984
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
   985
    writing:
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   986
	tell the image, to save itself, via <image> saveOn:fileName
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   987
	or <image> saveOn:fileName using:<readerClass>
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   988
593
a3264954cf83 commentary
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   989
    [See also:]
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   990
	Image Icon Form
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   991
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 593
diff changeset
   992
    [author:]
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
   993
	Claus Gittinger
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   994
"
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   995
! !
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
   996
1358
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   997
!ImageReader class methodsFor:'instance creation'!
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   998
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   999
new
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  1000
    ^ self basicNew initialize
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  1001
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  1002
    "Created: 18.2.1997 / 17:08:45 / cg"
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  1003
! !
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  1004
1167
4998857f7a9a new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  1005
!ImageReader class methodsFor:'cleanup'!
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1006
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1007
lowSpaceCleanup
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1008
    "cleanup things we do not need"
118
25e775072a89 *** empty log message ***
claus
parents: 105
diff changeset
  1009
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1010
    ReverseBits := nil
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1011
! !
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1012
1167
4998857f7a9a new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  1013
!ImageReader class methodsFor:'constants'!
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1014
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1015
reverseBits
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1016
    "return a table filled with bit reverse information.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1017
     To convert from msbit-first to lsbit-first bytes, use
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1018
     the value as index into the table, retrieving the reverse
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1019
     value. Since indexing must start at 1, use (value + 1) as
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1020
     index."
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1021
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1022
    |val "{ Class: SmallInteger }" |
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1023
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1024
    ReverseBits isNil ifTrue:[
153
claus
parents: 134
diff changeset
  1025
	ReverseBits := ByteArray uninitializedNew:256.
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1026
	0 to:255 do:[:i |
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1027
	    val := 0.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1028
	    (i bitTest:16r01) ifTrue:[val := val bitOr:16r80].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1029
	    (i bitTest:16r02) ifTrue:[val := val bitOr:16r40].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1030
	    (i bitTest:16r04) ifTrue:[val := val bitOr:16r20].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1031
	    (i bitTest:16r08) ifTrue:[val := val bitOr:16r10].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1032
	    (i bitTest:16r10) ifTrue:[val := val bitOr:16r08].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1033
	    (i bitTest:16r20) ifTrue:[val := val bitOr:16r04].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1034
	    (i bitTest:16r40) ifTrue:[val := val bitOr:16r02].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1035
	    (i bitTest:16r80) ifTrue:[val := val bitOr:16r01].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1036
	    ReverseBits at:(i + 1) put:val
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1037
	]
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1038
    ].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1039
    ^ ReverseBits
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1040
! !
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1041
1167
4998857f7a9a new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  1042
!ImageReader class methodsFor:'decompression support'!
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1043
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1044
_decompressCCITT3From:src count:inCount into:dst startingAt:dstIndexIn 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1045
    |srcIndex dstIndex countTable shiftTable 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1046
     outCount outBitOffset bits nBitsLess13 bits13 cnt shift
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1047
     nLeft t leftBits|
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1048
    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1049
    WhiteCountTable isNil ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1050
        self initCCITTTables.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1051
    ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1052
    countTable := WhiteCountTable.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1053
    shiftTable := WhiteShiftTable.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1054
    leftBits := #[ 0 16r80 16rC0 16rE0 16rF0 16rF8 16rFC 16rFE 16rFF ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1055
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1056
    srcIndex := 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1057
    dstIndex := dstIndexIn.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1058
    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1059
    outCount := 0.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1060
    outBitOffset := 0.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1061
    bits := ((src at:srcIndex) bitShift:8) bitOr:(src at:srcIndex+1).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1062
    srcIndex := srcIndex + 2.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1063
    nBitsLess13 := 3.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1064
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1065
    [
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1066
        bits13 := (bits rightShift: nBitsLess13) bitAnd: 16r1FFF.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1067
        cnt := countTable at:(bits13+1).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1068
        cnt < 0 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1069
            ^ dstIndex
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1070
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1071
        shift := shiftTable at:(bits13+1).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1072
        outCount := outCount + cnt.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1073
        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1074
        countTable == BlackCountTable ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1075
            "/ toggle if it was a terminating code
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1076
            cnt < 64 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1077
                countTable := WhiteCountTable.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1078
                shiftTable := WhiteShiftTable
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1079
            ].    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1080
            "/ draw cnt black bits 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1081
            cnt ~~ 0 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1082
                outBitOffset > 0 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1083
                    nLeft := 8 - outBitOffset.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1084
                    (cnt < nLeft) ifTrue:[ nLeft := cnt ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1085
                    t := (leftBits at:(nLeft+1)) rightShift: outBitOffset.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1086
                    dst at:dstIndex put: ((dst at:dstIndex) bitOr:(t bitAnd:16rFF)).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1087
                    cnt := cnt - nLeft.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1088
                    outBitOffset := outBitOffset + nLeft.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1089
                    (outBitOffset >= 8) ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1090
                        dstIndex := dstIndex + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1091
                        outBitOffset := outBitOffset - 8.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1092
                    ]
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1093
                ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1094
                [ cnt >= 8 ] whileTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1095
                    dst at:dstIndex put:16rFF.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1096
                    dstIndex := dstIndex + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1097
                    cnt := cnt - 8.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1098
                ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1099
                dst at:dstIndex put:((dst at:dstIndex) bitOr:(leftBits at:(cnt+1))).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1100
                outBitOffset := outBitOffset + cnt.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1101
            ]
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1102
        ] ifFalse:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1103
            "/ toggle if it was a terminating code
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1104
            cnt < 64 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1105
                countTable := BlackCountTable.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1106
                shiftTable := BlackShiftTable
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1107
            ].    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1108
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1109
            "/ skip cnt bits
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1110
            dstIndex := dstIndex + (cnt rightShift: 3).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1111
            outBitOffset := outBitOffset + (cnt bitAnd: 7).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1112
            (outBitOffset >= 8)  ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1113
                dstIndex := dstIndex + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1114
                outBitOffset := outBitOffset - 8.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1115
            ]
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1116
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1117
        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1118
        nBitsLess13 := nBitsLess13 - shift.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1119
        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1120
        "/ fill bits from the input
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1121
        [ nBitsLess13 < 0 ] whileTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1122
            srcIndex > inCount ifTrue:[^ 1].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1123
            
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1124
            bits := (bits bitShift:8) bitOr:( src at:srcIndex ).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1125
            srcIndex := srcIndex + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1126
            nBitsLess13 := nBitsLess13 + 8.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1127
        ].        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1128
    ] loop.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1129
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1130
    "Created: / 25-08-2017 / 13:34:29 / cg"
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1131
    "Modified: / 26-08-2017 / 18:12:15 / cg"
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1132
!
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1133
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1134
_decompressCCITT3From:src count:inCount into:dst startingAt:dstIndexIn count:len
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1135
    |srcIndex dstIndex countTable shiftTable 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1136
     outCount outBitOffset bits nBitsLess13 bits13 cnt shift
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1137
     nLeft t leftBits|
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1138
    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1139
    WhiteCountTable isNil ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1140
        self initCCITTTables.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1141
    ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1142
    countTable := WhiteCountTable.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1143
    shiftTable := WhiteShiftTable.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1144
    leftBits := #[ 0 16r80 16rC0 16rE0 16rF0 16rF8 16rFC 16rFE 16rFF ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1145
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1146
    srcIndex := 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1147
    dstIndex := dstIndexIn.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1148
    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1149
    outCount := 0.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1150
    outBitOffset := 0.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1151
    bits := ((src at:srcIndex) bitShift:8) bitOr:(src at:srcIndex+1).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1152
    srcIndex := srcIndex + 2.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1153
    nBitsLess13 := 3.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1154
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1155
    [
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1156
        bits13 := (bits rightShift: nBitsLess13) bitAnd: 16r1FFF.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1157
        cnt := countTable at:(bits13+1).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1158
        cnt < 0 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1159
            ^ 1
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1160
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1161
        shift := shiftTable at:(bits13+1).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1162
        outCount := outCount + cnt.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1163
        outCount > len ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1164
            self error:'out buffer overflow'.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1165
            ^ 0
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1166
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1167
        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1168
        countTable == BlackCountTable ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1169
            "/ toggle if it was a terminating code
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1170
            cnt < 64 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1171
                countTable := WhiteCountTable.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1172
                shiftTable := WhiteShiftTable
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1173
            ].    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1174
            "/ draw cnt black bits 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1175
            cnt > 0 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1176
                outBitOffset > 0 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1177
                    nLeft := 8 - outBitOffset.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1178
                    (cnt < nLeft) ifTrue:[ nLeft := cnt ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1179
                    t := (leftBits at:(nLeft+1)) rightShift: outBitOffset.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1180
                    dst at:dstIndex put: ((dst at:dstIndex) bitOr:(t bitAnd:16rFF)).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1181
                    cnt := cnt - nLeft.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1182
                    outBitOffset := outBitOffset + nLeft.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1183
                    (outBitOffset >= 8) ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1184
                        dstIndex := dstIndex + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1185
                        outBitOffset := outBitOffset - 8.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1186
                    ]
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1187
                ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1188
                [ cnt >= 8 ] whileTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1189
                    dst at:dstIndex put:16rFF.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1190
                    dstIndex := dstIndex + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1191
                    cnt := cnt - 8.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1192
                ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1193
                dst at:dstIndex put:((dst at:dstIndex) bitOr:(leftBits at:(cnt+1))).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1194
                outBitOffset := outBitOffset + cnt.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1195
            ]
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1196
        ] ifFalse:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1197
            "/ toggle if it was a terminating code
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1198
            cnt < 64 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1199
                countTable := BlackCountTable.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1200
                shiftTable := BlackShiftTable
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1201
            ].    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1202
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1203
            "/ skip cnt bits
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1204
            dstIndex := dstIndex + (cnt rightShift: 3).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1205
            outBitOffset := outBitOffset + (cnt bitAnd: 7).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1206
            (outBitOffset >= 8)  ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1207
                dstIndex := dstIndex + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1208
                outBitOffset := outBitOffset - 8.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1209
            ]
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1210
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1211
        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1212
        outCount >= len ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1213
            ^ 1
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1214
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1215
        nBitsLess13 := nBitsLess13 - shift.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1216
        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1217
        "/ fill bits from the input
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1218
        [ nBitsLess13 < 0 ] whileTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1219
            bits := (bits bitShift:8) bitOr:( src at:srcIndex ).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1220
            srcIndex := srcIndex + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1221
            nBitsLess13 := nBitsLess13 + 8.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1222
        ].        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1223
    ] loop.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1224
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1225
    "
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1226
     |bytes outBytes|
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1227
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1228
     bytes := '/Users/cg/DownloadsUnsaved/images/software/libtiffpic/g3test.g3'
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1229
                asFilename binaryContentsOfEntireFile.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1230
     outBytes := ByteArray new:100000.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1231
     ImageReader 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1232
        _decompressCCITT3From:bytes
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1233
        count:bytes size    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1234
        into:outBytes
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1235
        startingAt:1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1236
    "
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1237
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1238
    "Created: / 26-08-2017 / 14:16:54 / cg"
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1239
!
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1240
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1241
decodeDelta:step in:data width:width height:height
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1242
    "perform TIFF predictor = 2 delta decoding inplace on data.
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1243
     Calls primitive c function for speed"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1244
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1245
    |idx values ov nv|
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1246
    
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1247
    (step == 3) ifTrue:[
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1248
%{
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1249
        if (__isByteArray(data)
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1250
         && __bothSmallInteger(width, height)) {
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1251
            __decodeDelta3__(__ByteArrayInstPtr(data)->ba_element,
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1252
                             __intVal(width), __intVal(height));
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1253
            RETURN ( self );
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1254
        }
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1255
%}.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1256
    ].
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1257
    (step == 4) ifTrue:[
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1258
%{
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1259
        if (__isByteArray(data)
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1260
         && __bothSmallInteger(width, height)) {
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1261
            __decodeDelta4__(__ByteArrayInstPtr(data)->ba_element,
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1262
                             __intVal(width), __intVal(height));
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1263
            RETURN ( self );
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1264
        }
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1265
%}.
8102
e60aac8eccb9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8101
diff changeset
  1266
    ].
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1267
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1268
    "/ slow fallback
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1269
    idx := 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1270
    1 to:height do:[:y |
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1271
        values := Array new:step withAll:0.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1272
        1 to:width do:[:x |
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1273
            1 to:step do:[:chNr |
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1274
                ov := (values at:chNr).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1275
                nv := (ov + (data at:idx)) bitAnd:16rFF.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1276
                values at:chNr put:nv.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1277
                data at:idx put:nv.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1278
                idx := idx + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1279
            ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1280
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1281
    ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1282
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1283
    "Modified: / 27-08-2017 / 16:52:37 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1284
!
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1285
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  1286
decompressCCITT3From:srcBytes into:dstBytes startingAt:offset count:count
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1287
    "decompress CCITT Group 3 compressed image data.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1288
     count bytes from srcBytes are decompressed into dstBytes.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1289
     Calls primitive c function for speed"
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1290
%{
5481
93de6ee2ed5a __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5318
diff changeset
  1291
    if (__isByteArrayLike(srcBytes)
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1292
     && __isByteArray(dstBytes)
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1293
     && __bothSmallInteger(offset, count)) {
8107
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
  1294
	int _count = __intVal(count);
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
  1295
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
  1296
	if (_count > __byteArraySize(dstBytes)) {
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
  1297
	    _count = __byteArraySize(dstBytes);
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
  1298
	}
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1299
	if (__decodeCCITTgroup3__(__ByteArrayInstPtr(srcBytes)->ba_element,
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1300
				  __ByteArrayInstPtr(dstBytes)->ba_element
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1301
				  + __intVal(offset) - 1,
8107
154acb64bf45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8102
diff changeset
  1302
				  _count)) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1303
	    RETURN ( self );
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1304
	}
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1305
    }
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1306
%}
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1307
.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1308
    self primitiveFailed
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1309
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1310
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1311
decompressGIFFrom:srcBytes count:count into:dstBytes startingAt:offset codeLen:codeLen
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1312
    "decompress GIF compressed image data.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1313
     count bytes from srcBytes are decompressed into dstBytes.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1314
     Calls primitive c function for speed"
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1315
%{
5481
93de6ee2ed5a __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5318
diff changeset
  1316
    if (__isByteArrayLike(srcBytes)
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1317
     && __isByteArray(dstBytes)
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1318
     && __bothSmallInteger(codeLen, offset)
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1319
     && __isSmallInteger(count)) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1320
	if (__decodeGIF__(__ByteArrayInstPtr(srcBytes)->ba_element,
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1321
			  __ByteArrayInstPtr(dstBytes)->ba_element
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1322
						+__intVal(offset) - 1,
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1323
			  __intVal(count),
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1324
			  __intVal(codeLen),
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1325
			  __byteArraySize(srcBytes),
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1326
			  __byteArraySize(dstBytes)
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1327
			 )) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1328
	    RETURN ( self );
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1329
	}
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1330
    }
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1331
%}
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1332
.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1333
    self primitiveFailed
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1334
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1335
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1336
decompressLZWFrom:srcBytes count:count into:dstBytes startingAt:offset
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1337
    "decompress LZW (tiff) compressed image data.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1338
     count bytes from srcBytes are decompressed into dstBytes.
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1339
     Calls primitive c function for speed"
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1340
%{
5481
93de6ee2ed5a __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5318
diff changeset
  1341
    if (__isByteArrayLike(srcBytes)
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1342
     && __isByteArray(dstBytes)
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1343
     && __bothSmallInteger(offset, count)) {
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1344
	if (__decodeLZW__(__ByteArrayInstPtr(srcBytes)->ba_element,
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1345
			  __ByteArrayInstPtr(dstBytes)->ba_element
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1346
					      + __intVal(offset) - 1,
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1347
			  __intVal(count),
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1348
			  __byteArraySize(srcBytes),
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1349
			  __byteArraySize(dstBytes)
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1350
			)) {
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1351
	    RETURN ( self );
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1352
	}
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1353
    }
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1354
%}
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1355
.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  1356
    self primitiveFailed
189
claus
parents: 153
diff changeset
  1357
!
claus
parents: 153
diff changeset
  1358
6585
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1359
decompressPackBits:nIn from:srcBytes to:dstBytes startingAt:dstOffset
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1360
    "decompress a number of input bytes.
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1361
     Used by tiff and some mac image formats.
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1362
     Return the number of decompressed output bytes."
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1363
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1364
    |i b n v dstOffs|
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1365
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1366
    dstOffs := dstOffset.
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1367
    i := 1.
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1368
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1369
    [i <= nIn] whileTrue:[
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1370
	b := srcBytes at:i.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1371
	i := i + 1.
6585
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1372
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1373
	b ~~ 16rFF ifTrue:[   "/ not a NOP
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1374
	    b <= 127 ifTrue:[
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1375
		"/ 0..127 literal bytes
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1376
		n := b + 1.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1377
		dstBytes replaceFrom:dstOffs to:dstOffs+n-1 with:srcBytes startingAt:i.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1378
		i := i + n.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1379
	    ] ifFalse:[
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1380
		"/ 128..254 a run
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1381
		n := b - 125.
6585
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1382
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1383
		v := srcBytes at:i.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1384
		i := i + 1.
6585
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1385
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1386
		dstBytes from:dstOffs to:dstOffs+n put:v.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1387
	    ].
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1388
	    dstOffs := dstOffs + n.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  1389
	]
6585
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1390
    ].
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1391
    ^ dstOffs - dstOffset
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1392
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1393
    "Created: / 1.12.1997 / 18:39:23 / cg"
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1394
    "Modified: / 1.12.1997 / 18:49:58 / cg"
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1395
!
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1396
7926
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1397
decompressPackBitsV2From:srcBytes at:srcStart to:dstBytes at:dstStart count:outCount
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1398
    "decompress until a number of output bytes has been decompressed.
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1399
     Used by some mac image formats.
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1400
     Return the number of processed input bytes.
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1401
     This does NOT treat FF as a noop."
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1402
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1403
    |i b n v dstOffs nRemaining|
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1404
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1405
    dstOffs := dstStart.
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1406
    i := srcStart.
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1407
    nRemaining := outCount.
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1408
    [nRemaining > 0] whileTrue:[
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1409
	b := srcBytes at:i.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1410
	i := i + 1.
7926
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1411
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1412
	"/ mhmh - other packbits decoders seem to treat FF as a noop
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1413
	"/ here, we do not.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1414
	true "b ~~ 16rFF" ifTrue:[   "/ not a NOP
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1415
	    b <= 127 ifTrue:[
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1416
		"/ 0..127: 1..128 literal bytes
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1417
		n := b + 1.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1418
		dstBytes replaceFrom:dstOffs to:dstOffs+b with:srcBytes startingAt:i.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1419
		nRemaining := nRemaining - n.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1420
		i := i + n.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1421
	    ] ifFalse:[
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1422
		"/ 128..255 a run of length 3..130
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1423
		n := b - 125.
7926
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1424
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1425
		v := srcBytes at:i.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1426
		i := i + 1.
7926
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1427
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1428
		dstBytes from:dstOffs to:dstOffs+n-1 put:v.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1429
		nRemaining := nRemaining - n.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1430
	    ].
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1431
	    dstOffs := dstOffs + n.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1432
	] ifFalse:[
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1433
	    self halt
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  1434
	].
7926
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1435
    ].
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1436
    ^ i-srcStart
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1437
b83ef852a991 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7925
diff changeset
  1438
    "Created: / 22-02-2017 / 12:05:26 / cg"
6585
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1439
!
6fc5ec1f3398 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6508
diff changeset
  1440
1648
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1441
decompressRLEFrom:srcBytes at:srcStartIndex into:dstBytes at:dstStartIndex increment:dstIncrement
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1442
    "common helper to expand RLE encoded data"
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1443
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1444
    "/ the code below expands common RLE formats, where the high bit
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1445
    "/ controls how the count in the low 7 bits is to be interpreted:
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1446
    "/ 1 means: count verbatim bytes follow;
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1447
    "/ 0 means: repeat the next byte count times.
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1448
    "/ Decoding stops when a 0-count is encountered.
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1449
    "/ srcBytes and dstBytes should not overlap.
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1450
    "/ dstIncrement controls the stepping in the destination (usually: 1)
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1451
    "/
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1452
    "/ this may be recoded in C in the future
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1453
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1454
    |srcIdx "{Class: SmallInteger }"
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1455
     dstIdx "{Class: SmallInteger }"
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1456
     pixel  "{Class: SmallInteger }"
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1457
     count  "{Class: SmallInteger }"|
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1458
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1459
    srcIdx := srcStartIndex.
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1460
    dstIdx := dstStartIndex.
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1461
    [true] whileTrue:[
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1462
	pixel := srcBytes at:srcIdx.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1463
	count := pixel bitAnd:16r7F.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1464
	count == 0 ifTrue:[
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1465
	    ^ self
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1466
	].
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1467
	srcIdx := srcIdx + 1.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1468
	(pixel bitAnd:16r80) == 0 ifTrue:[
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1469
	    "/ run bytes
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1470
	    pixel := srcBytes at:srcIdx.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1471
	    srcIdx := srcIdx + 1.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1472
	    dstIncrement == 1 ifTrue:[
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1473
		dstBytes from:dstIdx to:(dstIdx+count-1) put:pixel.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1474
		dstIdx := dstIdx + count.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1475
	    ] ifFalse:[
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1476
		1 to:count do:[:c |
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1477
		    dstBytes at:dstIdx put:pixel.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1478
		    dstIdx := dstIdx + dstIncrement.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1479
		]
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1480
	    ]
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1481
	] ifFalse:[
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1482
	    "/ verbatim bytes
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1483
	    dstIncrement == 1 ifTrue:[
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1484
		dstBytes replaceFrom:dstIdx to:(dstIdx+count-1) with:srcBytes startingAt:srcIdx.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1485
		srcIdx := srcIdx + count.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1486
		dstIdx := dstIdx + count.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1487
	    ] ifFalse:[
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1488
		1 to:count do:[:c |
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1489
		    dstBytes at:dstIdx put:(srcBytes at:srcIdx).
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1490
		    srcIdx := srcIdx + 1.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1491
		    dstIdx := dstIdx + dstIncrement.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1492
		]
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1493
	    ]
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1494
	]
1648
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1495
    ].
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1496
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1497
    "Modified: 23.4.1997 / 18:54:05 / cg"
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1498
!
cbb3f0d60617 prepare for RLE decompression code reuse
Claus Gittinger <cg@exept.de>
parents: 1633
diff changeset
  1499
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1500
decompressTiffPackBitsFrom:srcBytes to:dstBytes at:dstStart count:maxOutCount
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1501
    "decompress all of srcBytes to dstBytes starting at dstStart.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1502
     Used by TIFF image formats.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1503
     This DOES TREAT FF as a noop."
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1504
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1505
    |i b n v dstOffs dstLast end srcSize|
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1506
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1507
    dstOffs := dstStart.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1508
    dstLast := (dstStart + maxOutCount - 1) min:(dstBytes size).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1509
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1510
    i := 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1511
    srcSize := srcBytes size.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1512
    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1513
    [i <= srcSize] whileTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1514
        b := srcBytes at:i.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1515
        i := i + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1516
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1517
        "/ treat FF as a noop
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1518
        b ~~ 128 ifTrue:[   "/ not a NOP
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1519
            b <= 127 ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1520
                "/ 0..127: 1..128 literal bytes
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1521
                n := b + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1522
                end := (dstOffs+n-1) min:dstLast.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1523
                dstBytes replaceFrom:dstOffs to:end with:srcBytes startingAt:i.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1524
                i := i + n.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1525
            ] ifFalse:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1526
                n := 1 - (b - 256).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1527
                v := srcBytes at:i.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1528
                i := i + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1529
                end := (dstOffs+n-1) min:dstLast.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1530
                dstBytes from:dstOffs to:end put:v.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1531
            ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1532
            dstOffs := dstOffs + n.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1533
            dstOffs > dstLast ifTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1534
                ^ dstLast-1-dstStart.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1535
            ].    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1536
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1537
    ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1538
    ^ dstOffs-dstStart
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1539
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1540
    "Created: / 26-08-2017 / 17:50:13 / cg"
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1541
    "Modified: / 27-08-2017 / 12:32:17 / cg"
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1542
!
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1543
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1544
initCCITTTables
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1545
    |whiteDef blackDef index value| 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1546
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1547
    whiteDef := #(
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1548
        ( 16r3500 8 ) "/ 0 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1549
        ( 16r1c00 6 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1550
        ( 16r7000 4 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1551
        ( 16r8000 4 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1552
        ( 16rb000 4 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1553
        ( 16rc000 4 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1554
        ( 16re000 4 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1555
        ( 16rf000 4 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1556
        ( 16r9800 5 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1557
        ( 16rA000 5 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1558
        ( 16r3800 5 ) "/ 10 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1559
        ( 16r4000 5 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1560
        ( 16r2000 6 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1561
        ( 16r0c00 6 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1562
        ( 16rd000 6 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1563
        ( 16rd400 6 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1564
        ( 16ra800 6 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1565
        ( 16rac00 6 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1566
        ( 16r4e00 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1567
        ( 16r1800 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1568
        ( 16r1000 7 ) "/ 20 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1569
        ( 16r2e00 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1570
        ( 16r0600 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1571
        ( 16r0800 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1572
        ( 16r5000 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1573
        ( 16r5600 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1574
        ( 16r2600 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1575
        ( 16r4800 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1576
        ( 16r3000 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1577
        ( 16r0200 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1578
        ( 16r0300 8 ) "/ 30 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1579
        ( 16r1a00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1580
        ( 16r1b00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1581
        ( 16r1200 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1582
        ( 16r1300 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1583
        ( 16r1400 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1584
        ( 16r1500 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1585
        ( 16r1600 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1586
        ( 16r1700 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1587
        ( 16r2800 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1588
        ( 16r2900 8 ) "/ 40 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1589
        ( 16r2a00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1590
        ( 16r2b00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1591
        ( 16r2c00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1592
        ( 16r2d00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1593
        ( 16r0400 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1594
        ( 16r0500 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1595
        ( 16r0a00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1596
        ( 16r0b00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1597
        ( 16r5200 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1598
        ( 16r5300 8 ) "/ 50 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1599
        ( 16r5400 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1600
        ( 16r5500 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1601
        ( 16r2400 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1602
        ( 16r2500 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1603
        ( 16r5800 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1604
        ( 16r5900 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1605
        ( 16r5a00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1606
        ( 16r5b00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1607
        ( 16r4a00 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1608
        ( 16r4b00 8 ) "/ 60 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1609
        ( 16r3200 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1610
        ( 16r3300 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1611
        ( 16r3400 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1612
        "/ ---------------- 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1613
        ( 16rd800 5 ) "/ 64 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1614
        ( 16r9000 5 ) "/ 128 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1615
        ( 16r5c00 6 ) "/ 192 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1616
        ( 16r6e00 7 ) "/ 256 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1617
        ( 16r3600 8 ) "/ 320 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1618
        ( 16r3700 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1619
        ( 16r6400 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1620
        ( 16r6500 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1621
        ( 16r6800 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1622
        ( 16r6700 8 ) "/ 640 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1623
        ( 16r6600 9 ) "/ 704 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1624
        ( 16r6680 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1625
        ( 16r6900 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1626
        ( 16r6980 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1627
        ( 16r6a00 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1628
        ( 16r6a80 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1629
        ( 16r6b00 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1630
        ( 16r6b80 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1631
        ( 16r6c00 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1632
        ( 16r6c80 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1633
        ( 16r6d00 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1634
        ( 16r6d80 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1635
        ( 16r4c00 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1636
        ( 16r4c80 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1637
        ( 16r4d00 9 ) "/ 1600 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1638
        ( 16r6000 6 ) "/ 1664 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1639
        ( 16r4d80 9 ) "/ 1728 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1640
        "/ -------------------------------- 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1641
        ( 16r0100 11 ) "/ 1792 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1642
        ( 16r0180 11 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1643
        ( 16r01a0 11 ) "/ 1920 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1644
        ( 16r0120 12 ) "/ 1984 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1645
        ( 16r0130 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1646
        ( 16r0140 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1647
        ( 16r0150 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1648
        ( 16r0160 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1649
        ( 16r0170 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1650
        ( 16r01c0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1651
        ( 16r01d0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1652
        ( 16r01e0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1653
        ( 16r01f0 12 ) "/ 2560 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1654
        "/ -------------------------------- 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1655
        ( 16r0010 12 ) "/ EOL 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1656
    ).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1657
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1658
    blackDef := #(
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1659
        ( 16r0dc0 10 ) "/ 0 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1660
        ( 16r4000 3 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1661
        ( 16rc000 2 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1662
        ( 16r8000 2 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1663
        ( 16r6000 3 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1664
        ( 16r3000 4 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1665
        ( 16r2000 4 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1666
        ( 16r1800 5 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1667
        ( 16r1400 6 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1668
        ( 16r1000 6 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1669
        ( 16r0800 7 ) "/ 10 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1670
        ( 16r0a00 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1671
        ( 16r0e00 7 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1672
        ( 16r0400 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1673
        ( 16r0700 8 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1674
        ( 16r0c00 9 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1675
        ( 16r05c0 10 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1676
        ( 16r0600 10 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1677
        ( 16r0200 10 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1678
        ( 16r0ce0 11 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1679
        ( 16r0d00 11 ) "/ 20 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1680
        ( 16r0d80 11 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1681
        ( 16r06e0 11 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1682
        ( 16r0500 11 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1683
        ( 16r02e0 11 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1684
        ( 16r0300 11 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1685
        ( 16r0ca0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1686
        ( 16r0cb0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1687
        ( 16r0cc0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1688
        ( 16r0cd0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1689
        ( 16r0680 12 ) "/ 30 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1690
        ( 16r0690 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1691
        ( 16r06a0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1692
        ( 16r06b0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1693
        ( 16r0d20 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1694
        ( 16r0d30 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1695
        ( 16r0d40 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1696
        ( 16r0d50 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1697
        ( 16r0d60 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1698
        ( 16r0d70 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1699
        ( 16r06c0 12 ) "/ 40 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1700
        ( 16r06d0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1701
        ( 16r0da0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1702
        ( 16r0db0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1703
        ( 16r0540 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1704
        ( 16r0550 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1705
        ( 16r0560 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1706
        ( 16r0570 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1707
        ( 16r0640 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1708
        ( 16r0650 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1709
        ( 16r0520 12 ) "/ 50 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1710
        ( 16r0530 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1711
        ( 16r0240 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1712
        ( 16r0370 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1713
        ( 16r0380 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1714
        ( 16r0270 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1715
        ( 16r0280 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1716
        ( 16r0580 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1717
        ( 16r0590 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1718
        ( 16r02b0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1719
        ( 16r02c0 12 ) "/ 60 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1720
        ( 16r05a0 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1721
        ( 16r0660 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1722
        ( 16r0670 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1723
        "/ ---------------- 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1724
        ( 16r03c0 10 ) "/ 64 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1725
        ( 16r0c80 12 ) "/ 128 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1726
        ( 16r0c90 12 ) "/ 192 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1727
        ( 16r05b0 12 ) "/ 256 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1728
        ( 16r0330 12 ) "/ 320 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1729
        ( 16r0340 12 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1730
        ( 16r0350 12 ) "/ 448 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1731
        ( 16r0360 13 ) "/ 512 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1732
        ( 16r0368 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1733
        ( 16r0250 13 ) "/ 640 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1734
        ( 16r0258 13 ) "/ 704 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1735
        ( 16r0260 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1736
        ( 16r0268 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1737
        ( 16r0390 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1738
        ( 16r0398 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1739
        ( 16r03a0 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1740
        ( 16r03a8 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1741
        ( 16r03b0 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1742
        ( 16r03b8 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1743
        ( 16r0290 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1744
        ( 16r0298 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1745
        ( 16r02a0 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1746
        ( 16r02a8 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1747
        ( 16r02d0 13 )
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1748
        ( 16r02d8 13 ) "/ 1600 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1749
        ( 16r0320 13 ) "/ 1664 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1750
        ( 16r0328 13 ) "/ 1728 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1751
        "/ -------------------------------- 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1752
    ).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1753
    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1754
    WhiteCountTable := SignedWordArray new: 8192 withAll:-1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1755
    BlackCountTable := SignedWordArray new: 8192 withAll:-1.   
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1756
    WhiteShiftTable := SignedWordArray new: 8192.    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1757
    BlackShiftTable := SignedWordArray new: 8192. 
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1758
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1759
    0 to:63 do:[:value |
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1760
        |def nBits bits|
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1761
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1762
        def := whiteDef at:(value+1).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1763
        nBits := def second.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1764
        bits := def first >> 3.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1765
        (1 << (13 - nBits)) to:1 by:-1 do:[:cnt |
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1766
            WhiteCountTable at:bits+1 put:value.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1767
            WhiteShiftTable at:bits+1 put:nBits.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1768
            bits := bits + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1769
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1770
        def := blackDef at:(value+1).
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1771
        nBits := def second.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1772
        bits := def first >> 3.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1773
        (1 << (13 - nBits)) to:1 by:-1 do:[:cnt |
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1774
            BlackCountTable at:bits+1 put:value.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1775
            BlackShiftTable at:bits+1 put:nBits.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1776
            bits := bits + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1777
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1778
    ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1779
    
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1780
    index := value := 64.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1781
    [ value <= 1728 ] whileTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1782
        |nBits bits|
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1783
        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1784
        nBits := (whiteDef at:(index+1)) second.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1785
        bits := (whiteDef at:(index+1)) first >> 3.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1786
        
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1787
        (1 << (13 - nBits)) to:1 by:-1 do:[:cnt |
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1788
            WhiteCountTable at:bits+1 put:value.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1789
            WhiteShiftTable at:bits+1 put:nBits.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1790
            bits := bits + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1791
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1792
        nBits := (blackDef at:(index+1)) second.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1793
        bits := (blackDef at:(index+1)) first >> 3.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1794
        (1 << (13 - nBits)) to:1 by:-1 do:[:cnt |
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1795
            BlackCountTable at:bits+1 put:value.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1796
            BlackShiftTable at:bits+1 put:nBits.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1797
            bits := bits + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1798
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1799
        index := index + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1800
        value := value + 64.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1801
    ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1802
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1803
    [ value <= 2560 ] whileTrue:[
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1804
        |nBits bits|
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1805
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1806
        nBits := (whiteDef at:(index+1)) second.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1807
        bits := (whiteDef at:(index+1)) first >> 3.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1808
        (1 << (13 - nBits)) to:1 by:-1 do:[:cnt |
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1809
            WhiteCountTable at:bits+1 put:value.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1810
            WhiteShiftTable at:bits+1 put:nBits.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1811
            BlackCountTable at:bits+1 put:value.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1812
            BlackShiftTable at:bits+1 put:nBits.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1813
            bits := bits + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1814
        ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1815
        index := index + 1.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1816
        value := value + 64.
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1817
    ].
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1818
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1819
    "Created: / 25-08-2017 / 13:25:46 / cg"
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1820
!
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  1821
7501
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1822
swap:nBytes bytesFromRGBA_to_BGRA_in:data startingAt:startIndex
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1823
    "swap bytes from RGBA into BGRA order.
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1824
     The argument is a pixel data buffer (byteArray)"
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1825
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1826
    self swap:(nBytes//4) pixelsFromRGB_to_BGR_in:data startingAt:startIndex bytesPerPixel:4
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1827
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1828
    "
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1829
     |bytes|
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1830
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1831
     bytes := #[ 0 1 2 3 4 5 6 7 8 9 ].
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1832
     self swap:6 bytesFromRGB_to_BGR_in:bytes startingAt:1.
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1833
     bytes.
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1834
    "
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1835
    "
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1836
     |bytes|
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1837
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1838
     bytes := ByteArray new:1000000.
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1839
     bytes replaceFrom:1 with:#[ 0 1 2 3 4 5 6 7 8 9 10 11 12].
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1840
     Time millisecondsToRun:[
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
  1841
	self swap:1000000 bytesFromRGB_to_BGR_in:bytes.
7501
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1842
     ].
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1843
     bytes copyTo:10.
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1844
    "
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1845
!
ddcd558eda4b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7375
diff changeset
  1846
3835
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1847
swap:nBytes bytesFromRGB_to_BGR_in:data
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1848
    "swap bytes from RGB into BGR order.
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1849
     The argument is a pixel data buffer (byteArray)"
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1850
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1851
    self swap:(nBytes//3) pixelsFromRGB_to_BGR_in:data startingAt:1 bytesPerPixel:3
3835
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1852
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1853
    "
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1854
     |bytes|
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1855
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1856
     bytes := #[ 0 1 2 3 4 5 6 7 8 9 ].
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1857
     self swap:6 bytesFromRGB_to_BGR_in:bytes.
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  1858
     bytes.
3835
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1859
    "
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1860
    "
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1861
     |bytes|
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1862
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1863
     bytes := ByteArray new:1000000.
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  1864
     bytes replaceFrom:1 with:#[ 0 1 2 3 4 5 6 7 8 9 10 11 12].
3835
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1865
     Time millisecondsToRun:[
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
  1866
	self swap:1000000 bytesFromRGB_to_BGR_in:bytes.
5129
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1867
     ].
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1868
     bytes copyTo:10.
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1869
    "
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1870
!
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1871
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1872
swap:nBytes bytesFromRGB_to_BGR_in:data startingAt:startIndex
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1873
    "swap bytes from RGB into BGR order.
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1874
     The argument is a pixel data buffer (byteArray)"
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1875
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1876
    self swap:(nBytes//3) pixelsFromRGB_to_BGR_in:data startingAt:startIndex bytesPerPixel:3
5129
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1877
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1878
    "
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1879
     |bytes|
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1880
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1881
     bytes := #[ 0 1 2 3 4 5 6 7 8 9 ].
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1882
     self swap:6 bytesFromRGB_to_BGR_in:bytes startingAt:1.
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1883
     bytes.
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1884
    "
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1885
    "
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1886
     |bytes|
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1887
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1888
     bytes := ByteArray new:1000000.
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1889
     bytes replaceFrom:1 with:#[ 0 1 2 3 4 5 6 7 8 9 10 11 12].
1f80ff25b6a5 BMP support removed (moved down to the WindopwsIconReader)
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
  1890
     Time millisecondsToRun:[
7539
cf0fed88ba16 warnings eliminated
Claus Gittinger <cg@exept.de>
parents: 7501
diff changeset
  1891
	self swap:1000000 bytesFromRGB_to_BGR_in:bytes.
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  1892
     ].
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  1893
     bytes copyTo:10.
3835
8b203fa57396 swap_RGB_BGR support
Claus Gittinger <cg@exept.de>
parents: 3605
diff changeset
  1894
    "
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1895
!
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1896
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1897
swap:count pixelsFromRGB_to_BGR_in:data startingAt:startIndex bytesPerPixel:bpp
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1898
    "swap bytes from RGB into BGR order.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1899
     The argument is a pixel data buffer (byteArray).
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1900
     Can be used for both 24bit rgb data (bpp=3) or rgba data (bpp=4)"
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1901
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1902
    |t idx|
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1903
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1904
%{  /* OPTIONAL */
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1905
    if (__isByteArray(data)
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1906
     && __isSmallInteger(count)
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1907
     && __isSmallInteger(startIndex)
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1908
     && __isSmallInteger(bpp)) {
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1909
	INT __count = __intVal(count);
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1910
	INT __startOffset = __intVal(startIndex) - 1;
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1911
	INT __dataSize = __byteArraySize(data);
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1912
	int __bpp = __intVal(bpp);
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1913
	INT __nBytes = __count * __bpp;
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1914
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1915
	if ((__startOffset + __nBytes) <= __dataSize) {
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1916
	    unsigned char *__cp = __ByteArrayInstPtr(data)->ba_element + __startOffset;
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1917
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1918
	    while (__count-- > 0) {
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1919
		unsigned char __t;
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1920
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1921
		__t = __cp[0];
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1922
		__cp[0] = __cp[2];
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1923
		__cp[2] = __t;
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1924
		__cp += __bpp;
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1925
	    }
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1926
	    RETURN (true);
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1927
	}
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1928
    }
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1929
%}.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1930
    idx := startIndex.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1931
    1 to:count do:[:i |
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1932
	t := data at:idx.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1933
	data at:idx put:(data at:idx+2).
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1934
	data at:idx+2 put:t.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1935
	idx := idx + bpp.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1936
    ].
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1937
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1938
    "
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1939
     |bytes|
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1940
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1941
     bytes := #[ 0 1 2  3 4 5  6 7 8  9 ].
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1942
     self swap:2 pixelsFromRGB_to_BGR_in:bytes startingAt:1 bytesPerPixel:3.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1943
     bytes.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1944
    "
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1945
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1946
    "
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1947
     |bytes|
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1948
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1949
     bytes := #[ 0 1 2 3  4 5 6 7  8 9 ].
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1950
     self swap:2 pixelsFromRGB_to_BGR_in:bytes startingAt:1 bytesPerPixel:4.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1951
     bytes.
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  1952
    "
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1953
! !
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1954
1167
4998857f7a9a new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  1955
!ImageReader class methodsFor:'i/o support'!
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1956
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1957
streamReadingFile:aFilename
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1958
    "return a stream to read aFilename.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1959
     If the filename ends with '.Z' or '.gz', return a stream
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1960
     to a pipe for the uncompressor. Otherwise, return a stream to read
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1961
     the file directly."
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1962
1300
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1963
    |inStream name fn|
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1964
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1965
    name := aFilename asString.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1966
    ((name endsWith:'.Z') or:[name endsWith:'.gz']) ifTrue:[
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1967
	fn := Smalltalk getSystemFileName:name.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1968
	inStream := PipeStream readingFrom:'gunzip < ' , fn.
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1969
    ] ifFalse:[
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1970
	inStream := Smalltalk systemFileStreamFor:aFilename.
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1971
	inStream isNil ifTrue:[
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1972
	    inStream := Smalltalk bitmapFileStreamFor:aFilename
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  1973
	]
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1974
    ].
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1975
    inStream isNil ifTrue:[
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  1976
	'ImageReader [warning]: open error on: ' infoPrint. aFilename infoPrintCR.
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1977
    ].
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1978
    ^ inStream
518
f76da6242336 nicer message
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
  1979
1300
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  1980
    "Modified: 31.1.1997 / 10:37:24 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1981
! !
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1982
1167
4998857f7a9a new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  1983
!ImageReader class methodsFor:'image reading'!
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1984
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1985
fromBytes:aByteArray
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1986
    "read an image (in my format) from aByteArray.
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1987
     Return the image or nil (if unrecognized format or error)"
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1988
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1989
    |reader|
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1990
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1991
    reader := self readStream:aByteArray readStream.
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1992
    ^ reader image
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1993
!
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  1994
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1995
fromFile:aFileName
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  1996
    "read an image (in my format) from aFileName.
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1997
     Return the image or nil on error."
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  1998
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  1999
    |reader|
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2000
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2001
    reader := self readFile:aFileName.
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2002
    reader notNil ifTrue:[
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  2003
	^ reader image
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2004
    ].
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2005
    ^ nil
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2006
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2007
    "
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2008
     XBMReader fromFile:'bitmaps/SBrowser.xbm'
4033
9af502584519 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
  2009
     XPMReader fromFile:'bitmaps/xpmBitmaps/misc_icons/BOOK.xpm'
9af502584519 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
  2010
     XBMReader fromFile:'bitmaps/xpmBitmaps/misc_icons/BOOK.xpm'
518
f76da6242336 nicer message
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
  2011
    "
f76da6242336 nicer message
Claus Gittinger <cg@exept.de>
parents: 285
diff changeset
  2012
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2013
    "Modified: 4.4.1997 / 22:09:49 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2014
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2015
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2016
fromStream:aStream
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2017
    "read an image (in my format) from aStream.
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2018
     Return the image or nil (if unrecognized format or error).
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2019
     The stream remains open."
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2020
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2021
    |reader|
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2022
3839
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2023
    reader := self readStream:aStream.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2024
    ^ reader image
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2025
!
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2026
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2027
fromURL:url
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2028
    "read an image (in my format) from url.
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2029
     Return the image or nil (if unrecognized format or error)"
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2030
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2031
    |readerClass response|
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2032
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2033
    self == ImageReader ifTrue:[
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2034
	"select a reader supporting this file format"
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2035
	readerClass := self readerClassForFilename:url asURL path.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2036
	readerClass ~~ self ifTrue:[
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2037
	    ^ readerClass fromURL:url.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2038
	].
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2039
    ].
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2040
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2041
    response := HTTPInterface get:url.
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2042
    response isErrorResponse ifTrue:[
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2043
	self error:'failed to read url' mayProceed:true.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2044
	^ nil
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2045
    ].
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2046
    ^ self fromBytes:(response data).
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2047
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2048
    "
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2049
     self fromURL:'http://www.lutece.paris.fr/tech/images/helloworld.png'
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2050
    "
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2051
!
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2052
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2053
imagesFromFile:aFileName
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2054
    "read all images (in my format) from aFileName.
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2055
     Return a collection of images or nil on error.
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2056
     Not all reader may support multiple images."
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2057
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2058
    |reader|
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2059
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2060
    reader := self readFile:aFileName.
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2061
    reader notNil ifTrue:[
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  2062
	^ reader images
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2063
    ].
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2064
    ^ nil
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2065
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2066
    "Modified: 4.4.1997 / 22:11:01 / cg"
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2067
!
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2068
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2069
imagesFromStream:aStream
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2070
    "read all images (in my format) from aStream.
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2071
     Return a collection of images or nil (if unrecognized format or error).
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2072
     The stream remains open.
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2073
     Not all reader may support multiple images."
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2074
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2075
    |reader|
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2076
3839
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2077
    reader := self new.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2078
    reader inStream:aStream.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2079
    reader fromStream:aStream.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2080
    ^ reader images
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2081
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2082
    "Modified: 4.4.1997 / 22:11:40 / cg"
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2083
!
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2084
4912
b2fd9c2d5e11 #fromFile: and #readFile: - choose a matching subclass
Stefan Vogel <sv@exept.de>
parents: 4776
diff changeset
  2085
readFile:aFilename
b2fd9c2d5e11 #fromFile: and #readFile: - choose a matching subclass
Stefan Vogel <sv@exept.de>
parents: 4776
diff changeset
  2086
    "create a reader and let it read an image (in my format) from aFilename.
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2087
     Return the reader, NOT the image (however, the reader has already read the image,
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2088
     so it can be asked with 'reader image')."
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2089
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2090
    |readerClass reader inStream|
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2091
4912
b2fd9c2d5e11 #fromFile: and #readFile: - choose a matching subclass
Stefan Vogel <sv@exept.de>
parents: 4776
diff changeset
  2092
    self == ImageReader ifTrue:[
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2093
	"select a reader supporting this file format"
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2094
	readerClass := self readerClassForFilename:aFilename.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2095
	readerClass ~~ self ifTrue:[
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2096
	    ^ readerClass readFile:aFilename.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2097
	].
4912
b2fd9c2d5e11 #fromFile: and #readFile: - choose a matching subclass
Stefan Vogel <sv@exept.de>
parents: 4776
diff changeset
  2098
    ].
b2fd9c2d5e11 #fromFile: and #readFile: - choose a matching subclass
Stefan Vogel <sv@exept.de>
parents: 4776
diff changeset
  2099
b2fd9c2d5e11 #fromFile: and #readFile: - choose a matching subclass
Stefan Vogel <sv@exept.de>
parents: 4776
diff changeset
  2100
    inStream := self streamReadingFile:aFilename.
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2101
    inStream isNil ifTrue:[
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2102
	'ImageReader [warning]: file open error' errorPrintCR.
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2103
	^ nil
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2104
    ].
3839
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2105
    reader := self new.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2106
    reader inStream:inStream.
3489
60e6b6ded0b3 close inStream on unwind
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  2107
    [
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2108
	reader fromStream:inStream.
3605
b5c70808fc8c #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 3489
diff changeset
  2109
    ] ensure:[
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2110
	inStream close.
3489
60e6b6ded0b3 close inStream on unwind
Claus Gittinger <cg@exept.de>
parents: 3468
diff changeset
  2111
    ].
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2112
    ^ reader
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2113
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2114
    "
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2115
     XPMReader readFile:'../../goodies/bitmaps/xpmBitmaps/misc_icons/BOOK.xpm'
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2116
     (XPMReader readFile:'../../goodies/bitmaps/xpmBitmaps/misc_icons/BOOK.xpm') image
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2117
    "
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2118
5737
f39cc6dc9848 raise different error in #readFile: for unsupported filetypes
Claus Gittinger <cg@exept.de>
parents: 5567
diff changeset
  2119
    "Modified: / 04-04-2011 / 14:16:56 / cg"
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2120
!
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2121
3839
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2122
readStream:aStream
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2123
    "create a reader and let it read a stream (in my format).
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2124
     Return the reader, NOT the image (however, the reader has already read the image,
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2125
     so it can be asked with 'reader image').
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2126
     The stream remains open."
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2127
3839
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2128
    |reader|
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2129
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2130
    reader := self new.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2131
    reader fromStream:aStream.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2132
    ^ reader
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2133
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2134
    "Created: 4.4.1997 / 22:08:13 / cg"
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2135
!
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2136
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2137
readerClassForFilename:aStringOrFilename
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2138
    "return a reader class, determined by the file's name"
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2139
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2140
    |mime reader|
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2141
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2142
    mime := aStringOrFilename asFilename mimeTypeFromName.
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2143
    mime isNil ifTrue:[
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2144
	mime := aStringOrFilename asFilename mimeTypeOfContents.
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2145
    ].
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2146
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2147
    mime notNil ifTrue:[
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2148
	reader := MIMETypes imageReaderForType:mime.
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2149
    ].
6167
baa4c9ec056a class: ImageReader
Stefan Vogel <sv@exept.de>
parents: 6062
diff changeset
  2150
    reader isNil ifTrue:[
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2151
	"answer the reader when proceeding form this error"
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2152
	reader := ConversionError raiseRequestErrorString:(' - unsupported image type: ''%1''' bindWith:(mime ? aStringOrFilename asFilename suffix)).
6167
baa4c9ec056a class: ImageReader
Stefan Vogel <sv@exept.de>
parents: 6062
diff changeset
  2153
    ].
baa4c9ec056a class: ImageReader
Stefan Vogel <sv@exept.de>
parents: 6062
diff changeset
  2154
    ^ reader
6060
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2155
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2156
    "
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2157
     self readerClassForFilename:('http://www.foo.bar/helloworld.png' asURL path)
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2158
     self readerClassForFilename:('http://www.foo.bar/helloworld.gif' asURL path)
96649bbbab0c class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6058
diff changeset
  2159
    "
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2160
! !
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2161
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2162
!ImageReader class methodsFor:'image support'!
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2163
8095
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2164
buildMaskFromColor:maskPixelValue for:pixels depth:depth width:width height:height
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2165
    "helper for image formats, where an individual pixel value
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2166
     has been defined as a mask-pixel (i.e. GIF).
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2167
     Creates a maskImage, with zeros at positions where the image
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2168
     has the given pixelValue; all other mask pixels are set to 1."
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2169
8095
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2170
    |maskArray bytesPerMaskRow mask ok|
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2171
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2172
    bytesPerMaskRow := (width+7) // 8.
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2173
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2174
    maskArray := ByteArray uninitializedNew:bytesPerMaskRow * height.
8095
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2175
    ok := false.
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2176
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2177
%{
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2178
    int __w = __intVal(width);
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2179
    int __h = __intVal(height);
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2180
    int __x, __y;
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2181
    int __outBits, __nOut;
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2182
    unsigned char *__inP, *__outP, *__nextOutRow;
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2183
    int __bpr = __intVal(bytesPerMaskRow);
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2184
    int __maskPixel = __intVal(maskPixelValue);
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2185
#ifdef DEBUG
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2186
    unsigned char *outEnd;
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2187
#endif
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2188
5481
93de6ee2ed5a __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5318
diff changeset
  2189
    if (! __isByteArrayLike(pixels)) goto fail;
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2190
    if (! __isByteArray(maskArray)) goto fail;
8095
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2191
    if (__intVal(depth) != 8) goto fail;
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2192
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2193
    __inP = __ByteArrayInstPtr(pixels)->ba_element;
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2194
    __outP = __ByteArrayInstPtr(maskArray)->ba_element;
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2195
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2196
#ifdef DEBUG
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2197
    outEnd = __outP + (__byteArraySize(maskArray));
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2198
#endif
8095
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2199
    //
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2200
    // printf("outP: %x outEnd: %x sz: %d\n", __outP, outEnd, __byteArraySize(maskArray));
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2201
    //
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2202
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2203
    for (__y=__h; __y>0; __y--) {
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2204
	__outBits = 0;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2205
	__nOut = 8;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2206
	__nextOutRow = __outP + __bpr;
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2207
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2208
	for (__x=__w; __x>=8; __x-=8) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2209
	    if (__inP[0] != __maskPixel) { __outBits |= 0x80; };
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2210
	    if (__inP[1] != __maskPixel) { __outBits |= 0x40; };
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2211
	    if (__inP[2] != __maskPixel) { __outBits |= 0x20; };
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2212
	    if (__inP[3] != __maskPixel) { __outBits |= 0x10; };
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2213
	    if (__inP[4] != __maskPixel) { __outBits |= 0x08; };
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2214
	    if (__inP[5] != __maskPixel) { __outBits |= 0x04; };
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2215
	    if (__inP[6] != __maskPixel) { __outBits |= 0x02; };
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2216
	    if (__inP[7] != __maskPixel) { __outBits |= 0x01; };
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2217
	    __inP += 8;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2218
	    *__outP++ = __outBits;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2219
	    __outBits = 0;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2220
	}
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2221
	for (; __x>0; __x--) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2222
	    __outBits <<= 1;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2223
	    if (*__inP != __maskPixel) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2224
		__outBits |= 1;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2225
	    }
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2226
	    __inP++;
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2227
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2228
	    //
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2229
	    // printf("x: %d  bits: %x\n", __x, __outBits);
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2230
	    //
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2231
	    if (--__nOut == 0) {
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2232
#ifdef DEBUG
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2233
		if (__outP >= outEnd) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2234
		    if (@global(InfoPrinting) == true) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2235
			console_fprintf(stderr, "oops %d\n", __LINE__);
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2236
		    }
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2237
		    goto fail;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2238
		}
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2239
#endif
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2240
		*__outP = __outBits;
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2241
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2242
		__outP++;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2243
		__nOut = 8;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2244
		__outBits = 0;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2245
	    }
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2246
	}
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2247
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2248
	if (__nOut != 8) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2249
	    __outBits <<= __nOut;
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2250
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2251
#ifdef DEBUG
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2252
	    if (__outP >= outEnd) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2253
		if (@global(InfoPrinting) == true) {
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2254
		    console_fprintf(stderr, "oops2 %d\n", __LINE__);
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2255
		}
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2256
		goto fail;
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2257
	    }
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2258
#endif
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2259
	    *__outP = __outBits;
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2260
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2261
	}
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2262
	__outP = __nextOutRow;
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2263
    }
8095
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2264
    ok = true;
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2265
fail: ;
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2266
%}.
8095
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2267
    ok ifFalse:[
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2268
	"/ slow fallback...
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2269
	self halt.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2270
    ].
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2271
    mask := ImageMask width:width height:height fromArray:maskArray.
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2272
    ^ mask
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2273
8095
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2274
    "Created: / 23-08-2017 / 17:10:03 / cg"
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2275
!
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2276
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2277
buildMaskFromColor:maskPixelValue for:pixels width:width height:height
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2278
    "helper for image formats, where an individual pixel value
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2279
     has been defined as a mask-pixel (i.e. GIF).
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2280
     Creates a maskImage, with zeros at positions where the image
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2281
     has the given pixelValue; all other mask pixels are set to 1."
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2282
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2283
    ^ self buildMaskFromColor:maskPixelValue for:pixels depth:8 width:width height:height
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2284
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2285
    "Created: / 21-06-1996 / 11:43:47 / cg"
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2286
    "Modified: / 23-08-2017 / 17:13:23 / cg"
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2287
! !
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2288
1167
4998857f7a9a new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  2289
!ImageReader class methodsFor:'image writing'!
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2290
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2291
save:anImage onFile:aFileName
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2292
    "save the image in my format on aFileName.
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2293
     Returns the imageReader instance (bad name; is a writer).
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  2294
     May raise Image cannotRepresentImageSignal,
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2295
     if the image cannot be represented in that format,
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2296
     or it is not support"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2297
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2298
    ^ (self basicNew) save:anImage onFile:aFileName
1574
7c25ed84ad12 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1551
diff changeset
  2299
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2300
    "Modified: / 10-04-1997 / 17:42:57 / cg"
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2301
    "Modified (comment): / 05-02-2017 / 16:58:30 / cg"
3932
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2302
!
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2303
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2304
save:anImage onFile:aFileName quality:qualityPercent
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2305
    "save the image in my format on aFileName.
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2306
     The qualityPercent argument is ignored by all lossless formats.
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2307
     (however, JPG does care for it.)
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2308
     Returns the imageReader instance (bad name; is a writer).
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  2309
     May raise Image cannotRepresentImageSignal,
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2310
     if the image cannot be represented in that format,
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2311
     or it is not support"
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2312
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2313
    ^ (self basicNew) save:anImage onFile:aFileName quality:qualityPercent
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2314
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2315
    "Modified: / 10-04-1997 / 17:42:57 / cg"
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2316
    "Modified (comment): / 05-02-2017 / 16:58:45 / cg"
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2317
!
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2318
3932
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2319
save:anImage onStream:aStream
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2320
    "save the image in my format on aStream.
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2321
     Returns the imageReader instance (bad name; is a writer).
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  2322
     May raise Image cannotRepresentImageSignal,
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2323
     if the image cannot be represented in that format,
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2324
     or it is not support"
3932
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2325
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2326
    ^ (self basicNew) save:anImage onStream:aStream
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2327
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2328
    "Modified: / 10-04-1997 / 17:42:57 / cg"
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2329
    "Modified (comment): / 05-02-2017 / 16:58:18 / cg"
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2330
!
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2331
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2332
save:anImage onStream:aStream quality:qualityPercent
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2333
    "save the image in my format on a Stream.
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2334
     The qualityPercent argument is ignored by all lossless formats.
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2335
     (however, JPG does care for it.)
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2336
     Returns the imageReader instance (bad name; is a writer).
7894
16136333fe33 increased the suffix/prefix size to 8192
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  2337
     May raise Image cannotRepresentImageSignal,
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2338
     if the image cannot be represented in that format,
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2339
     or it is not support"
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2340
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2341
    ^ (self basicNew) save:anImage onStream:aStream quality:qualityPercent
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2342
7174
33fb4dc4b3d5 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7172
diff changeset
  2343
    "
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  2344
     (Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') saveOn:'garfield.gif'
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  2345
     (Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') saveOn:'garfield.jpg'
7174
33fb4dc4b3d5 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7172
diff changeset
  2346
     (Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') saveOn:'garfield50.jpg' quality:50
33fb4dc4b3d5 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7172
diff changeset
  2347
     (Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') saveOn:'garfield100.jpg' quality:100
33fb4dc4b3d5 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7172
diff changeset
  2348
    "
7839
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2349
98cc4414405e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7726
diff changeset
  2350
    "Modified (comment): / 05-02-2017 / 16:58:11 / cg"
7924
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2351
!
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2352
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2353
saveAll:aCollectionOfImages onFile:aFilename
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2354
    "save an image collection in my format on a file.
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2355
     Not all file formats support multiple images,
7924
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2356
     so be prepared for an exception to be raised."
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2357
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2358
    ^ (self basicNew) saveAll:aCollectionOfImages onFile:aFilename
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2359
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2360
    "Created: / 22-02-2017 / 01:01:17 / cg"
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2361
!
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2362
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2363
saveAll:aCollectionOfImages onStream:aStream
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2364
    "save an image collection in my format on a Stream.
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2365
     Not all file formats support multiple images,
7924
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2366
     so be prepared for an exception to be raised."
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2367
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2368
    ^ (self basicNew) saveAll:aCollectionOfImages onStream:aStream
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2369
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2370
    "Created: / 22-02-2017 / 01:00:44 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2371
! !
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2372
7859
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2373
!ImageReader class methodsFor:'queries'!
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2374
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2375
isAbstract
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2376
    "Return if this class is an abstract class.
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2377
     True is returned here for myself only; false for subclasses.
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2378
     Abstract subclasses must redefine this again."
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2379
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2380
    ^ self == ImageReader.
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2381
! !
6778c78e74e8 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7839
diff changeset
  2382
8246
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2383
!ImageReader class methodsFor:'signal constants'!
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2384
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2385
enforcedImageTypeQuery
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2386
    "the query signal which can be used to override the default type
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2387
     of image as returned by a reader.
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2388
     Currently, only PNGReader supports.
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2389
     Usage:
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2390
        ImageReader enforcedImageTypeQuery answer:#rgb
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2391
            do:[
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2392
                Image fromFile:anRGBAFile
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2393
            ]
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2394
    "
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2395
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2396
    ^ EnforcedImageTypeQuery
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2397
! !
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2398
1167
4998857f7a9a new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  2399
!ImageReader class methodsFor:'testing'!
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2400
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2401
canRepresent:anImage
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2402
    "return true, if anImage can be represented in my file format.
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2403
     must be redefined in concrete subclasses which support saving."
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2404
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2405
    ^ false
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2406
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2407
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2408
isValidImageFile:aFileName
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2409
    "return true, if aFileName contains an image this
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2410
     reader understands - must be redefined in concrete subclasses
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2411
     which support reading."
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2412
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2413
    ^ false
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2414
! !
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2415
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2416
!ImageReader methodsFor:'accessing'!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2417
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2418
bitsPerPixel
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2419
    "return the number of bits per pixel"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2420
8146
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2421
    "/ if depth was given, that is what we use;
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2422
    "/ otherwise, compute from bitsPerSample.
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2423
    "/ notice, that depth is >= sum(bitsPerSample),
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2424
    "/ for example, in a 16bit image, we mght have
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2425
    "/ depth == 16 and bitsPerSample = 5+5+5,
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2426
    
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2427
    depth notNil ifTrue:[^ depth].
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2428
    
3386
b9294699dbcf care for nil-data when converting to an image
Claus Gittinger <cg@exept.de>
parents: 3263
diff changeset
  2429
    bitsPerSample isNil ifTrue:[^ nil].
5927
eebe3a485637 changed: #bitsPerPixel
Stefan Vogel <sv@exept.de>
parents: 5737
diff changeset
  2430
    ^ bitsPerSample sum
8146
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2431
97a4ee050bd6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 8145
diff changeset
  2432
    "Modified (format): / 31-08-2017 / 18:09:59 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2433
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2434
1300
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2435
bitsPerRow
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2436
    "return the number of bits in one scanline of the image"
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2437
3868
e47cf114c824 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3843
diff changeset
  2438
    ^ width * (self bitsPerPixel).
1300
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2439
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2440
    "Created: 31.1.1997 / 10:38:42 / cg"
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2441
!
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2442
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2443
bitsPerSample
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2444
    "return the number of bits per sample"
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2445
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2446
    ^ bitsPerSample
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2447
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2448
    "Modified: 22.4.1996 / 19:15:18 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2449
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2450
1300
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2451
bytesPerRow
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2452
    "return the number of bytes in one scanline of the image"
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2453
7897
de53f0853c91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7894
diff changeset
  2454
    ^ Image bytesPerRowForWidth:width bitsPerPixel:(self bitsPerPixel)
1300
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2455
7897
de53f0853c91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7894
diff changeset
  2456
    "Created: / 31-01-1997 / 10:39:06 / cg"
de53f0853c91 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 7894
diff changeset
  2457
    "Modified: / 16-02-2017 / 16:18:13 / cg"
1300
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2458
!
1416ad43b694 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
  2459
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2460
colorMap
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2461
    "return the colormap"
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2462
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2463
    ^ colorMap
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2464
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2465
    "Modified: 22.4.1996 / 19:15:24 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2466
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2467
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2468
compressQuality:qualityPercentIgnoredHere
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2469
    "/ intentionally ignored here (redefined in JPEGReader)
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2470
!
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2471
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2472
data
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2473
    "return the raw image data"
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2474
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2475
    ^ data
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2476
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2477
    "Modified: 22.4.1996 / 19:15:31 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2478
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2479
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2480
hasMultipleImages
1773
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2481
    ^ imageSequence size > 1
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2482
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2483
    "Created: 4.4.1997 / 21:37:06 / cg"
1773
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2484
    "Modified: 24.6.1997 / 15:33:43 / cg"
1550
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2485
!
afee7c032a57 rudimentary support for multiple images.
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
  2486
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2487
height
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2488
    "return the height of the image"
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2489
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2490
    ^ height
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2491
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2492
    "Modified: 22.4.1996 / 19:15:39 / cg"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2493
!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2494
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2495
image
1772
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2496
    "return the image as represented by myself;
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2497
     If my file contained multiple images, return the first one."
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2498
7908
84a8ad360ada #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7897
diff changeset
  2499
    imageSequence notEmptyOrNil ifTrue:[
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  2500
        ^ imageSequence first image
1772
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2501
    ].
2080
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2502
    ^ self makeImage.
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2503
7908
84a8ad360ada #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7897
diff changeset
  2504
    "Modified: / 15-01-1998 / 15:46:24 / stefan"
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  2505
    "Modified: / 26-08-2017 / 14:38:18 / cg"
2082
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2506
!
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2507
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2508
imageFrames
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2509
    "return a collection of all imageFrames as represented by myself.
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2510
     ImageFrames are wrappers for individual images, which hold
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2511
     additional information (such as image delay time).
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2512
     Nil is return for single image formats/files."
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2513
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2514
    ^ imageSequence
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2515
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2516
    "Created: / 1.4.1998 / 14:37:42 / cg"
893
24dc4b26a486 prepare to read mask/alpha channel
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  2517
!
24dc4b26a486 prepare to read mask/alpha channel
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  2518
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2519
images
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2520
    "return a collection of all images as represented by myself.
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2521
     For compatibility with single-image formats, return a collection
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  2522
     containing my single image here if the file format does not support
1773
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2523
     multiple images.
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2524
     Readers for formats with multiple images should leave the images
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2525
     in the imageSequence instVar as a side effect of reading."
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2526
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2527
    |img|
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2528
1773
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2529
    imageSequence notNil ifTrue:[
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  2530
        ^ (imageSequence collect:[:aFrame | aFrame image])
1773
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2531
    ].
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2532
2082
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2533
    img := self makeImage.
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2534
    img isNil ifTrue:[
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  2535
        ^ img
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2536
    ].
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2537
    ^ Array with:img
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2538
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  2539
    "Modified: / 01-04-1998 / 14:36:23 / cg"
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  2540
    "Modified (comment): / 26-08-2017 / 14:38:48 / cg"
1551
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2541
!
1e1f4820b93a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
  2542
2080
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2543
makeImage
2082
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2544
    "return the image as represented by the values found in my
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2545
     instvars; these have been typically set as a side effect of
e9dbcef26c9a fixed imageSequence reading
Claus Gittinger <cg@exept.de>
parents: 2080
diff changeset
  2546
     the fromStream:-method, which reads images."
2080
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2547
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2548
    |image depth|
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2549
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2550
    depth := self bitsPerPixel.
3839
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2551
    (depth notNil and:[data notNil]) ifTrue:[
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2552
	image := Image newForDepth:depth.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2553
	image depth:depth.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2554
	inStream isFileStream ifTrue:[
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2555
	    image fileName:inStream pathName.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2556
	].
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2557
	image
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2558
	    width:width
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2559
	    height:height
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2560
	    photometric:photometric
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2561
	    samplesPerPixel:samplesPerPixel
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2562
	    bitsPerSample:bitsPerSample
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2563
	    colorMap:colorMap
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2564
	    bits:data
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2565
	    mask:mask.
3386
b9294699dbcf care for nil-data when converting to an image
Claus Gittinger <cg@exept.de>
parents: 3263
diff changeset
  2566
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2567
	imageSequence notNil ifTrue:[
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2568
	    image imageSequence:imageSequence.
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2569
	].
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2570
	metaData notEmptyOrNil ifTrue:[
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2571
	    image metaData:metaData
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2572
	].
2080
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2573
    ].
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2574
    ^ image
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2575
8026
532ccce8b1fd #REFACTORING by mawalch
mawalch
parents: 7929
diff changeset
  2576
    "Modified: / 15-01-1998 / 15:46:24 / stefan"
532ccce8b1fd #REFACTORING by mawalch
mawalch
parents: 7929
diff changeset
  2577
    "Created: / 01-04-1998 / 14:09:45 / cg"
532ccce8b1fd #REFACTORING by mawalch
mawalch
parents: 7929
diff changeset
  2578
    "Modified: / 17-05-2017 / 14:37:16 / mawalch"
2080
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2579
!
5361e4ffaaaf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2044
diff changeset
  2580
893
24dc4b26a486 prepare to read mask/alpha channel
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  2581
mask
24dc4b26a486 prepare to read mask/alpha channel
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  2582
    "return the image mask (or nil)"
24dc4b26a486 prepare to read mask/alpha channel
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  2583
24dc4b26a486 prepare to read mask/alpha channel
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  2584
    ^ mask
24dc4b26a486 prepare to read mask/alpha channel
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  2585
24dc4b26a486 prepare to read mask/alpha channel
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  2586
    "Modified: 22.4.1996 / 19:15:31 / cg"
24dc4b26a486 prepare to read mask/alpha channel
Claus Gittinger <cg@exept.de>
parents: 665
diff changeset
  2587
    "Created: 20.6.1996 / 17:08:29 / cg"
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2588
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2589
1772
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2590
numberOfImages
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2591
    "return the number of images as read.
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2592
     By default (here), I hold a single image;
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2593
     however, some fileFormats allow for multiple images"
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2594
1773
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2595
    |n|
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2596
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2597
    (n := imageSequence size) > 0 ifTrue:[
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  2598
	^ n
1773
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2599
    ].
1772
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2600
    ^ 1
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2601
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2602
    "Created: 21.6.1997 / 18:33:45 / cg"
1773
e12d18fb2b4c multiple images changes
Claus Gittinger <cg@exept.de>
parents: 1772
diff changeset
  2603
    "Modified: 24.6.1997 / 15:33:26 / cg"
1772
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2604
!
56b3ae478bbb changes to support multiple images
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  2605
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2606
photometric
6309
d12f01f0e52e class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2607
    "return the photometric interpretation of the image data.
d12f01f0e52e class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2608
     This may be a somewhat old leftover from times, when tiff was the first image file type to be read.
d12f01f0e52e class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2609
     Much better would be to always have some (possibly fake and virtual) colormap around, and ask that one.
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2610
     However, in the meantime, many other classes depend on that, so that it should be kept as an API
6309
d12f01f0e52e class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6167
diff changeset
  2611
     - even when the internal representation will be replaced by something better in the future."
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2612
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2613
    ^ photometric
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2614
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2615
    "Modified: 22.4.1996 / 19:15:57 / cg"
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2616
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2617
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2618
samplesPerPixel
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2619
    "return the number of samples per pixel"
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2620
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2621
    ^ samplesPerPixel
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2622
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2623
    "Modified: 22.4.1996 / 19:16:03 / cg"
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2624
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2625
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2626
width
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2627
    "return the width of the image"
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2628
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2629
    ^ width
583
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2630
211abfdb4db5 commentary
Claus Gittinger <cg@exept.de>
parents: 518
diff changeset
  2631
    "Modified: 22.4.1996 / 19:16:10 / cg"
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2632
! !
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2633
3263
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 3260
diff changeset
  2634
!ImageReader methodsFor:'accessing-private'!
1355
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2635
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2636
byteOrder:aSymbol
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2637
    "set the byte order - either #lsb or #msb"
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2638
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2639
    byteOrder := aSymbol
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2640
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2641
    "Created: 15.2.1997 / 13:58:50 / cg"
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2642
!
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2643
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2644
inStream
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2645
    ^ inStream
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2646
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2647
    "Created: 15.2.1997 / 13:57:40 / cg"
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2648
!
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2649
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2650
inStream:aStream
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2651
    inStream := aStream
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2652
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2653
    "Created: 15.2.1997 / 13:57:35 / cg"
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2654
! !
a7ec624230c0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2655
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2656
!ImageReader methodsFor:'error reporting'!
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2657
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2658
fileFormatError:aMessage
7925
2c80806ec2de #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7924
diff changeset
  2659
    "report a format error - no image could be read.
2c80806ec2de #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7924
diff changeset
  2660
     The error may be proceeded, then a nil is returned (useful for image sequences as in ICNS)"
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2661
8129
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2662
    ^ self fileFormatError:aMessage with:nil
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2663
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2664
    "Created: / 03-02-1998 / 17:50:06 / cg"
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2665
    "Modified: / 29-08-2017 / 23:00:51 / cg"
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2666
!
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2667
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2668
fileFormatError:aMessage with:argument
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2669
    "report a format error - no image could be read.
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2670
     The error may be proceeded, then a nil is returned (useful for image sequences as in ICNS)"
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2671
4055
bb45fa7310eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4033
diff changeset
  2672
    |errorString|
bb45fa7310eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4033
diff changeset
  2673
8129
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2674
    errorString := self class name , ' [error]: ' , (aMessage bindWith:argument).
4055
bb45fa7310eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4033
diff changeset
  2675
    inStream isFileStream ifTrue:[
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  2676
        errorString := errorString , Character cr, '[in "' , inStream pathName , '"]'
4055
bb45fa7310eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4033
diff changeset
  2677
    ].
bb45fa7310eb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4033
diff changeset
  2678
6618
9d377a77a1a1 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6585
diff changeset
  2679
    Image badImageFormatQuerySignal raiseRequestErrorString:errorString.
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2680
    ^ nil
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2681
8129
a84ca4eab4ae #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8110
diff changeset
  2682
    "Created: / 29-08-2017 / 23:00:37 / cg"
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2683
! !
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2684
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2685
!ImageReader methodsFor:'i/o support'!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2686
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2687
readLong
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2688
    "return the next 4-byte long, honoring the byte-order"
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2689
7142
439177d49d77 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 6902
diff changeset
  2690
    ^ inStream nextInt32MSB:(byteOrder ~~ #lsb)
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2691
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2692
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2693
readShort
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2694
    "return the next 2-byte short, honoring the byte-order"
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2695
7142
439177d49d77 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 6902
diff changeset
  2696
    ^ inStream nextUnsignedInt16MSB:(byteOrder ~~ #lsb)
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2697
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2698
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2699
readShortLong
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2700
    "return the next 2-byte short, honoring the byte-order.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2701
     There are actually 4 bytes read, but only 2 looked at."
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2702
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2703
    |bytes val|
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2704
153
claus
parents: 134
diff changeset
  2705
    bytes := ByteArray uninitializedNew:4.
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2706
    inStream nextBytes:4 into:bytes.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2707
    (byteOrder == #lsb) ifTrue:[
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2708
	val := bytes at:2.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2709
	val := val * 256 + (bytes at:1)
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2710
    ] ifFalse:[
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2711
	val := bytes at:3.
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2712
	val := val * 256 + (bytes at:4)
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2713
    ].
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2714
    ^ val
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2715
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2716
5318
c1947a63d265 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5129
diff changeset
  2717
readUnsignedLong
c1947a63d265 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5129
diff changeset
  2718
    "return the next 4-byte long, honoring the byte-order"
c1947a63d265 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5129
diff changeset
  2719
7142
439177d49d77 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 6902
diff changeset
  2720
    ^ inStream nextUnsignedInt32MSB:(byteOrder ~~ #lsb)
5318
c1947a63d265 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5129
diff changeset
  2721
!
c1947a63d265 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5129
diff changeset
  2722
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2723
writeLong:anInteger
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2724
    "write a 4-byte long, honoring the byte-order."
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2725
7142
439177d49d77 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 6902
diff changeset
  2726
    outStream nextPutInt32:anInteger MSB:(byteOrder ~~ #lsb)
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2727
!
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2728
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2729
writeShort:anInteger
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2730
    "write a 2-byte short, honoring the byte-order."
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2731
7142
439177d49d77 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 6902
diff changeset
  2732
    outStream nextPutInt16:anInteger MSB:(byteOrder ~~ #lsb)
105
6a4a21c17e5d *** empty log message ***
claus
parents: 97
diff changeset
  2733
! !
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2734
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2735
!ImageReader methodsFor:'image reading'!
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2736
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2737
fromStream:aStream
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2738
    "read an image in my format from aStream.
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2739
     Leave image description in instance variables."
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2740
3839
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2741
    self inStream:aStream.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2742
    self readImage.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2743
!
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2744
3839
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2745
readImage
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2746
    "read an image in my format from my inStream.
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2747
     Leave image description in instance variables."
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2748
3839
28440069abe4 refactorings
Claus Gittinger <cg@exept.de>
parents: 3836
diff changeset
  2749
    self subclassResponsibility.
2039
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2750
! !
00e10543cf57 added common fileFormatError reporter
Claus Gittinger <cg@exept.de>
parents: 2014
diff changeset
  2751
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  2752
!ImageReader methodsFor:'image reading support'!
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2753
929
f792d9689def Moved #buildMask from GIFReader to #buildMaskFromColor:
Stefan Vogel <sv@exept.de>
parents: 893
diff changeset
  2754
buildMaskFromColor:maskPixelValue
1631
fc944d181796 use ImageMask instead of Depth1Image
Claus Gittinger <cg@exept.de>
parents: 1574
diff changeset
  2755
    "helper for image formats, where an individual pixel value
fc944d181796 use ImageMask instead of Depth1Image
Claus Gittinger <cg@exept.de>
parents: 1574
diff changeset
  2756
     has been defined as a mask-pixel (i.e. GIF).
fc944d181796 use ImageMask instead of Depth1Image
Claus Gittinger <cg@exept.de>
parents: 1574
diff changeset
  2757
     Creates a maskImage, with zeros at positions where the image
fc944d181796 use ImageMask instead of Depth1Image
Claus Gittinger <cg@exept.de>
parents: 1574
diff changeset
  2758
     has the given pixelValue; all other mask pixels are set to 1."
fc944d181796 use ImageMask instead of Depth1Image
Claus Gittinger <cg@exept.de>
parents: 1574
diff changeset
  2759
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2760
    mask := self class
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2761
		buildMaskFromColor:maskPixelValue
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2762
		for:data depth:(self bitsPerPixel)
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2763
		width:width height:height
929
f792d9689def Moved #buildMask from GIFReader to #buildMaskFromColor:
Stefan Vogel <sv@exept.de>
parents: 893
diff changeset
  2764
8095
7d4b25655182 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8060
diff changeset
  2765
    "Modified: / 23-08-2017 / 17:11:51 / cg"
1983
03a93138c52a made buildMask public and a class method (functionality also needed by JavaVM)
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
  2766
! !
929
f792d9689def Moved #buildMask from GIFReader to #buildMaskFromColor:
Stefan Vogel <sv@exept.de>
parents: 893
diff changeset
  2767
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2768
!ImageReader methodsFor:'image writing'!
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2769
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2770
save:image onFile:aFileName
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2771
    "save image in my format on aFile"
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2772
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2773
    self writingFile:aFileName for:image do:[:stream |
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  2774
	self save:image onStream:stream.
5567
7a7a10a2e29c changed: #save:onFile:
Claus Gittinger <cg@exept.de>
parents: 5527
diff changeset
  2775
    ].
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2776
!
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2777
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2778
save:image onFile:aFileName quality:qualityPercentOrNil
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2779
    "save image in my format on aFile"
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2780
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2781
    self compressQuality:qualityPercentOrNil.
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2782
    self save:image onFile:aFileName
3933
10147dc53aef image saving - use save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3932
diff changeset
  2783
5567
7a7a10a2e29c changed: #save:onFile:
Claus Gittinger <cg@exept.de>
parents: 5527
diff changeset
  2784
    "Modified: / 01-06-2010 / 19:02:17 / cg"
3932
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2785
!
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2786
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2787
save:image onStream:aStream
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2788
    "save image in my file-format onto aStream"
3932
afa76a9c32eb +save:onStream:
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  2789
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2790
    ^ Image cannotRepresentImageSignal
7182
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  2791
	raiseWith:image
60d1db16530b #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 7174
diff changeset
  2792
	errorString:('image save not implemented/supported for this format').
7172
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2793
!
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2794
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2795
save:image onStream:aStream quality:qualityPercentOrNil
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2796
    "save image in my format on a Stream.
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2797
     QualityPercent is ignored by lossless formats (jpg uses it)"
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2798
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2799
    self compressQuality:qualityPercentOrNil.
6d903c0407fa #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7142
diff changeset
  2800
    self save:image onStream:aStream
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2801
!
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2802
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2803
saveAll:aCollectionOfImages onFile:aFileName
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2804
    "save a collection of images in my format on aFile.
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2805
     Not all file formats support multiple images,
7924
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2806
     so be prepared for an exception to be raised."
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2807
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2808
    self writingFile:aFileName for:aCollectionOfImages do:[:stream |
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2809
	self saveAll:aCollectionOfImages onStream:stream.
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2810
    ].
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2811
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2812
    "Modified: / 01-06-2010 / 19:02:17 / cg"
7924
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2813
    "Modified (comment): / 22-02-2017 / 01:00:03 / cg"
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2814
!
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2815
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2816
saveAll:aCollectionOfImages onStream:aStream
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2817
    "save an image collection in my format on a Stream.
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2818
     Not all file formats support multiple images,
7924
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2819
     so be prepared for an exception to be raised."
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2820
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2821
    ^ Image cannotRepresentImageSignal
8101
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2822
	raiseWith:aCollectionOfImages
89a8d155c22a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8095
diff changeset
  2823
	errorString:('save of imageSequence not implemented/supported for this format').
7924
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2824
ff2f12b98716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7908
diff changeset
  2825
    "Modified (comment): / 22-02-2017 / 01:00:11 / cg"
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2826
!
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2827
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2828
writingFile:aFileName for:something do:aBlock
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2829
    "helper for save image"
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2830
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2831
    |stream|
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2832
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2833
    [
8328
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2834
        stream := aFileName asFilename newReadWriteStream.
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2835
    ] on:FileStream openErrorSignal do:[:ex|
8328
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2836
        ^ Image fileCreationErrorSignal
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2837
            raiseWith:something
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2838
            errorString:('file creation error: ' , ex description).
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2839
    ].
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2840
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2841
    [
8328
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2842
        [
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2843
            aBlock value: stream
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2844
        ] ensure:[
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2845
            stream close.
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2846
        ].
6377
7546e57a7035 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6309
diff changeset
  2847
    ] ifCurtailed:[
8328
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2848
        OsError catch:[
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2849
            aFileName asFilename remove.
9c4240cfee1a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8246
diff changeset
  2850
        ]
6057
5d6464c7f936 class: ImageReader
Claus Gittinger <cg@exept.de>
parents: 6042
diff changeset
  2851
    ].
8060
009e27b016b1 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 8026
diff changeset
  2852
009e27b016b1 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 8026
diff changeset
  2853
    "Modified: / 04-08-2017 / 11:28:41 / stefan"
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2854
! !
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2855
1358
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  2856
!ImageReader methodsFor:'initialization'!
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  2857
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  2858
initialize
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  2859
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  2860
    "Created: 18.2.1997 / 17:08:31 / cg"
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  2861
! !
193570ad2ff5 added dummy #initialize
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  2862
3955
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2863
!ImageReader methodsFor:'progress reporting'!
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2864
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2865
dimensionCallBack:aBlock
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2866
    "set the block, which is evaluated during the readProcess, as soon as
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2867
     the images dimension is known. This is useful for background image reading,
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2868
     if the size is need to be known (for example: for formatting purposes).
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2869
     Obsoleted by dimensionHolder."
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2870
4177
7c3612e35974 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 4055
diff changeset
  2871
    <resource:#obsolete>
3965
8c9c9e08880c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3957
diff changeset
  2872
    self obsoleteMethodWarning:'use #dimensionHolder'.
3955
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2873
    dimensionCallBack := aBlock
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2874
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2875
    "Created: 14.9.1996 / 17:10:58 / cg"
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2876
!
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2877
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2878
dimensionHolder:aValueHolderOrBlock
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2879
    "set the valueHolder or block, which is evaluated during the readProcess,
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2880
     as soon as the images dimension is known.
3955
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2881
     Useful for background image reading, if the size is need to be known (for example: for formatting purposes)."
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2882
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2883
    dimensionHolder := aValueHolderOrBlock
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2884
!
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2885
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2886
progressHolder:aValueHolderOrBlock
4714
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2887
    "set the valueHolder or block, which is evaluated during the readProcess,
3ea57c207759 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4401
diff changeset
  2888
     and set with progress information (0..100 percent).
3955
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2889
     Useful for user feedback"
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2890
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2891
    progressHolder := aValueHolderOrBlock
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2892
!
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2893
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2894
reportDimension
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2895
    dimensionCallBack notNil ifTrue:[
4033
9af502584519 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
  2896
	dimensionCallBack value:self
3955
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2897
    ].
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2898
    dimensionHolder notNil ifTrue:[
4033
9af502584519 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
  2899
	dimensionHolder value:(width @ height)
3955
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2900
    ].
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2901
!
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2902
3957
ffe8a76fae45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3955
diff changeset
  2903
reportProgress:fraction
ffe8a76fae45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3955
diff changeset
  2904
    "can be used by a GUI application to indicate loading progress (0..1)"
ffe8a76fae45 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3955
diff changeset
  2905
3955
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2906
    progressHolder notNil ifTrue:[
4033
9af502584519 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3965
diff changeset
  2907
	progressHolder value:fraction
3955
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2908
    ].
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2909
! !
6f48b9693fe5 dimensionReport and progressReport hooks
Claus Gittinger <cg@exept.de>
parents: 3933
diff changeset
  2910
8246
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2911
!ImageReader::EnforcedImageTypeQuery class methodsFor:'documentation'!
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2912
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2913
documentation
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2914
"
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2915
    consider this a hack (but a not too bad one):
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2916
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2917
    with pngReader (and maybe others), we may want to read an image file,
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2918
    but ignore the alpha channel.
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2919
    I.e. read it as an rgb image although the image file is actually rgba formatted.
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2920
    This is useful, if the image contains invalid alpha information anyway,
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2921
    as when asking appium for a screen shot 
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2922
    (there are no transparent pixels on the screen - at least not until we get glass-plate displays...)
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2923
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2924
    Instead of passing this information down through all the possible image and image reader interfaces,
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2925
    this query is asked by some readers (currently only pngReader) and
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2926
    can be answered high above by a caller to answer #rgb.
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2927
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2928
    The default answer (nil) leads to the old behavior in that the file itself determines the format.
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2929
    Please take a look at the concrete image reader documentation for which answers are valid and useful.
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2930
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2931
    [author:]
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2932
        cg
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2933
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2934
    [instance variables:]
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2935
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2936
    [class variables:]
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2937
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2938
    [see also:]
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2939
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2940
"
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2941
! !
7fbe2b212aee #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8146
diff changeset
  2942
1167
4998857f7a9a new infoMessage scheme
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  2943
!ImageReader class methodsFor:'documentation'!
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2944
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2945
version
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2946
    ^ '$Header$'
5481
93de6ee2ed5a __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5318
diff changeset
  2947
!
93de6ee2ed5a __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5318
diff changeset
  2948
93de6ee2ed5a __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5318
diff changeset
  2949
version_CVS
6902
6357c181c178 eliminated a compiler warning
Claus Gittinger <cg@exept.de>
parents: 6761
diff changeset
  2950
    ^ '$Header$'
285
1effedd62f30 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
  2951
! !
8110
19a15da94872 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8107
diff changeset
  2952