ColorForm with transparency not working properly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

ColorForm with transparency not working properly

Christoph Thiede

Hi all,


try out this:


m := Morph new color: (Color red alpha: 0.5).
m openInHand.
m imageForm openAsMorph.

Output:


And for completeness' sake, "m imageForm asMorph imageForm openAsMorph" appears just a bit darker again.


I traced the issue down to two methods: For the regular Morph, FormCanvas >> #setFillColor:, and for the ImageMorph, Canvas >> #translucentImage:at:sourceRect:. In both methods, at the end, the rule Form blend is used to draw the image. If I change it to Form over, the colors are the same and the issue seems to be fixed.

But unfortunately, I could not find any documentation about the different Form rules such as #blend, #over, #paint etc. Can you give me some pointers?


Also, I noted the comment in #translucentImage:at:sourceRect: which states:


"Draw a translucent image using the best available way of representing translucency.
Note: This will be fixed in the future."

Which workaround is this comment referring to?


Looking forward to your help! :-)


Best,

Christoph



Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: ColorForm with transparency not working properly

Stéphane Rollandin
> But unfortunately, I could not find any documentation about the
> different Form rules such as #blend, #over, #paint etc. Can you give me
> some pointers?
Related thread:
http://forum.world.st/ImageForm-color-with-alpha-td5090574.html

Stef

Reply | Threaded
Open this post in threaded view
|

Re: ColorForm with transparency not working properly

Christoph Thiede

Thanks for the pointer, Stef. I think we really need some kind of documentation of the form rules to decide whether we can apply Marcel's solution. Did anyone ever read something about it?


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Stéphane Rollandin <[hidden email]>
Gesendet: Samstag, 19. September 2020 22:34:21
An: [hidden email]
Betreff: Re: [squeak-dev] ColorForm with transparency not working properly
 
> But unfortunately, I could not find any documentation about the
> different Form rules such as #blend, #over, #paint etc. Can you give me
> some pointers?
Related thread:
http://forum.world.st/ImageForm-color-with-alpha-td5090574.html

Stef



Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: ColorForm with transparency not working properly

Karl Ramberg
It is this code that apply the blendAlphaScaled.

BalloonEngine>>bitBlt: aBitBlt
| destWidth |
bitBlt := aBitBlt.
bitBlt isNil ifTrue:[^self].
destWidth := bitBlt destForm width.
destWidth > span size ifTrue:[span := Bitmap new: destWidth].
self class primitiveSetBitBltPlugin: bitBlt getPluginName.
self clipRect: bitBlt clipRect.
bitBlt
sourceForm: (Form extent: span size @ 1 depth: 32 bits: span);
sourceRect: (0@0 extent: 1@span size);
colorMap: (Color colorMapIfNeededFrom: 32 to: bitBlt destForm depth);
combinationRule: (bitBlt destForm depth >= 8 ifTrue:[34" blendAlphaScaled "] ifFalse:[Form paint]).

Best,
Karl

On Mon, Sep 21, 2020 at 9:31 PM Thiede, Christoph <[hidden email]> wrote:

Thanks for the pointer, Stef. I think we really need some kind of documentation of the form rules to decide whether we can apply Marcel's solution. Did anyone ever read something about it?


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Stéphane Rollandin <[hidden email]>
Gesendet: Samstag, 19. September 2020 22:34:21
An: [hidden email]
Betreff: Re: [squeak-dev] ColorForm with transparency not working properly
 
> But unfortunately, I could not find any documentation about the
> different Form rules such as #blend, #over, #paint etc. Can you give me
> some pointers?
Related thread:
http://forum.world.st/ImageForm-color-with-alpha-td5090574.html

Stef




Reply | Threaded
Open this post in threaded view
|

Re: ColorForm with transparency not working properly

Karl Ramberg
See also mail from Juan Vuletich in vm-dev list:"Proposal for new BitBlt rules (#505)" which has fixes for alpha blending

Best,
Karl



On Mon, Sep 21, 2020 at 9:44 PM karl ramberg <[hidden email]> wrote:
It is this code that apply the blendAlphaScaled.

BalloonEngine>>bitBlt: aBitBlt
| destWidth |
bitBlt := aBitBlt.
bitBlt isNil ifTrue:[^self].
destWidth := bitBlt destForm width.
destWidth > span size ifTrue:[span := Bitmap new: destWidth].
self class primitiveSetBitBltPlugin: bitBlt getPluginName.
self clipRect: bitBlt clipRect.
bitBlt
sourceForm: (Form extent: span size @ 1 depth: 32 bits: span);
sourceRect: (0@0 extent: 1@span size);
colorMap: (Color colorMapIfNeededFrom: 32 to: bitBlt destForm depth);
combinationRule: (bitBlt destForm depth >= 8 ifTrue:[34" blendAlphaScaled "] ifFalse:[Form paint]).

