Menu

#130 dmBlend ignored in Draw method

v1.9.1
pending-rejected
Blend (3)
5
2012-08-13
2012-08-12
Anonymous
No

The draw mode dmBlend is only used when the source of the Draw command is identical to the target. When the source is different from the target dmOpaque is internally used.

Example: take an empty form "Form1", put a PaintBox32 "PaintBox32_1" on it. Fill the "PaintBuffer" method as follows:

procedure TForm1.PaintBox32_1PaintBuffer(Sender: TObject);
var
ClonePaintBox: TPaintBox32;
begin
Self.PaintBox32_1.Buffer.Clear(clLightGrey32);
Self.PaintBox32_1.Buffer.FillRect(20,20,50,50, clYellow32); // solid
Self.PaintBox32_1.Buffer.FillRectT(10,10,60,60, clTrWhite32); // incl. alpha

// clone paintbox
ClonePaintBox := TPaintBox32.Create(nil);
ClonePaintBox.Buffer.SetSize(Self.PaintBox32_1.Width, Self.PaintBox32_1.Height);
ClonePaintBox.Buffer.Draw(
Rect(0, 0, Self.PaintBox32_1.Width, Self.PaintBox32_1.Height),
Rect(0, 0, Self.PaintBox32_1.Width, Self.PaintBox32_1.Height),
Self.PaintBox32_1.Buffer
);

// prepare for alpha-blending
Self.PaintBox32_1.Buffer.DrawMode := dmBlend;
Self.PaintBox32_1.Buffer.MasterAlpha := $BF;

// blend from same paintbox and from different paintbox
Self.PaintBox32_1.Buffer.Draw( 10, 110, Rect(10,10,60,60), Self.PaintBox32_1.Buffer); // works incl. alpha
Self.PaintBox32_1.Buffer.Draw(110, 110, Rect(10,10,60,60), ClonePaintBox.Buffer); // does not work - alpha is ignored

ClonePaintBox.Destroy();
end;

Discussion

  • Christian-W. Budde

    Can you please also post what output you expect?

    With the code you posted, the Self.PaintBox32_1.Buffer draw mode is dmBlend (as specified), while the default (and unchanged) draw mode of ClonePaintBox.Buffer is dmOpaque.

    So it should be that the line

    Self.PaintBox32_1.Buffer.Draw(110, 110, Rect(10,10,60,60), ClonePaintBox.Buffer);

    ignores the alpha, since ClonePaintBox.Buffer has the draw mode dmOpaque. Also its MasterAlpha is unchanged, which means that even with dmBlend, the drawing would be opaque.

     
  • Christian-W. Budde

    • assigned_to: nobody --> cwbudde
    • status: open --> open-rejected
     
  • Christian-W. Budde

    • status: open-rejected --> pending-rejected
     
MongoDB Logo MongoDB