[squeak-dev] Re: [Vm-dev] Balloon engine and bitmap fills: any clues
why it ignores an alpha channel of bitmap?
Igor Stasenko
siguctua at gmail.com
Thu Apr 21 17:44:39 UTC 2011
On 21 April 2011 19:17, Andreas Raab <andreas.raab at gmx.de> wrote:
>
> Hi -
>
> [Apologies for being off-topic on vm-dev; I've set the reply-to to
> squeak-dev]
>
> On 4/21/2011 15:44, Igor Stasenko wrote:
>>
>> I tried various paint rules
>> 24, 34
>>
>> nothing. A balloon engine seems like completely ignores an alpha channel,
>> so i could use it for filling shapes using bitmaps as long as these
>> bitmaps fully opaque.
>>
>> I thought i could use a generic way to render bitmaps, instead of
>> using awkward warpBlt...
>> but it seems like something in plugin discards/ignores an alpha
>> channel of source bitmap.
>> I would be happy if this is not true.
>
> It isn't true. Here is an example for transparent bitmap rendering with the
> Balloon engine:
>
> "First we create a bitmap with a transparent pattern"
> f := Form extent: 100 at 100 depth: 32.
> f getCanvas asBalloonCanvas
> fillRectangle: f boundingBox
> fillStyle:
> ((GradientFillStyle colors: {Color transparent. Color white})
> origin: 0 at 0; direction: 0 at 100).
>
> "Now we're displaying it"
> (Display getCanvas asBalloonCanvas)
> transformBy: ((MatrixTransform2x3 withAngle: 45));
> fillRectangle: (400 at 0 extent: 400 at 400)
> fillStyle: (BitmapFillStyle fromForm: f)
>
> I'm not sure what you've been playing with but generally speaking you'll be
> better off with BalloonCanvas instead of trying to manipulate the Balloon
> engine directly.
>
Thanks. I figured out that i was wrong couple minutes before :)
I was confused with the way how some images are rendered.
They are looking different when drawn using
canvas translucentImage:
vs balloon & bitmapfillstyle
if i use exactly same bitmap but paint it using balloon engine through
fill style (rule 34),
a result looks quite different - an input image colors looks too much
saturated comparing to original, especially noticeable for small
alpha values.
Here's an example which i using:
| f bf |
f := Form extent: 10 at 10 depth: 32.
f getCanvas fillRectangle: (0 at 0 corner: 5 at 5) color: (Color red alpha: 0.3).
f getCanvas fillRectangle: (5 at 5 corner: 10 at 10) color: (Color green alpha: 0.3).
bf := BitmapFillStyle fromForm: f.
bf direction: 5 at 5.
bf normal: -5 at 5.
Display getCanvas asBalloonCanvas
fillRectangle: (0 at 0 corner: 100 at 100)
fillStyle: bf.
Display forceToScreen
which looks correct.
But when i use Pharo logo form (which usually sticks in top-left edge
of world)... it draws it completely differently comparing to way how
ImageMorph renders it:
drawOn: aCanvas
"Draw the border after the image."
| style |
self isOpaque
ifTrue:[aCanvas drawImage: image at: self innerBounds origin]
ifFalse:[aCanvas translucentImage: image at: self innerBounds origin].
(style := self borderStyle) ifNotNil:[
style frameRectangle: bounds on: aCanvas]
--
Best regards,
Igor Stasenko AKA sig.
More information about the Squeak-dev
mailing list
|