Depth32Image.st
author Claus Gittinger <cg@exept.de>
Wed, 22 Aug 2018 12:58:11 +0200
changeset 8451 6eafe0433763
parent 8339 b2b10047577b
child 8728 289cdc983b33
permissions -rw-r--r--
#QUALITY by cg class: WindowSensor comment/format in: #basicAddDamage:view:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8339
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
     1
"{ Encoding: utf8 }"
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
     2
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 1995 by Claus Gittinger
6066
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
     5
	      All Rights Reserved
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
3263
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
    14
"{ Package: 'stx:libview' }"
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
    15
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
    16
"{ NameSpace: Smalltalk }"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
    17
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
Image subclass:#Depth32Image
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Graphics-Images'
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!Depth32Image class methodsFor:'documentation'!
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 1995 by Claus Gittinger
6066
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
    30
	      All Rights Reserved
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
!
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
7902
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
    43
    this class represents 32 bit (eg. rgb+alpha) images.
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
    44
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    Only the minimum protocol is implemented here; much more is
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    needed for higher performance operations on depth32 images.
7902
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
    47
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    48
    with #rgb, #rgba, #rgbx, photometrics 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    49
    pixels are internally stored byte-wise in rgba order.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    50
    (i.e. r at low-address byte, a at high-address byte). 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    51
    For rgb, a zero is always retrieved as alpha; 255 for rgbx.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    52
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    53
    When reading pixel values, photometric argb is returned as aarrggbb,
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    54
    photometric rgb is returned as 00rrggbb,
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    55
    photometric rgba is returned as rrggbb00,
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    56
    both on LSB and on MSB machines.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    57
    (i.e. blue in lower bits of the returned 32bit integer, alpha in the high bits for argb,
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    58
     and in the low bits for rgba)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    59
    Thus, pixelValues and rgbValues are identical, simulating MSB on all
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    60
    architectures.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    61
    (this should be transparent, if you use the rgbValueAt
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    62
     accessors; however, some old code uses pixelValueAt:, assuming that the
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    63
    returned pixel value is rrggbb - which it would not be without this hack).
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    64
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    65
    This also makes depth24Image's rgbValues compatible with depth32Image's rgbValues.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    66
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    67
    For argb and xrgb formats, alpha (or dummy alpha) is in the first byte 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    68
    (which are the high bits, as we present pixel values always MSB).
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
    69
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    [author:]
7902
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
    71
        Claus Gittinger
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    [see also:]
7902
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
    74
        Depth1Image Depth2Image Depth4Image Depth8Image Depth16Image Depth24Image
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
    75
        ImageReader
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
! !
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
!Depth32Image class methodsFor:'queries'!
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
    81
defaultPhotometric
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
    82
    "return the default photometric pixel interpretation"
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
    83
7903
8dd4063b92fb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7902
diff changeset
    84
    "/ here we return #rgb - thus ignoring any alpha channel.
8dd4063b92fb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7902
diff changeset
    85
    "/ the reason is that many displays and graphics formats do use
8dd4063b92fb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7902
diff changeset
    86
    "/ 32bit per pixel, but provide an alpha value of 0, instead of 255.
8dd4063b92fb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7902
diff changeset
    87
    "/ Thus returning rgba here would make many images invisible (totally transparent)
8dd4063b92fb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7902
diff changeset
    88
    
5324
63a97775c5fc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5297
diff changeset
    89
    ^ #rgb
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
    90
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
    91
    "Created: / 27-05-2007 / 14:03:59 / cg"
7903
8dd4063b92fb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7902
diff changeset
    92
    "Modified: / 16-02-2017 / 17:41:09 / cg"
8dd4063b92fb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7902
diff changeset
    93
    "Modified (comment): / 16-02-2017 / 19:00:25 / cg"
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
    94
!
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
    95
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
imageDepth
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    "return the depth of images represented by instances of
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
     this class - here we return 32"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    ^ 32
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    "Modified: 20.4.1996 / 23:40:01 / cg"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    "Created: 24.4.1997 / 19:00:28 / cg"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
! !
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
3263
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   106
!Depth32Image methodsFor:'accessing-pixels'!
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   108
colorAtX:x y:y
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   109
    "retrieve a pixel at x/y; return a color.
7124
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   110
     Pixels start at x=0 , y=0 for upper left pixel, 
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   111
     end at x = width-1, y=height-1 for lower right pixel"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   112
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   113
    |index "{ Class: SmallInteger }"
7124
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   114
     rVal gVal bVal aVal|
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   115
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   116
    index := 1 + (((width * y) + x) * 4).
8339
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   117
    ((photometric == #rgb) or:[photometric == #xrgb]) ifTrue:[
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   118
        "/ byteorder is: <ignoredAlpha>,r,g,b
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   119
        rVal := bytes at:(index + 1).
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   120
        gVal := bytes at:(index + 2).
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   121
        bVal := bytes at:(index + 3).
7124
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   122
        ^ Color redByte:rVal greenByte:gVal blueByte:bVal
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   123
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   124
    (photometric == #rgba) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   125
        "/ byteorder is: r,g,b,<ignoredAlpha>
7124
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   126
        rVal := bytes at:(index).
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   127
        gVal := bytes at:(index + 1).
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   128
        bVal := bytes at:(index + 2).
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   129
        aVal := bytes at:(index + 3).
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   130
        ^ Color redByte:rVal greenByte:gVal blueByte:bVal alphaByte:aVal
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   131
    ].
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   132
    photometric == #argb ifTrue:[
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   133
        "/ byteorder is: a,r,g,b
7124
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   134
        aVal := bytes at:(index).
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   135
        rVal := bytes at:(index + 1).
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   136
        gVal := bytes at:(index + 2).
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   137
        bVal := bytes at:(index + 3).
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   138
        ^ Color redByte:rVal greenByte:gVal blueByte:bVal alphaByte:aVal
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   139
    ].
8339
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   140
    photometric == #xrgb ifTrue:[
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   141
        "/ byteorder is: ignored-alpha,r,g,b
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   142
        rVal := bytes at:(index + 1).
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   143
        gVal := bytes at:(index + 2).
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   144
        bVal := bytes at:(index + 3).
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   145
        ^ Color redByte:rVal greenByte:gVal blueByte:bVal
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   146
    ].
7124
51bbda668ab4 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7122
diff changeset
   147
    "/ the inherited method should handle all cases.
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   148
    ^ super colorAtX:x y:y.
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   149
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   150
    "Modified: / 22-08-2017 / 18:17:38 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   151
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   152
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   153
colorAtX:x y:y put:aColor
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   154
    "set the pixel at x/y to aColor.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   155
     Pixels start at x=0 , y=0 for upper left pixel, end at
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   156
     x = width-1, y=height-1 for lower right pixel."
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   157
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   158
    |index "{ Class: SmallInteger }"
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   159
     r g b|
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   160
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   161
    index := 1 + (((width * y) + x) * 4).
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   162
    r := aColor redByte.
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   163
    g := aColor greenByte.
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   164
    b := aColor blueByte.
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   165
    
