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