diff -r 4396fb652bd7 -r 50e94e3563fa ImageEditor.st --- a/ImageEditor.st Wed Sep 13 18:12:32 2017 +0200 +++ b/ImageEditor.st Thu Sep 14 15:44:58 2017 +0200 @@ -1943,83 +1943,84 @@ ^ - #(FullSpec - name: dialogSpecForNewImage - window: - (WindowSpec - label: 'New Image' - name: 'New Image' - min: (Point 10 10) - bounds: (Rectangle 0 0 301 119) - ) - component: - (SpecCollection - collection: ( - (ViewSpec - name: 'View' - layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -35 1.0) - level: 1 - component: - (SpecCollection - collection: ( - (FramedBoxSpec - label: 'Size' - name: 'framedBox1' - layout: (LayoutFrame 1 0.0 7 0.0 0 0.4 76 0) - style: (FontDescription helvetica medium roman 12) - labelPosition: topLeft - translateLabel: true - component: - (SpecCollection - collection: ( - (ComboBoxSpec - name: 'defaultSizesComboBox' - layout: (LayoutFrame 0 0.0 10 0.0 0 1 35 0.0) - model: selectionOfSize - type: string - acceptOnPointerLeave: false - comboList: listOfDefaultSizes - isFilenameBox: false - ) + #(FullSpec + name: dialogSpecForNewImage + window: + (WindowSpec + label: 'New Image' + name: 'New Image' + min: (Point 10 10) + bounds: (Rectangle 0 0 301 119) + ) + component: + (SpecCollection + collection: ( + (ViewSpec + name: 'View' + layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -35 1.0) + level: 1 + component: + (SpecCollection + collection: ( + (FramedBoxSpec + label: 'Size' + name: 'framedBox1' + layout: (LayoutFrame 1 0.0 7 0.0 0 0.40000000000000002 76 0) + style: (FontDescription helvetica medium roman 12) + labelPosition: topLeft + translateLabel: true + component: + (SpecCollection + collection: ( + (ComboBoxSpec + name: 'defaultSizesComboBox' + layout: (LayoutFrame 0 0.0 10 0.0 0 1 35 0.0) + model: selectionOfSize + type: string + acceptOnPointerLeave: false + comboList: listOfDefaultSizes + isFilenameBox: false ) - - ) - ) - (FramedBoxSpec - label: 'Color Map' - name: 'framedBox2' - layout: (LayoutFrame 0 0.4 7 0.0 -1 1.0 76 0) - style: (FontDescription helvetica medium roman 12) - labelPosition: topLeft - translateLabel: true - component: - (SpecCollection - collection: ( - (ComboListSpec - name: 'colorMapComboBox' - layout: (LayoutFrame 0 0.0 10 0.0 0 1 35 0.0) - model: selectionOfColorMap - comboList: listOfColorMaps - useIndex: false - hidePullDownMenuButton: false - ) + ) + + ) + ) + (FramedBoxSpec + label: 'Color Map' + name: 'framedBox2' + layout: (LayoutFrame 0 0.40000000000000002 7 0.0 -1 1.0 76 0) + style: (FontDescription helvetica medium roman 12) + labelPosition: topLeft + translateLabel: true + component: + (SpecCollection + collection: ( + (ComboListSpec + name: 'colorMapComboBox' + layout: (LayoutFrame 0 0.0 10 0.0 0 1 35 0.0) + model: selectionOfColorMap + comboList: listOfColorMaps + useIndex: false + hidePullDownMenuButton: false ) - - ) - ) + ) + + ) ) - - ) - ) - (UISubSpecification - name: 'windowSpecForCommitWithoutChannels' - layout: (LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1.0) - minorKey: windowSpecForCommitWithoutChannels - ) + ) + + ) ) - - ) - ) + (UISubSpecification + name: 'windowSpecForCommitWithoutChannels' + layout: (LayoutFrame 2 0.0 -37 1 -2 1.0 -2 1.0) + minorKey: windowSpecForCommitWithoutChannels + keepSpaceForOSXResizeHandleH: true + ) + ) + + ) + ) ! floodFillToleranceSpec @@ -8714,7 +8715,7 @@ doNewImage "opens a dialog with choices of size and color map for creating a new image" - |dialogAspects width height cMapString cMapMode cMap imageClass image szString defaultSize ext| + |dialogAspects width height cMapString cMapMode cMap imageClass image szString defaultSize ext depth| self checkModified ifFalse:[ ^ self ]. @@ -8745,23 +8746,35 @@ cMapString := (dialogAspects at:#selectionOfColorMap) value. cMapMode := self class namesOfColorMaps keyAtEqualValue:cMapString. cMap := self class listOfColorMaps at:cMapMode. - imageClass := Image implementorForDepth:(cMap size highBit-1). + depth := (cMapMode startsWith:'depth') + ifTrue:[ Integer readFrom:(cMapMode copyFrom:'depth' size + 1) ] + ifFalse:[ + (cMapMode startsWith:'masked') + ifTrue:[ Integer readFrom:(cMapMode copyFrom:'masked' size + 1) ] + ifFalse:[ cMap size highBit-1 ]]. + imageClass := Image implementorForDepth:depth. image := imageClass width: width height: height. image bits:(ByteArray new:(image bytesPerRow*height)). LastSizeString := szString. LastColormapMode := cMapString. - (cMapMode startsWith: 'mask') ifTrue:[ + (cMapMode startsWith:'mask') ifTrue:[ image mask: (ImageMask width: width height: height depth: 1 fromArray: (ByteArray new: width*height)). ]. - image colorMap: cMap. + depth == 32 ifTrue:[ + image photometric:#rgba + ] ifFalse:[ + image colorMap: cMap. + ]. (imageEditView image: image) notNil ifTrue:[ self updateListOfColorsAndColormapMode. self updateLabelsAndHistory. ]. image fillRectangleX:0 y:0 width:width height:height with:Color white. ] + + "Modified: / 13-09-2017 / 23:57:52 / cg" ! doNewImageEditor