Le 21/11/2013 21:27, Hilaire Fernandes a écrit :
> Le 21/11/2013 08:21, Stéphane Ducasse a écrit :
>>
>> On Nov 20, 2013, at 4:54 PM, Hilaire Fernandes <[email protected]> 
>> wrote:
>>
>>> Hello,
>>>
>>> In Pharo 2.0 (true in 1.4 as well), it looks PNG bitmap are wrongly
>>> rotated or scaled when they contain alpha transparency.
>>>
>>> In the example bellow with the joined bitmap, the alpha gray color are
>>> rendered darker when the imagemorph is scaled or rotated.
>>>
>>> Sqeak does not suffer this problem
>>
>> hilaire may be you should have a look at the changes made in the graphics 
>> package
> 
> I took at look on the list, did not find anything yet
> 


Oh, look like an old fix can partially make it

http://forum.world.st/ENH-Translucent-images-in-8-and-16-bit-screen-resolution-tp58371p58373.html

Joined .cs of this changes

I don't understand this code, and I don't know its consequences on the
all system. So someone should review it.


Hilaire


> Hilaire
> 
>> of squeak to identify the change.
>> We should have more tests.
>>
>> Stef
>>>
>>>
>>> | dir morph transform form|
>>> dir := FileSystem disk workingDirectory parent.
>>> morph := (ImageReadWriter formFromFileNamed: (dir / 'bubble.png')
>>> fullName) asMorph.
>>> transform := TransformationMorph new asFlexOf: morph.
>>> transform smoothingOn ; angle: Float pi / 3; scale: 1.
>>> transform openInWorld
>>>
>>>
>>> Thanks
>>>
>>> Hilaire
>>>
>>>
>>> -- 
>>> Dr. Geo http://drgeo.eu
>>> <bubble.png>
>>
>>
>>
> 
> 


-- 
Dr. Geo http://drgeo.eu
'From Pharo2.0 of 7 March 2013 [Latest update: #20628] on 21 November 2013 at 10:25:13 pm'!

!Canvas methodsFor: 'drawing-images' stamp: 'HilaireFernandes 11/21/2013 22:14'!
translucentImage: aForm at: aPoint sourceRect: sourceRect
	"Draw a translucent image using the best available way of representing translucency.
	Note: This will be fixed in the future."
        | multipliedForm | 
        self shadowColor ifNotNil:[ 
                ^self stencil: aForm at: aPoint sourceRect: sourceRect color: self shadowColor]. 
        ((self depth < 32 and:[aForm depth = 32]) and:[self depth > 4]) 
                ifTrue:[ 
    "Convert aForm to pre-multiplied" 
    multipliedForm := Form extent: aForm extent depth: 32. 
    aForm displayOn: multipliedForm at: 0@0 rule: Form blend. 
    ^self image: multipliedForm at: aPoint sourceRect: sourceRect rule: 34]. 
        (self depth < 32 or:[aForm isTranslucent not]) 
                ifTrue:[^self paintImage: aForm at: aPoint sourceRect: sourceRect]. 
        self image: aForm 
                at: aPoint 
                sourceRect: sourceRect 
                rule: Form blend! !


!FormCanvas methodsFor: 'drawing-support' stamp: 'HilaireFernandes 11/21/2013 22:17'!
transformBy: aDisplayTransform clippingTo: aClipRect during: aBlock	 smoothing: cellSize

        "Note: This method has been originally copied from TransformationMorph." 
        | innerRect patchRect sourceQuad warp start subCanvas | 
        (aDisplayTransform isPureTranslation) ifTrue:[ 
                ^aBlock value: (self copyOffset: aDisplayTransform offset negated truncated 
                                                        clipRect: aClipRect) 
        ]. 
        "Prepare an appropriate warp from patch to innerRect" 
        innerRect := aClipRect. 
        patchRect := (aDisplayTransform globalBoundsToLocal: innerRect) truncated. 
        sourceQuad := (aDisplayTransform sourceQuadFor: innerRect) 
                                        collect: [:p | p - patchRect topLeft]. 
        warp := self warpFrom: sourceQuad toRect: innerRect. 
        warp cellSize: cellSize. 

        "Render the submorphs visible in the clipping rectangle, as patchForm" 
        start := (self depth = 1 and: [self isShadowDrawing not]) 
                "If this is true B&W, then we need a first pass for erasure." 
                ifTrue: [1] ifFalse: [2]. 
        start to: 2 do: 
                [:i | "If i=1 we first make a shadow and erase it for opaque whites in B&W" 
                subCanvas := self class extent: patchRect extent depth: self depth. 
                i=1	ifTrue: [subCanvas shadowColor: Color black. 
                                        warp combinationRule: Form erase] 
                        ifFalse: [self isShadowDrawing ifTrue: 
                                        [subCanvas shadowColor: self shadowColor]. 
                                        (self depth = 32) ifTrue:[warp combinationRule: 34] 
                                        ifFalse:[warp combinationRule: Form paint]]. 
                subCanvas translateBy: patchRect topLeft negated 
                        during:[:offsetCanvas| aBlock value: offsetCanvas]. 
                warp sourceForm: subCanvas form; warpBits. 
                warp sourceForm: nil.  subCanvas := nil "release space for next loop"] ! !

Reply via email to