Best,
Karl

On Mon, Sep 21, 2020 at 9:31 PM Thiede, Christoph <[hidden email]> wrote:

Thanks for the pointer, Stef. I think we really need some kind of documentation of the form rules to decide whether we can apply Marcel's solution. Did anyone ever read something about it?


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Stéphane Rollandin <[hidden email]>
Gesendet: Samstag, 19. September 2020 22:34:21
An: [hidden email]
Betreff: Re: [squeak-dev] ColorForm with transparency not working properly
 
> But unfortunately, I could not find any documentation about the
> different Form rules such as #blend, #over, #paint etc. Can you give me
> some pointers?
Related thread:
http://forum.world.st/ImageForm-color-with-alpha-td5090574.html

Stef




Reply | Threaded
Open this post in threaded view
|

Re: ColorForm with transparency not working properly

Karl Ramberg
In reply to this post by Christoph Thiede
Class comment for VMMaker-Interpreter/BitBltSimulation

 has some information. This information is not in the image currently.


This class implements BitBlt, much as specified in the Blue Book spec. Performance has been enhanced through the use of pointer variables such as sourceIndex and destIndex, and by separating several special cases of the inner loop. Operation has been extended to color, with support for 1, 2, 4, 8, 16, and 32-bit pixel sizes. Conversion between different pixel sizes is facilitated by accepting an optional color map. In addition to the original 16 combination rules, this BitBlt supports 16 fail (for old paint mode) 17 fail (for old mask mode) 18 sourceWord + destinationWord 19 sourceWord - destinationWord 20 rgbAdd: sourceWord with: destinationWord 21 rgbSub: sourceWord with: destinationWord 22 OLDrgbDiff: sourceWord with: destinationWord 23 OLDtallyIntoMap: destinationWord -- old vers doesn't clip to bit boundary 24 alphaBlend: sourceWord with: destinationWord 25 pixPaint: sourceWord with: destinationWord 26 pixMask: sourceWord with: destinationWord 27 rgbMax: sourceWord with: destinationWord 28 rgbMin: sourceWord with: destinationWord 29 rgbMin: sourceWord bitInvert32 with: destinationWord 30 alphaBlendConst: sourceWord with: destinationWord -- alpha passed as an arg 31 alphaPaintConst: sourceWord with: destinationWord -- alpha passed as an arg 32 rgbDiff: sourceWord with: destinationWord 33 tallyIntoMap: destinationWord 34 alphaBlendScaled: sourceWord with: destinationWord 35 alphaBlendScaled: sourceWord with: "unused here - only used by FXBlt" 36 alphaBlendScaled: sourceWord with: "unused here - only used by FXBlt" 37 rgbMul: sourceWord with: destinationWord 38 pixSwap: sourceWord with: destinationWord 39 pixClear: sourceWord with: destinationWord 40 fixAlpha: sourceWord with: destinationWord 41 rgbComponentAlpha: sourceWord with: destinationWord This implementation has also been fitted with an experimental "warp drive" that allows abritrary scaling and rotation (and even limited affine deformations) with all BitBlt storage modes supported. To add a new rule to BitBlt... 1. add the new rule method or methods in the category 'combination rules' of BBSim 2. describe it in the class comment of BBSim and in the class comment for BitBlt 3. add refs to initializeRuleTable in proper positions 4. add refs to initBBOpTable, following the pattern

On Mon, Sep 21, 2020 at 9:31 PM Thiede, Christoph <[hidden email]> wrote:

Thanks for the pointer, Stef. I think we really need some kind of documentation of the form rules to decide whether we can apply Marcel's solution. Did anyone ever read something about it?


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Stéphane Rollandin <[hidden email]>
Gesendet: Samstag, 19. September 2020 22:34:21
An: [hidden email]
Betreff: Re: [squeak-dev] ColorForm with transparency not working properly
 
> But unfortunately, I could not find any documentation about the
> different Form rules such as #blend, #over, #paint etc. Can you give me
> some pointers?
Related thread:
http://forum.world.st/ImageForm-color-with-alpha-td5090574.html

Stef




Reply | Threaded
Open this post in threaded view
|

Re: ColorForm with transparency not working properly

Christoph Thiede
Thanks, Karl.

Still, I do not see what the combination rules are good for. For example, my
image does not implement #alphaBlend:with:.

Here is another request for some documentation of the combination rules:
https://github.com/MrModder/Autocompletion/issues/36

Best,
Christoph



--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html

Carpe Squeak!