8339
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   166
    ((photometric == #rgb) or:[(photometric == #xrgb)]) ifTrue:[
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   167
        "/ byteorder is: ignored-alpha,r,g,b
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   168
        bytes at:(index + 1) put:r.
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   169
        bytes at:(index + 2) put:g.
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   170
        bytes at:(index + 3) put:b.
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   171
        ^ self
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   172
    ].
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   173
    (photometric == #rgba) ifTrue:[
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   174
        "/ byteorder is: r,g,b,a
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   175
        bytes at:(index + 0) put:r.
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   176
        bytes at:(index + 1) put:g.
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   177
        bytes at:(index + 2) put:b.
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   178
        bytes at:(index + 3) put:(aColor alphaByte). "alpha channel in last byte"
7167
12b5d9ffc66c #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7124
diff changeset
   179
        ^ self
12b5d9ffc66c #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7124
diff changeset
   180
    ].
12b5d9ffc66c #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7124
diff changeset
   181
    (photometric == #argb) ifTrue:[
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   182
        "/ byteorder is: a,r,g,b
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   183
        bytes at:(index + 0) put:(aColor alphaByte).     "alpha channel in first byte"
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   184
        bytes at:(index + 1) put:r.
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   185
        bytes at:(index + 2) put:g.
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   186
        bytes at:(index + 3) put:b.             
7167
12b5d9ffc66c #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7124
diff changeset
   187
        ^ self
12b5d9ffc66c #FEATURE
Claus Gittinger <cg@exept.de>
parents: 7124
diff changeset
   188
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   189
    (photometric == #rgbx) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   190
        "/ byteorder is: <ignoredAlpha>,r,g,b
8339
b2b10047577b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8327
diff changeset
   191
        bytes at:(index + 0) put:r.
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   192
        bytes at:(index + 1) put:g.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   193
        bytes at:(index + 2) put:b.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   194
        ^ self
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   195
    ].
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   196
7917
fb1dcd2edc4e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7903
diff changeset
   197
    super colorAtX:x y:y put:aColor.
fb1dcd2edc4e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7903
diff changeset
   198
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   199
    "Modified: / 22-08-2017 / 18:17:14 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   200
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   201
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
pixelAtX:x y:y
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    "retrieve a pixel at x/y; return a pixelValue.
7514
cdfa1afc6956 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7497
diff changeset
   204
     The interpretation of the returned value depends on the photometric
cdfa1afc6956 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7497
diff changeset
   205
     and the colormap. See also Image>>atX:y:)
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
     Pixels start at x=0 , y=0 for upper left pixel, end at
7279
51d86b5b7883 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7274
diff changeset
   207
     x = width-1, y=height-1 for lower right pixel.
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   208
     With rgba photometric, the pixel value contains r/g/b/a in lsb order 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   209
     (i.e. r at low, a at high bits);
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   210
     with argb, alpha is in the low byte"
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
1669
d156d2623f41 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1663
diff changeset
   212
    |pixelIndex "{ Class: SmallInteger }"|
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
7274
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   214
%{  /* NOCONTEXT */
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   215
    OBJ b = __INST(bytes);
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   216
    OBJ w = __INST(width);
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   217
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   218
    if (__isByteArrayLike(b)
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   219
     && __bothSmallInteger(x, y)
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   220
     && __isSmallInteger(w)
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   221
     && (__INST(pixelFunction)==nil) ) {
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   222
        int _idx;
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   223
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   224
        _idx = ((__intVal(w) * __intVal(y)) + __intVal(x))*4;
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   225
        if (((unsigned)(_idx+3)) < __byteArraySize(b)) {
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   226
            unsigned char *pPix = &(__ByteArrayInstPtr(b)->ba_element[_idx]);
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   227
            unsigned int _pix;
7917
fb1dcd2edc4e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7903
diff changeset
   228
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   229
#ifdef __MSBFIRST__
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   230
            _pix = ((int *)pPix)[0];
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   231
#else
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   232
            _pix = pPix[0] << 24;
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   233
            _pix |= pPix[1] << 16;
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   234
            _pix |= pPix[2] << 8;
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   235
            _pix |= pPix[3];
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   236
#endif
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   237
7274
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   238
#if __POINTER_SIZE__ == 8
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   239
            RETURN( __MKSMALLINT(_pix) );
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   240
#else
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   241
            RETURN( __MKUINT(_pix) );
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   242
#endif
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   243
        }
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   244
    }
32011db2fd2c #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 7225
diff changeset
   245
%}.
6302
d393dae43c28 pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 6066
diff changeset
   246
    pixelFunction notNil ifTrue:[^ pixelFunction value:x value:y].
d393dae43c28 pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 6066
diff changeset
   247
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   248
    pixelIndex := 1 + (((width * y) + x) * 4).
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   249
    ^ bytes unsignedInt32At:pixelIndex MSB:true.
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
7917
fb1dcd2edc4e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7903
diff changeset
   251
    "Created: / 24-04-1997 / 19:00:28 / cg"
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   252
    "Modified: / 21-02-2017 / 17:21:44 / cg"
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   253
    "Modified (comment): / 22-08-2017 / 18:24:22 / cg"
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
!
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
pixelAtX:x y:y put:aPixelValue
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    "set the pixel at x/y to aPixelValue.
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   258
     The interpretation of the pixelValue depends on the photometric.
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
     Pixels start at x=0 , y=0 for upper left pixel, end at
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   260
     x = width-1, y=height-1 for lower right pixel.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   261
     With rgba photometric, the pixel value contains r/g/b/a in lsb order 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   262
     (i.e. r at low, a at high bits);
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   263
     with argb, alpha is in the low byte"
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
1669
d156d2623f41 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1663
diff changeset
   265
    |pixelIndex "{ Class: SmallInteger }"|
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   267
%{  /* NOCONTEXT */
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   268
    OBJ b = __INST(bytes);
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   269
    OBJ w = __INST(width);
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   270
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   271
    if ((b != nil)
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   272
     && __isByteArrayLike(b)
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   273
     && __bothSmallInteger(x, y)
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   274
     && __isSmallInteger(aPixelValue)
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   275
     && (__INST(pixelFunction)==nil) ) {
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   276
        int _idx;
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   277
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   278
        _idx = ((__intVal(w) * __intVal(y)) + __intVal(x))*4;
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   279
        if (((unsigned)(_idx+3)) < __byteArraySize(b)) {
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   280
            unsigned char *pPix = &(__ByteArrayInstPtr(b)->ba_element[_idx]);
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   281
            unsigned int _pix = __intVal(aPixelValue);
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   282
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   283
#ifdef __MSBFIRST__
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   284
            ((int *)pPix)[0] = _pix;
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   285
#else
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   286
            pPix[0] = (_pix >> 24) & 0xFF;
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   287
            pPix[1] = (_pix >> 16) & 0xFF;
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   288
            pPix[2] = (_pix >> 8) & 0xFF;
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   289
            pPix[3] = _pix & 0xFF;
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   290
#endif
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   291
            RETURN(self);
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   292
        }
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   293
    }
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   294
%}.
8201
d8a475e6e994 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 8166
diff changeset
   295
    bytes isNil ifTrue:[ self createPixelStore ].
d8a475e6e994 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 8166
diff changeset
   296
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   297
    pixelIndex := 1 + (((width * y) + x) * 4).
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   298
    bytes unsignedInt32At:pixelIndex put:aPixelValue MSB:true.
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
4790
652fca7eac26 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4763
diff changeset
   300
    "Created: / 24-04-1997 / 19:00:28 / cg"
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
   301
    "Modified: / 22-08-2017 / 18:21:47 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   302
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   303
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   304
rowAt:y putAll:pixelArray startingAt:startIndex
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   305
    "store a single rows bits from bits in the pixelArray argument;
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   306
     The interpretation of the pixel values depends on the photometric.
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   307
     Notice: row coordinate starts at 0."
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   308
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   309
    |bytes pixel
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   310
     dstIdx "{ Class: SmallInteger }" 
6846
6c9367f0ecb8 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6841
diff changeset
   311
     w "{ Class: SmallInteger }"|
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   312
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   313
    bytes := self bits.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   314
    dstIdx := (y * self bytesPerRow) + 1.
6846
6c9367f0ecb8 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6841
diff changeset
   315
    w := width - 1.
6c9367f0ecb8 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6841
diff changeset
   316
6c9367f0ecb8 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6841
diff changeset
   317
    0 to:w do:[:col |
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   318
        pixel := pixelArray at:(startIndex + col).
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   319
        "/ msbFirst
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   320
        bytes unsignedInt32At:dstIdx put:pixel MSB:true.
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   321
        dstIdx := dstIdx + 4.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   322
    ].
7917
fb1dcd2edc4e #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7903
diff changeset
   323
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   324
    "Modified (comment): / 21-02-2017 / 15:03:24 / cg"
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
! !
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   327
!Depth32Image methodsFor:'converting rgb images'!
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   328
7492
34cfdad00603 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7279
diff changeset
   329
computeAlphaValuesFromMask:aMaskImage
34cfdad00603 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7279
diff changeset
   330
    "convert a mask into alpha values;
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   331
     masked pixels get an alpha value of 0, unmasked of 255"
7492
34cfdad00603 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7279
diff changeset
   332
34cfdad00603 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7279
diff changeset
   333
    |alphaMask|
34cfdad00603 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7279
diff changeset
   334
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   335
    alphaMask := (self alphaMaskForPixelValue bitShift:self alphaShiftForPixelValue).
7902
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
   336
    self 
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
   337
        valuesFromX:0 y:0 toX:(width-1) y:(height-1)
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
   338
        do:[:x :y :pixelValue |
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
   339
            (aMaskImage pixelAtX:x y:y) ~~ 0 ifTrue:[
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
   340
                self pixelAtX:x y:y put:(pixelValue bitOr:alphaMask).
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
   341
            ] ifFalse:[
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
   342
                self pixelAtX:x y:y put:(pixelValue bitClear:alphaMask).
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
   343
            ].
7492
34cfdad00603 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7279
diff changeset
   344
        ].
34cfdad00603 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7279
diff changeset
   345
    photometric := #rgba
7902
865d2b3679cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7896
diff changeset
   346
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   347
    "Modified: / 21-02-2017 / 16:41:02 / cg"
7492
34cfdad00603 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7279
diff changeset
   348
!
34cfdad00603 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7279
diff changeset
   349
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   350
rgbImageAsTrueColorFormOn:aDevice
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   351
    "return a truecolor form from the rgba or argb-picture."
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   352
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   353
    |bytes bestFormat usedDeviceDepth usedDeviceBitsPerPixel usedDevicePadding
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   354
     myDepth form imageBits padd
8000
62ea15884e2b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7922
diff changeset
   355
     rightShiftR rightShiftG rightShiftB
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   356
     shiftRed shiftGreen shiftBlue
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   357
     redOffs greenOffs blueOffs alphaOffs|
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   358
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   359
    bytes := self bits.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   360
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   361
    bestFormat := self bestSupportedImageFormatFor:aDevice.
4763
69afd837e817 leftover halt:
Claus Gittinger <cg@exept.de>
parents: 4761
diff changeset
   362
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   363
    usedDeviceDepth := bestFormat at:#depth.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   364
    usedDeviceBitsPerPixel := bestFormat at:#bitsPerPixel.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   365
    usedDevicePadding := bestFormat at:#padding.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   366
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   367
    rightShiftR := (8 - aDevice bitsRed).
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   368
    rightShiftG := (8 - aDevice bitsGreen).
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   369
    rightShiftB := (8 - aDevice bitsBlue).
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   370
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   371
    shiftRed := aDevice shiftRed.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   372
    shiftGreen := aDevice shiftGreen.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   373
    shiftBlue := aDevice shiftBlue.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   374
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   375
    redOffs := 0.
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   376
    greenOffs := 1.  
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   377
    blueOffs := 2.
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   378
    alphaOffs := 3.
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   379
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   380
    ((photometric == #argb) or:[ photometric == #rgb ]) ifTrue:[
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   381
        redOffs := 1. greenOffs := 2. blueOffs := 3. alphaOffs := 0.
8114
4b012d4736b0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8094
diff changeset
   382
    ] ifFalse:[
4b012d4736b0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8094
diff changeset
   383
        (photometric == #rgba) ifFalse:[
4b012d4736b0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8094
diff changeset
   384
            ^ self anyImageAsTrueColorFormOn:aDevice
4b012d4736b0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8094
diff changeset
   385
        ].    
4b012d4736b0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8094
diff changeset
   386
    ].    
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   387
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   388
    "/
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   389
    "/ for now, only a few formats are supported
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   390
    "/
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   391
    myDepth := self bitsPerPixel.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   392
    usedDeviceBitsPerPixel == 24 ifTrue:[
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   393
        "/
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   394
        "/ 24 bit/pixel
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   395
        "/
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   396
        imageBits := ByteArray uninitializedNew:(width * height * 3).
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   397
        usedDevicePadding := 8.
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   398
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   399
        "/ now, walk over the image and compose 24bit values from the r/g/b/a triples
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   400
%{
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   401
        unsigned char *srcPtr = 0;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   402
        unsigned char *dstPtr = 0;
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   403
        int _redOffs = __intVal(redOffs);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   404
        int _greenOffs = __intVal(greenOffs);  
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   405
        int _blueOffs = __intVal(blueOffs);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   406
        // int _alphaOffs = __intVal(alphaOffs);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   407
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   408
        if (__isByteArrayLike(bytes)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   409
            srcPtr = __ByteArrayInstPtr(bytes)->ba_element;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   410
        } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   411
            if (__isExternalBytesLike(bytes)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   412
                srcPtr = __externalBytesAddress(bytes);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   413
            }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   414
        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   415
        if (__isByteArray(imageBits)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   416
            dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   417
        } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   418
            if (__isExternalBytesLike(imageBits)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   419
                dstPtr = __externalBytesAddress(imageBits);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   420
            }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   421
        }
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   422
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   423
        if (__bothSmallInteger(__INST(height), __INST(width))
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   424
         && __bothSmallInteger(rightShiftR, shiftRed)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   425
         && __bothSmallInteger(rightShiftG, shiftGreen)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   426
         && __bothSmallInteger(rightShiftB, shiftBlue)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   427
         && srcPtr
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   428
         && dstPtr) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   429
            int rShRed = __intVal(rightShiftR),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   430
                rShGreen = __intVal(rightShiftG),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   431
                rShBlue = __intVal(rightShiftB),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   432
                lShRed = __intVal(shiftRed),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   433
                lShGreen = __intVal(shiftGreen),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   434
                lShBlue = __intVal(shiftBlue);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   435
            int x, y, w;
5297
e1e2793072ad 32bit->24bit (win32) fix (rgb-bgr)
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   436
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   437
            w = __intVal(__INST(width));
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   438
            if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   439
                if ((lShRed == 0) && (lShGreen == 8) && (lShBlue == 16)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   440
                    for (y=__intVal(__INST(height)); y > 0; y--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   441
                        for (x=w; x > 0; x--) {                        
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   442
# ifdef __MSBFIRST
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   443
                            dstPtr[0] = srcPtr[_redOffs];
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   444
                            dstPtr[1] = srcPtr[_greenOffs];
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   445
                            dstPtr[2] = srcPtr[_blueOffs];
5297
e1e2793072ad 32bit->24bit (win32) fix (rgb-bgr)
Claus Gittinger <cg@exept.de>
parents: 4790
diff changeset
   446
# else /* not MSB */
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   447
                            dstPtr[0] = srcPtr[_blueOffs];
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   448
                            dstPtr[1] = srcPtr[_greenOffs];
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   449
                            dstPtr[2] = srcPtr[_redOffs];
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   450
# endif /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   451
                            dstPtr += 3;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   452
                            srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   453
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   454
                    }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   455
                } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   456
                    for (y=__intVal(__INST(height)); y > 0; y--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   457
                        for (x=w; x > 0; x--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   458
                            unsigned v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   459
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   460
                            v = srcPtr[_redOffs] << lShRed;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   461
                            v |= (srcPtr[_greenOffs] << lShGreen);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   462
                            v |= (srcPtr[_blueOffs] << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   463
# ifdef __MSBFIRST
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   464
                            dstPtr[0] = (v) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   465
                            dstPtr[1] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   466
                            dstPtr[2] = (v>>16) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   467
# else /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   468
                            dstPtr[0] = (v>>16) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   469
                            dstPtr[1] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   470
                            dstPtr[2] = (v) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   471
# endif /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   472
                            dstPtr += 3;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   473
                            srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   474
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   475
                    }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   476
                }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   477
            } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   478
                for (y=__intVal(__INST(height)); y > 0; y--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   479
                    for (x=w; x > 0; x--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   480
                        unsigned r, g, b, v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   481
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   482
                        r = srcPtr[_redOffs] >> rShRed;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   483
                        g = srcPtr[_greenOffs] >> rShGreen;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   484
                        b = srcPtr[_blueOffs] >> rShBlue;
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   485
                        v = r << lShRed;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   486
                        v |= (g << lShGreen);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   487
                        v |= (b << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   488
# ifdef __MSBFIRST
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   489
                        dstPtr[0] = (v) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   490
                        dstPtr[1] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   491
                        dstPtr[2] = (v>>16) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   492
# else /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   493
                        dstPtr[0] = (v>>16) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   494
                        dstPtr[1] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   495
                        dstPtr[2] = (v) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   496
# endif /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   497
                        dstPtr += 3;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   498
                        srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   499
                    }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   500
                }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   501
            }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   502
        }
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   503
%}.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   504
    ] ifFalse:[
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   505
        "/
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   506
        "/ 8, 16 or 32 bit/pixel ...
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   507
        "/
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   508
        (usedDeviceBitsPerPixel == 16) ifTrue:[
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   509
            padd := width \\ (usedDevicePadding // 16).
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   510
            imageBits := ByteArray uninitializedNew:((width + padd) * height * 2).
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   511
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   512
            "/ now, walk over the image and compose 16bit values from the r/g/b triples
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   513
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   514
%{
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   515
            unsigned char *srcPtr = 0;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   516
            unsigned char *dstPtr = 0;
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   517
            int _redOffs = __intVal(redOffs);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   518
            int _greenOffs = __intVal(greenOffs);  
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   519
            int _blueOffs = __intVal(blueOffs);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   520
            // int _alphaOffs = __intVal(alphaOffs);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   521
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   522
            if (__isByteArrayLike(bytes)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   523
                srcPtr = __ByteArrayInstPtr(bytes)->ba_element;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   524
            } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   525
                if (__isExternalBytesLike(bytes)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   526
                    srcPtr = __externalBytesAddress(bytes);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   527
                }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   528
            }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   529
            if (__isByteArray(imageBits)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   530
                dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   531
            } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   532
                if (__isExternalBytesLike(imageBits)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   533
                    dstPtr = __externalBytesAddress(imageBits);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   534
                }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   535
            }
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   536
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   537
            if (__bothSmallInteger(__INST(height),__INST(width))
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   538
             && __bothSmallInteger(rightShiftR, shiftRed)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   539
             && __bothSmallInteger(rightShiftG, shiftGreen)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   540
             && __bothSmallInteger(rightShiftB, shiftBlue)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   541
             && srcPtr
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   542
             && dstPtr) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   543
                int rShRed = __intVal(rightShiftR),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   544
                    rShGreen = __intVal(rightShiftG),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   545
                    rShBlue = __intVal(rightShiftB),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   546
                    lShRed = __intVal(shiftRed),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   547
                    lShGreen = __intVal(shiftGreen),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   548
                    lShBlue = __intVal(shiftBlue);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   549
                int x, y, w;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   550
                int p;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   551
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   552
                w = __intVal(__INST(width));
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   553
                p = __intVal(padd) * 2;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   554
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   555
                if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   556
                    for (y=__intVal(__INST(height)); y > 0; y--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   557
                        for (x=w; x > 0; x--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   558
                            unsigned v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   559
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   560
                            v = srcPtr[_redOffs] << lShRed;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   561
                            v |= (srcPtr[_greenOffs] << lShGreen);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   562
                            v |= (srcPtr[_blueOffs] << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   563
# ifdef __MSBFIRST
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   564
                            ((short *)dstPtr)[0] = v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   565
# else /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   566
                            dstPtr[0] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   567
                            dstPtr[1] = (v) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   568
# endif /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   569
                            dstPtr += 2;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   570
                            srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   571
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   572
                        dstPtr += p;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   573
                    }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   574
                } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   575
                    if (p == 0) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   576
                        int n = __intVal(__INST(height)) * w;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   577
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   578
                        while (n >= 2) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   579
                            unsigned w, r, g, b, v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   580
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   581
                            n -= 2;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   582
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   583
                            r = srcPtr[_redOffs];
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   584
                            g = srcPtr[_greenOffs];
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   585
                            b = srcPtr[_blueOffs];
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   586
                            v = (r >> rShRed) << lShRed;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   587
                            v |= ((g >> rShGreen) << lShGreen);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   588
                            v |= ((b >> rShBlue) << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   589
# ifdef __MSBFIRST
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   590
                            ((short *)dstPtr)[0] = v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   591
# else
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   592
                            dstPtr[0] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   593
                            dstPtr[1] = (v) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   594
# endif /* not MSB */
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   595
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   596
                            r = srcPtr[3+_redOffs];
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   597
                            g = srcPtr[3+_greenOffs];
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   598
                            b = srcPtr[3+_blueOffs];
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   599
                            v = (r >> rShRed) << lShRed;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   600
                            v |= ((g >> rShGreen) << lShGreen);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   601
                            v |= ((b >> rShBlue) << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   602
# ifdef __MSBFIRST
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   603
                            ((short *)dstPtr)[1] = v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   604
# else
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   605
                            dstPtr[2] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   606
                            dstPtr[3] = (v) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   607
# endif /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   608
                            dstPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   609
                            srcPtr += 8;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   610
                        }
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   611
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   612
                        while (n--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   613
                            unsigned r, g, b, v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   614
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   615
                            r = srcPtr[_redOffs] >> rShRed;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   616
                            g = srcPtr[_greenOffs] >> rShGreen;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   617
                            b = srcPtr[_blueOffs] >> rShBlue;
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   618
                            v = r << lShRed;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   619
                            v |= (g << lShGreen);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   620
                            v |= (b << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   621
# ifdef __MSBFIRST
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   622
                            ((short *)dstPtr)[0] = v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   623
# else /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   624
                            dstPtr[0] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   625
                            dstPtr[1] = (v) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   626
# endif /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   627
                            dstPtr += 2;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   628
                            srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   629
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   630
                    } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   631
                        for (y=__intVal(__INST(height)); y > 0; y--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   632
                            for (x=w; x > 0; x--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   633
                                unsigned r, g, b, v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   634
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   635
                                r = srcPtr[_redOffs] >> rShRed;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   636
                                g = srcPtr[_greenOffs] >> rShGreen;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   637
                                b = srcPtr[_blueOffs] >> rShBlue;
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   638
                                v = r << lShRed;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   639
                                v |= (g << lShGreen);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   640
                                v |= (b << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   641
# ifdef __MSBFIRST
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   642
                                ((short *)dstPtr)[0] = v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   643
# else /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   644
                                dstPtr[0] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   645
                                dstPtr[1] = (v) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   646
# endif /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   647
                                dstPtr += 2;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   648
                                srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   649
                            }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   650
                            dstPtr += p;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   651
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   652
                    }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   653
                }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   654
            }
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   655
%}.
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   656
        ] ifFalse:[
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   657
            "/
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   658
            "/ 32 or 8 bits/pixel ...
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   659
            "/
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   660
            (usedDeviceBitsPerPixel == 32) ifTrue:[
8000
62ea15884e2b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7922
diff changeset
   661
                "/ usedDevicePadding := 8.
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   662
                imageBits := ByteArray uninitializedNew:(width * height * 4).
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   663
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   664
                "/ now, walk over the image and compose 32bit values from the r/g/b triples
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   665
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   666
%{
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   667
                unsigned char *srcPtr = 0;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   668
                unsigned char *dstPtr = 0;
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   669
                int _redOffs = __intVal(redOffs);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   670
                int _greenOffs = __intVal(greenOffs);  
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   671
                int _blueOffs = __intVal(blueOffs);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   672
                // int _alphaOffs = __intVal(alphaOffs);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   673
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   674
                if (__isByteArrayLike(bytes)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   675
                    srcPtr = __ByteArrayInstPtr(bytes)->ba_element;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   676
                } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   677
                    if (__isExternalBytesLike(bytes)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   678
                        srcPtr = __externalBytesAddress(bytes);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   679
                    }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   680
                }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   681
                if (__isByteArray(imageBits)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   682
                    dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   683
                } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   684
                    if (__isExternalBytesLike(imageBits)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   685
                        dstPtr = __externalBytesAddress(imageBits);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   686
                    }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   687
                }
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   688
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   689
                if (__bothSmallInteger(__INST(height), __INST(width))
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   690
                 && __bothSmallInteger(rightShiftR, shiftRed)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   691
                 && __bothSmallInteger(rightShiftG, shiftGreen)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   692
                 && __bothSmallInteger(rightShiftB, shiftBlue)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   693
                 && srcPtr
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   694
                 && dstPtr) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   695
                    int rShRed = __intVal(rightShiftR),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   696
                        rShGreen = __intVal(rightShiftG),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   697
                        rShBlue = __intVal(rightShiftB),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   698
                        lShRed = __intVal(shiftRed),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   699
                        lShGreen = __intVal(shiftGreen),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   700
                        lShBlue = __intVal(shiftBlue);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   701
                    int x, y, w;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   702
                    
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   703
                    w = __intVal(__INST(width));
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   704
                    if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   705
                        for (y=__intVal(__INST(height)); y > 0; y--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   706
                            for (x=w; x > 0; x--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   707
                                unsigned v;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   708
                                
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   709
                                v = srcPtr[_redOffs] << lShRed;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   710
                                v |= (srcPtr[_greenOffs] << lShGreen);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   711
                                v |= (srcPtr[_blueOffs] << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   712
# ifdef __MSBFIRST
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   713
                                ((int *)dstPtr)[0] = v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   714
# else /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   715
                                dstPtr[0] = (v>>24) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   716
                                dstPtr[1] = (v>>16) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   717
                                dstPtr[2] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   718
                                dstPtr[3] = (v) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   719
# endif /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   720
                                dstPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   721
                                srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   722
                            }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   723
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   724
                    } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   725
                        for (y=__intVal(__INST(height)); y > 0; y--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   726
                            for (x=w; x > 0; x--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   727
                                unsigned r, g, b, v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   728
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   729
                                r = srcPtr[_redOffs] >> rShRed;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   730
                                g = srcPtr[_greenOffs] >> rShGreen;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   731
                                b = srcPtr[_blueOffs] >> rShBlue;
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   732
                                v = r << lShRed;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   733
                                v |= (g << lShGreen);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   734
                                v |= (b << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   735
# ifdef __MSBFIRST
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   736
                                ((int *)dstPtr)[0] = v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   737
# else /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   738
                                dstPtr[0] = (v>>24) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   739
                                dstPtr[1] = (v>>16) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   740
                                dstPtr[2] = (v>>8) & 0xFF;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   741
                                dstPtr[3] = (v) & 0xFF;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   742
# endif /* not MSB */
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   743
                                dstPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   744
                                srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   745
                            }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   746
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   747
                    }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   748
                }
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   749
%}.
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   750
            ] ifFalse:[
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   751
                "/
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   752
                "/ 8 bits/pixel ...
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   753
                "/
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   754
                (usedDeviceBitsPerPixel == 8) ifTrue:[
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   755
                    usedDevicePadding := 8.
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   756
                    imageBits := ByteArray uninitializedNew:(width * height).
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   757
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   758
                    "/ now, walk over the image and compose 8bit values from the r/g/b triples
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   759
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   760
%{
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   761
                    unsigned char *srcPtr = 0;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   762
                    unsigned char *dstPtr = 0;
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   763
                    int _redOffs = __intVal(redOffs);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   764
                    int _greenOffs = __intVal(greenOffs);  
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   765
                    int _blueOffs = __intVal(blueOffs);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   766
                    // int _alphaOffs = __intVal(alphaOffs);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   767
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   768
                    if (__isByteArrayLike(bytes)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   769
                        srcPtr = __ByteArrayInstPtr(bytes)->ba_element;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   770
                    } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   771
                        if (__isExternalBytesLike(bytes)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   772
                            srcPtr = __externalBytesAddress(bytes);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   773
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   774
                    }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   775
                    if (__isByteArray(imageBits)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   776
                        dstPtr = __ByteArrayInstPtr(imageBits)->ba_element;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   777
                    } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   778
                        if (__isExternalBytesLike(imageBits)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   779
                            dstPtr = __externalBytesAddress(imageBits);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   780
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   781
                    }
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   782
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   783
                    if (__bothSmallInteger(__INST(height), __INST(width))
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   784
                     && __bothSmallInteger(rightShiftR, shiftRed)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   785
                     && __bothSmallInteger(rightShiftG, shiftGreen)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   786
                     && __bothSmallInteger(rightShiftB, shiftBlue)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   787
                     && srcPtr
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   788
                     && dstPtr) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   789
                        int rShRed = __intVal(rightShiftR),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   790
                            rShGreen = __intVal(rightShiftG),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   791
                            rShBlue = __intVal(rightShiftB),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   792
                            lShRed = __intVal(shiftRed),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   793
                            lShGreen = __intVal(shiftGreen),
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   794
                            lShBlue = __intVal(shiftBlue);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   795
                        int x, y, w;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   796
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   797
                        w = __intVal(__INST(width));
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   798
                        if ((rShRed == 0) && (rShGreen == 0) && (rShBlue == 0)) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   799
                            for (y=__intVal(__INST(height)); y > 0; y--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   800
                                for (x=w; x > 0; x--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   801
                                    unsigned v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   802
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   803
                                    v = srcPtr[_redOffs] << lShRed;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   804
                                    v |= (srcPtr[_greenOffs] << lShGreen);
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   805
                                    v |= (srcPtr[_blueOffs] << lShBlue);
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   806
                                    dstPtr[0] = v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   807
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   808
                                    dstPtr += 1;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   809
                                    srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   810
                                }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   811
                            }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   812
                        } else {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   813
                            for (y=__intVal(__INST(height)); y > 0; y--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   814
                                for (x=w; x > 0; x--) {
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   815
                                    unsigned r, g, b, v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   816
8094
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   817
                                    r = srcPtr[_redOffs] >> rShRed;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   818
                                    g = srcPtr[_greenOffs] >> rShGreen;
72be8139d8e8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8089
diff changeset
   819
                                    b = srcPtr[_blueOffs] >> rShBlue;
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   820
                                    v = r << lShRed;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   821
                                    v |= (g << lShGreen);
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   822
                                    v |= (b << lShBlue);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   823
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   824
                                    dstPtr[0] = v;
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   825
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   826
                                    dstPtr += 1;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   827
                                    srcPtr += 4;
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   828
                                }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   829
                            }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   830
                        }
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   831
                    }
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   832
%}.
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   833
                ]
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   834
            ].
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   835
        ]
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   836
    ].
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   837
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   838
    imageBits isNil ifTrue:[
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   839
        'IMAGE: unimplemented trueColor depth in #rgbImageAsTrueColorFormOn: ' errorPrint.
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   840
        usedDeviceBitsPerPixel errorPrintCR.
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   841
        ^ self asMonochromeFormOn:aDevice
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   842
    ].
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   843
7497
62a3648614ff #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 7492
diff changeset
   844
    form := Form imageForm width:width height:height depth:usedDeviceDepth onDevice:aDevice.
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   845
    form isNil ifTrue:[
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   846
        'Depth32Image [warning]: display bitmap creation failed' errorPrintCR.
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   847
        ^ nil
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   848
    ].
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   849
    form initGC.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   850
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   851
    form
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   852
        copyBitsFrom:imageBits
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   853
        bitsPerPixel:usedDeviceBitsPerPixel
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   854
        depth:usedDeviceDepth
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   855
        padding:usedDevicePadding
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   856
        width:width height:height
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
   857
        x:0 y:0 toX:0 y:0.
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   858
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   859
    ^ form
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   860
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   861
    "Created: / 27-05-2007 / 16:54:19 / cg"
8114
4b012d4736b0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8094
diff changeset
   862
    "Modified: / 27-08-2017 / 21:06:49 / cg"
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   863
! !
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   864
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   865
!Depth32Image methodsFor:'image manipulations'!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   866
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   867
negative
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   868
    |bytes 
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   869
     index "{ Class: SmallInteger }"
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   870
     newImage newBytes nBytes r g b a
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   871
     alphaFirst|
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   872
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   873
    ((photometric ~~ #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   874
    and:[(photometric ~~ #rgba)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   875
    and:[(photometric ~~ #xrgb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   876
    and:[(photometric ~~ #rgbx)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   877
    and:[(photometric ~~ #rgb0)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   878
    and:[(photometric ~~ #'0rgb')]]]]]) ifTrue:[
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   879
        ^ super negative.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   880
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   881
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   882
    alphaFirst := (photometric == #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   883
                  or:[ (photometric == #xrgb) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   884
                  or:[ (photometric == #'0rgb') ]].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   885
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   886
    bytes := self bits.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   887
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   888
    newImage := self copy.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   889
    nBytes := bytes size.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   890
    newImage bits:(newBytes := ByteArray new:nBytes).
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   891
    index := 1.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   892
    [index < nBytes] whileTrue:[
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   893
        alphaFirst ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   894
            a := bytes at:index.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   895
            newBytes at:index put:a.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   896
            index := index + 1.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   897
        ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   898
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   899
        r := bytes at:index.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   900
        newBytes at:index put:(255-r).
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   901
        index := index + 1.
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   902
        
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   903
        g := bytes at:index.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   904
        newBytes at:index put:(255-g).
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   905
        index := index + 1.
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   906
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   907
        b := bytes at:index.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   908
        newBytes at:index put:(255-b).
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   909
        index := index + 1.
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   910
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   911
        alphaFirst ifFalse:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   912
            a := bytes at:index.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   913
            newBytes at:index put:a.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   914
            index := index + 1.
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
   915
        ]
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   916
    ].
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   917
    ^ newImage
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
   918
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   919
    "Modified (format): / 22-08-2017 / 17:13:38 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   920
! !
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
   921
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   922
!Depth32Image methodsFor:'initialization'!
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   923
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   924
initialize
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   925
    super initialize.
6066
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
   926
    samplesPerPixel := 4.
7819
1dd77ab4b48f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7514
diff changeset
   927
    bitsPerSample := #[8 8 8 8].
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   928
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   929
    "Created: / 27-05-2007 / 14:09:16 / cg"
7819
1dd77ab4b48f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7514
diff changeset
   930
    "Modified: / 30-01-2017 / 19:32:13 / stefan"
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   931
! !
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   932
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   933
!Depth32Image methodsFor:'magnification'!
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   934
8262
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   935
hardAntiAliasedMagnifiedBy:scaleArg
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   936
    "return a new image magnified by scalePoint, aPoint.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   937
     This interpolates pixels and is therefore much slower,
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   938
     but generates nicer looking magnifications."
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   939
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   940
    |scalePoint mX
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   941
     mY
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   942
     newWidth  "{ Class: SmallInteger }"
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   943
     newHeight "{ Class: SmallInteger }"
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   944
     w         "{ Class: SmallInteger }"
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   945
     h         "{ Class: SmallInteger }"
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   946
     newImage newBits bitsPerPixel newBytesPerRow newMask
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   947
     value
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   948
     srcRow pixelArray|
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   949
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   950
    scalePoint := scaleArg asPoint. 
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   951
    mX := scalePoint x.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   952
    mY := scalePoint y.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   953
    ((mX < 0) or:[mY < 0]) ifTrue:[^ nil].
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   954
    ((mX = 1) and:[mY = 1]) ifTrue:[^ self].
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   955
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   956
    newWidth := (width * mX) truncated.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   957
    newHeight := (height * mY) truncated.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   958
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   959
    bitsPerPixel := self depth.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   960
    newBytesPerRow := ((newWidth * bitsPerPixel) + 7) // 8.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   961
    newBits := ByteArray new: "uninitializedNew:" (newBytesPerRow * newHeight).
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   962
    newBits isNil ifTrue:[
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   963
        'Depth32Image [warning]: failed to allocate byteArray for image bits' errorPrintCR.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   964
        ^ nil
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   965
    ].
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   966
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   967
    mask notNil ifTrue:[
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   968
        newMask := (mask magnifiedBy:scalePoint)
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   969
    ].
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   970
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   971
    newImage := self species new.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   972
    newImage
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   973
        width:newWidth
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   974
        height:newHeight
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   975
        photometric:photometric
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   976
        samplesPerPixel:samplesPerPixel
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   977
        bitsPerSample:bitsPerSample
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   978
        colorMap:nil
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   979
        bits:newBits
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   980
        mask:newMask.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   981
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   982
    mY := mY asFloat.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   983
    mX := mX asFloat.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   984
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   985
%{
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   986
    REGISTER unsigned char *_dstP = __ByteArrayInstPtr(newBits)->ba_element;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   987
    unsigned char *_srcP = __ByteArrayInstPtr(__INST(bytes))->ba_element;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   988
    unsigned char *_srcRowP, *sP;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   989
    int _width4 = __intVal(__INST(width)) * 4;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   990
    int _oldW = __intVal(__INST(width)) - 1;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   991
    int _oldH = __intVal(__INST(height)) - 1;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   992
    int _w = __intVal(newWidth) - 1;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   993
    int _h = __intVal(newHeight) - 1;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   994
    int _row, _col;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   995
    double _mX = __floatVal(mX);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   996
    double _mY = __floatVal(mY);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   997
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   998
    for (_row = 0; _row <= _h; _row++) {
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
   999
        double _srcY;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1000
        double _dY;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1001
        int _sR;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1002
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1003
        _srcY = ((double)_row / _mY);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1004
        _sR = (int)_srcY;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1005
        _dY = _srcY - ((double)_sR);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1006
        _srcRowP = _srcP + (_width4 * _sR);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1007
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1008
        for (_col = 0; _col <= _w; _col++) {
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1009
            unsigned int rHere, gHere, bHere, aHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1010
            unsigned int rRight, gRight, bRight, aRight;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1011
            unsigned int rRightBelow, gRightBelow, bRightBelow, aRightBelow;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1012
            unsigned int rBelow, gBelow, bBelow, aBelow;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1013
            unsigned int _r, _g, _b, _a;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1014
            double wHere, wRight, wRightBelow, wBelow, sumW;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1015
            double _srcX;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1016
            double _dX;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1017
            int _sC;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1018
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1019
            _srcX = ((double)_col / _mX);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1020
            _sC = (int)_srcX;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1021
            _dX = _srcX - ((double)_sC);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1022
            sP = _srcRowP + (_sC * 4);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1023
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1024
            rHere = sP[0];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1025
            gHere = sP[1];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1026
            bHere = sP[2];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1027
            aHere = sP[3];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1028
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1029
            if (_sC < _oldW) {
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1030
                rRight = sP[0+4];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1031
                gRight = sP[0+5];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1032
                bRight = sP[0+6];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1033
                aRight = sP[0+7];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1034
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1035
                if (_sR < _oldH) {
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1036
                    rBelow = sP[0+_width4];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1037
                    gBelow = sP[1+_width4];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1038
                    bBelow = sP[2+_width4];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1039
                    aBelow = sP[3+_width4];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1040
                    rRightBelow = sP[4+_width4];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1041
                    gRightBelow = sP[5+_width4];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1042
                    bRightBelow = sP[6+_width4];
8264
a37a81b3942b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8262
diff changeset
  1043
                    aRightBelow = sP[7+_width4];
8262
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1044
                } else {
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1045
                    rRightBelow = rHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1046
                    gRightBelow = gHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1047
                    bRightBelow = bHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1048
                    aRightBelow = aHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1049
                    rBelow = rHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1050
                    gBelow = gHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1051
                    bBelow = bHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1052
                    aBelow = aHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1053
                }
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1054
            } else {
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1055
                rRight = rRightBelow = rHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1056
                gRight = gRightBelow = gHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1057
                bRight = bRightBelow = bHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1058
                aRight = aRightBelow = aHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1059
                if (_sR < _oldH) {
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1060
                    rBelow = sP[0+_width4];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1061
                    gBelow = sP[1+_width4];
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1062
                    bBelow = sP[2+_width4];
8264
a37a81b3942b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8262
diff changeset
  1063
                    aBelow = sP[3+_width4];
8262
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1064
                } else {
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1065
                    rBelow = rHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1066
                    gBelow = gHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1067
                    bBelow = bHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1068
                    aBelow = aHere;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1069
                }
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1070
            }
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1071
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1072
            wHere = (1.0 - _dX) * (1.0 - _dY);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1073
            wRight = _dX * (1.0 - _dY);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1074
            wBelow = _dY * (1.0 - _dX);
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1075
            wRightBelow = _dX * _dY;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1076
            sumW = wHere + wRight + wBelow + wRightBelow;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1077
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1078
            _r = ((rHere * wHere) + (rRight * wRight) + (rBelow * wBelow) + (rRightBelow * wRightBelow)) / sumW;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1079
            _g = ((gHere * wHere) + (gRight * wRight) + (gBelow * wBelow) + (gRightBelow * wRightBelow)) / sumW;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1080
            _b = ((bHere * wHere) + (bRight * wRight) + (bBelow * wBelow) + (bRightBelow * wRightBelow)) / sumW;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1081
            _a = ((aHere * wHere) + (aRight * wRight) + (aBelow * wBelow) + (aRightBelow * wRightBelow)) / sumW;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1082
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1083
            _dstP[0] = _r;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1084
            _dstP[1] = _g;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1085
            _dstP[2] = _b;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1086
            _dstP[3] = _a;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1087
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1088
            _dstP += 4;
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1089
        }
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1090
    }
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1091
%}.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1092
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1093
    ^ newImage
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1094
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1095
    "
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1096
     |i|
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1097
     i := Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif'.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1098
     i := Depth32Image fromImage:i.
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1099
     i hardAntiAliasedMagnifiedBy:2@2
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1100
    "
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1101
    "
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1102
     |i|
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1103
     i := Depth32Image width:3 height:3 fromArray:#[ 0 0 0 127   0 0 0 127  0 0 0 127
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1104
                                                     0 0 0 127  255 255 255 127  0 0 0 127
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1105
                                                     0 0 0 127   0 0 0 127  0 0 0 127].
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1106
     i hardAntiAliasedMagnifiedBy:8@8
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1107
    "
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1108
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1109
    "Created: / 02-06-1997 / 13:18:53 / cg"
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1110
    "Modified: / 30-08-2017 / 13:35:20 / cg"
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1111
!
a9845a7cad69 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8201
diff changeset
  1112
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1113
magnifyRowFrom:srcBytes offset:srcStart
6066
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1114
	  into:dstBytes offset:dstStart factor:mX
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1115
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1116
    "magnify a single pixel row - can only magnify by integer factors"
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1117
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1118
%{
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1119
    unsigned char *srcP, *dstP;
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1120
    int _mag;
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1121
    REGISTER int i;
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1122
    REGISTER unsigned char byte1, byte2, byte3, byte4;
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1123
    int _pixels;
6066
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1124
    OBJ w = __INST(width);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1125
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1126
    if (__bothSmallInteger(srcStart, dstStart)
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1127
     && __bothSmallInteger(w, mX)
5474
037b18c68ac9 __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5327
diff changeset
  1128
     && __isByteArrayLike(srcBytes) && __isByteArray(dstBytes)) {
6066
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1129
	_mag = __intVal(mX);
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1130
	srcP = __ByteArrayInstPtr(srcBytes)->ba_element - 1 + __intVal(srcStart);
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1131
	dstP = __ByteArrayInstPtr(dstBytes)->ba_element - 1 + __intVal(dstStart);
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1132
	_pixels = __intVal(w);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1133
6066
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1134
	while (_pixels--) {
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1135
	    byte1 = *srcP;
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1136
	    byte2 = *(srcP+1);
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1137
	    byte3 = *(srcP+2);
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1138
	    byte4 = *(srcP+3);
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1139
	    srcP += 4;
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1140
	    for (i=_mag; i>0; i--) {
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1141
		*dstP = byte1;
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1142
		*(dstP+1) = byte2;
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1143
		*(dstP+2) = byte3;
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1144
		*(dstP+3) = byte4;
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1145
		dstP += 4;
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1146
	    }
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1147
	}
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1148
	RETURN (self);
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1149
    }
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1150
%}.
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1151
    super
6066
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1152
	magnifyRowFrom:srcBytes offset:srcStart
62426e8110ae stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents: 5474
diff changeset
  1153
	into:dstBytes offset:dstStart factor:mX
4761
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1154
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1155
    "Created: / 28-05-2007 / 15:20:52 / cg"
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1156
! !
9672fbf6ad20 defaultPhotometric, magnification, conversion
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
  1157
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
!Depth32Image methodsFor:'queries'!
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1160
alphaBitsOf:pixel
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1161
    "given a pixel-value, return the alpha component as byteValue (0..255)"
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1162
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1163
    photometric == #argb ifTrue:[
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1164
        "/ value is: aarrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1165
        ^ (pixel bitShift:-24) bitAnd:16rFF.   
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1166
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1167
    (photometric == #rgb) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1168
        "/ value is: 00rrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1169
        ^ 0
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1170
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1171
    (photometric == #xrgb) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1172
        "/ value is: FFrrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1173
        ^ 255       
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1174
    ].
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1175
    photometric == #rgba ifTrue:[
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1176
        "/ value is: rrggbbaa
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1177
        ^ pixel bitAnd:16rFF           
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1178
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1179
    photometric == #rgb0 ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1180
        "/ value is: rrggbb00
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1181
        ^ 0           
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1182
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1183
    photometric == #rgbx ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1184
        "/ value is: rrggbbFF
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1185
        ^ 255           
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1186
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1187
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1188
    ^ super alphaBitsOf:pixel.
8002
d9f38365af4d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 8000
diff changeset
  1189
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1190
    "Modified: / 22-08-2017 / 17:18:44 / cg"
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1191
!
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1192
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1193
alphaComponentOf:pixel
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1194
    "given a pixel-value, return the alpha component in percent (0..100)"
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1195
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1196
    ^ (self alphaBitsOf:pixel) * (100.0 / 255.0)
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1197
!
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1198
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1199
alphaMaskForPixelValue
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1200
    "return the mask used with translation from pixelValues to alphaBits.
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1201
     Determines the number of bits of alpha"
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1202
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1203
    ^ 16rFF
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1204
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1205
    "Modified (comment): / 21-02-2017 / 16:37:31 / cg"
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1206
!
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1207
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1208
alphaShiftForPixelValue
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1209
    "return the shift amount used with translation from pixelValues to alphaBits.
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1210
     That is the number of bits to shift the alpha value into the pixel value."
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1211
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1212
    ((photometric == #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1213
    or:[ (photometric == #rgb) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1214
    or:[ (photometric == #xrgb) ]])
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1215
     ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1216
        "/ aarrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1217
        ^ -24.    
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1218
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1219
    ((photometric == #rgba) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1220
    or:[ (photometric == #rgbx) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1221
    or:[ (photometric == #rgb0)]]) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1222
        "/ rrggbbaa
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1223
        ^ 0.    
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1224
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1225
    ^ super alphaShiftForPixelValue.
7896
1d6d23765472 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7819
diff changeset
  1226
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1227
    "Modified: / 22-08-2017 / 17:19:36 / cg"
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1228
!
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1229
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1230
bitsPerPixel
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1231
    "return the number of bits per pixel"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1232
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1233
    ^ 32
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1234
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1235
    "Created: 24.4.1997 / 19:00:28 / cg"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1236
!
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
bitsPerRow
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
    "return the number of bits in one scanline of the image"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
3866
c01473a90934 eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents: 3263
diff changeset
  1241
    ^ width * 32
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
    "Created: 24.4.1997 / 19:00:28 / cg"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
!
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1246
bitsPerSample
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1247
    "return the number of bits per sample.
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1248
     The return value is an array of bits-per-plane."
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1249
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1250
    bitsPerSample notNil ifTrue:[^ bitsPerSample].
7819
1dd77ab4b48f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7514
diff changeset
  1251
    ^ #[8 8 8 8]
1dd77ab4b48f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7514
diff changeset
  1252
1dd77ab4b48f #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7514
diff changeset
  1253
    "Modified: / 30-01-2017 / 19:23:31 / stefan"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1254
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1255
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1256
blueBitsOf:pixel
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1257
    "given a pixel-value, return the blue component as byteValue (0..255)"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1258
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1259
    ((photometric == #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1260
    or:[ (photometric == #rgb) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1261
    or:[ (photometric == #xrgb) ]])
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1262
     ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1263
        "/ aarrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1264
        ^ pixel bitAnd:16rFF.    
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1265
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1266
    ((photometric == #rgba) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1267
    or:[ (photometric == #rgbx) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1268
    or:[ (photometric == #rgb0)]]) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1269
        "/ rrggbbaa
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1270
        ^ (pixel bitShift:-8) bitAnd:16rFF.    
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1271
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1272
    ^ super blueBitsOf:pixel.
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1273
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
  1274
    "Modified: / 22-08-2017 / 18:23:41 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1275
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1276
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1277
blueComponentOf:pixel
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1278
    "given a pixel-value, return the blue component in percent (0..100)"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1279
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1280
    ^ (self blueBitsOf:pixel) * (100.0 / 255.0)
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1281
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1282
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1283
blueMaskForPixelValue
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1284
    "return the mask used with translation from pixelValues to blueBits"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1285
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1286
    ^ 16rFF
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1287
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1288
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1289
blueShiftForPixelValue
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1290
    "return the shift amount used with translation from pixelValues to blueBits"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1291
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1292
    ((photometric == #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1293
    or:[ (photometric == #rgb) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1294
    or:[ (photometric == #xrgb) ]])
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1295
     ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1296
        "/ aarrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1297
        ^ 0.    
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1298
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1299
    ((photometric == #rgba) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1300
    or:[ (photometric == #rgbx) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1301
    or:[ (photometric == #rgb0)]]) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1302
        "/ rrggbbaa
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1303
        ^ -8
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1304
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1305
    ^ super blueShiftForPixelValue
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1306
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1307
    "Modified: / 22-08-2017 / 17:19:55 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1308
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1309
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1310
bytesPerRow
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1311
    "return the number of bytes in one scanline of the image"
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1313
    ^ width * 4.
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1314
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
    "Created: 24.4.1997 / 19:00:28 / cg"
5327
cc9e8a99b6d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5324
diff changeset
  1316
!
cc9e8a99b6d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5324
diff changeset
  1317
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1318
greenBitsOf:pixel
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1319
    "given a pixel-value, return the green component as byteValue (0..255)"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1320
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1321
    ((photometric == #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1322
    or:[ (photometric == #rgb) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1323
    or:[ (photometric == #xrgb) ]])
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1324
     ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1325
        "/ aarrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1326
        ^ (pixel bitShift:-8) bitAnd:16rFF.    
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1327
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1328
    ((photometric == #rgba) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1329
    or:[ (photometric == #rgbx) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1330
    or:[ (photometric == #rgb0)]]) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1331
        "/ rrggbbaa
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1332
        ^ (pixel bitShift:-16) bitAnd:16rFF.    
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1333
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1334
    ^ super greenBitsOf:pixel.
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1335
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1336
    "Modified: / 22-08-2017 / 18:23:41 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1337
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1338
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1339
greenComponentOf:pixel
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1340
    "given a pixel-value, return the green component in percent (0..100)"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1341
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1342
    ^ (self greenBitsOf:pixel) * (100.0 / 255.0)
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1343
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1344
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1345
greenMaskForPixelValue
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1346
    "return the mask used with translation from pixelValues to redBits"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1347
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1348
    ^ 16rFF
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1349
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1350
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1351
greenShiftForPixelValue
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1352
    "return the shift amount used with translation from pixelValues to greenBits"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1353
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1354
    ((photometric == #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1355
    or:[ (photometric == #rgb) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1356
    or:[ (photometric == #xrgb) ]])
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1357
     ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1358
        "/ aarrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1359
        ^ -8    
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1360
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1361
    ((photometric == #rgba) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1362
    or:[ (photometric == #rgbx) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1363
    or:[ (photometric == #rgb0)]]) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1364
        "/ rrggbbaa
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1365
        ^ -16.    
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1366
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1367
    ^ super greenShiftForPixelValue.
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1368
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1369
5327
cc9e8a99b6d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5324
diff changeset
  1370
hasAlphaChannel
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1371
    "could be #rgb in 32 bits..."
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1372
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1373
    ^ (photometric == #argb) or:[photometric == #rgba]
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1374
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1375
    "Modified: / 21-02-2017 / 15:00:17 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1376
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1377
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1378
numAlphaBits
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1379
    photometric == #argb ifTrue:[
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1380
        ^ 8.
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1381
    ].
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1382
    photometric == #rgba ifTrue:[
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1383
        ^ 8.
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1384
    ].
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1385
    ^ 0
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1386
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1387
    "Created: / 22-08-2017 / 17:38:59 / cg"
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1388
!
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1389
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1390
numBlueBits
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1391
    ^ 8
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1392
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1393
    "Created: / 22-08-2017 / 17:38:31 / cg"
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1394
!
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1395
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1396
numGreenBits
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1397
    ^ 8
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1398
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1399
    "Created: / 22-08-2017 / 17:38:28 / cg"
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1400
!
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1401
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1402
numRedBits
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1403
    ^ 8
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1404
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1405
    "Created: / 22-08-2017 / 17:38:25 / cg"
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1406
!
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1407
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1408
redBitsOf:pixel
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1409
    "given a pixel-value, return the red component as byteValue (0..255)"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1410
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1411
    ((photometric == #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1412
    or:[ (photometric == #rgb) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1413
    or:[ (photometric == #xrgb) ]])
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1414
     ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1415
        "/ aarrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1416
        ^ (pixel bitShift:-16) bitAnd:16rFF.    
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1417
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1418
    ((photometric == #rgba) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1419
    or:[ (photometric == #rgbx) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1420
    or:[ (photometric == #rgb0)]]) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1421
        "/ rrggbbaa
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1422
        ^ (pixel bitShift:-24) bitAnd:16rFF.    
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1423
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1424
    ^ super redBitsOf:pixel.
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1425
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1426
    "Modified: / 22-08-2017 / 18:23:41 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1427
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1428
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1429
redComponentOf:pixel
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1430
    "given a pixel-value, return the red component in percent (0..100)"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1431
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1432
    ^ (self redBitsOf:pixel) * (100.0 / 255.0)
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1433
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1434
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1435
redMaskForPixelValue
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1436
    "return the mask used with translation from pixelValues to redBits"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1437
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1438
    ^ 16rFF
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1439
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1440
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1441
redShiftForPixelValue
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1442
    "return the shift amount used with translation from pixelValues to redBits"
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1443
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1444
    ((photometric == #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1445
    or:[ (photometric == #rgb) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1446
    or:[ (photometric == #xrgb) ]])
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1447
     ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1448
        "/ aarrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1449
        ^ -16    
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1450
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1451
    ((photometric == #rgba) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1452
    or:[ (photometric == #rgbx) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1453
    or:[ (photometric == #rgb0)]]) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1454
        "/ rrggbbaa
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1455
        ^ -24.    
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1456
    ].
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1457
    ^ super redShiftForPixelValue.
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1458
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1459
    "Modified: / 22-08-2017 / 18:23:41 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1460
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1461
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1462
rgbFromValue:pixelValue
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1463
    "given a pixel value, return the corresponding 24bit rgbValue (rrggbb, red is MSB)."
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1464
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1465
    ((photometric == #argb)
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1466
    or:[ (photometric == #rgb) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1467
    or:[ (photometric == #xrgb) ]])
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1468
     ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1469
        "/ aarrggbb
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1470
        ^ pixelValue bitAnd:16rFFFFFF   
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1471
    ].
8327
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1472
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1473
    ((photometric == #rgba) 
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1474
    or:[ photometric == #rgbx
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1475
    or:[ photometric == #rgb0]]) ifTrue:[
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1476
        "/ rrggbbaa
98509411b62e #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 8264
diff changeset
  1477
        ^ (pixelValue rightShift:8) bitAnd:16rFFFFFF       
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1478
    ].
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
  1479
    ^ super rgbFromValue:pixelValue.
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1480
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
  1481
    "Modified: / 22-08-2017 / 18:32:22 / cg"
6841
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1482
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1483
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1484
samplesPerPixel
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1485
    "return the number of samples per pixel in the image."
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1486
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1487
    samplesPerPixel notNil ifTrue:[^ samplesPerPixel].
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1488
    ^ 4
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1489
!
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1490
3f4935787091 class: Depth32Image
Stefan Vogel <sv@exept.de>
parents: 6302
diff changeset
  1491
valueFromRedBits:redBits greenBits:greenBits blueBits:blueBits
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
  1492
    (photometric == #rgba) ifTrue:[
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1493
        "/ alpha in low byte
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1494
        ^ (((((redBits bitShift:8) bitOr:greenBits) bitShift:8) bitOr:blueBits) bitShift:8) bitOr:16rFF
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1495
    ].
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1496
    (photometric == #argb) ifTrue:[
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1497
        "/ alpha in high byte
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1498
        ^ (((((redBits bitShift:8) bitOr:greenBits) bitShift:8) bitOr:blueBits)) bitOr:16rFF000000
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1499
    ].
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1500
    (photometric == #rgb) ifTrue:[
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
  1501
        "/ no alpha
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
  1502
        ^ (((redBits bitShift:8) bitOr:greenBits) bitShift:8) bitOr:blueBits
8085
ba867f680fde #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
  1503
    ].
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
  1504
    ^ super valueFromRedBits:redBits greenBits:greenBits blueBits:blueBits.
7922
800a52cd955b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 7917
diff changeset
  1505
8089
9a9ae8e56007 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 8085
diff changeset
  1506
    "Modified: / 22-08-2017 / 18:34:30 / cg"
8166
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1507
!
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1508
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1509
valueFromRedBits:redBits greenBits:greenBits blueBits:blueBits alphaBits:alphaBits
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1510
    (photometric == #rgba) ifTrue:[
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1511
        "/ alpha in low byte
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1512
        ^ (((((redBits bitShift:8) bitOr:greenBits) bitShift:8) bitOr:blueBits) bitShift:8) bitOr:alphaBits
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1513
    ].
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1514
    (photometric == #argb) ifTrue:[
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1515
        "/ alpha in high byte
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1516
        ^ (((((redBits bitShift:8) bitOr:greenBits) bitShift:8) bitOr:blueBits)) bitOr:(alphaBits bitShift:24)
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1517
    ].
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1518
    (photometric == #rgb) ifTrue:[
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1519
        "/ no alpha
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1520
        ^ (((redBits bitShift:8) bitOr:greenBits) bitShift:8) bitOr:blueBits
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1521
    ].
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1522
    ^ super valueFromRedBits:redBits greenBits:greenBits blueBits:blueBits.
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1523
71ddc0db4c31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 8114
diff changeset
  1524
    "Created: / 05-09-2017 / 14:31:38 / cg"
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1525
! !
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1526
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1527
!Depth32Image class methodsFor:'documentation'!
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1528
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1529
version
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1530
    ^ '$Header$'
5474
037b18c68ac9 __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5327
diff changeset
  1531
!
037b18c68ac9 __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5327
diff changeset
  1532
037b18c68ac9 __isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents: 5327
diff changeset
  1533
version_CVS
7122
100dd2139178 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 6846
diff changeset
  1534
    ^ '$Header$'
1663
a2be19b14666 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1535
! !
6302
d393dae43c28 pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 6066
diff changeset
  1536