Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-11

fcl-image lacking brush and pen?

10 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

It is just me or is a brush and pen implementation for pixel canvas missing? The standard brush does nothing:

function TFPPixelCanvas.DoCreateDefaultBrush : TFPCustomBrush;
begin
  result := TFPEmptyBrush.Create;
  with result do
    begin
    Style := bsClear;
    end;
end;

And I couldn't find any class descending from TFPCustomDrawBrush which implements a pixel brush.

The final issue that I am trying to solve is that this paints nothing:

procedure TCDGroupBoxDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
  CDGroupBox: TCDGroupBox);
begin
  ADest.Brush.FPColor := colRed;
  ADest.Rectangle(0, 0, CDGroupBox.Width, CDGroupBox.height);
end;

thanks,

Felipe Monteiro de Carvalho

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho

You must create an instance of TFPCustomDrawBrush and assign it to the canvas.

Same with pen.

Michael.

Felipe Monteiro de Carvalho wrote 33 lines
Hello, It is just me or is a brush and pen implementation for pixel canvas missing? The standard brush does nothing: function TFPPixelCanvas.DoCreateDefaultBrush : TFPCustomBrush; begin result := TFPEmptyBrush.Create; with result do begin Style := bsClear; end; end; And I couldn't find any class descending from TFPCustomDrawBrush which implements a pixel brush. The final issue that I am trying to solve is that this paints nothing: procedure TCDGroupBoxDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas; CDGroupBox: TCDGroupBox); begin ADest.Brush.FPColor := colRed; ADest.Rectangle(0, 0, CDGroupBox.Width, CDGroupBox.height); end; thanks, -- Felipe Monteiro de Carvalho _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Felipe Monteiro de Carvalho
to Michael Van Canneyt
Michael Van Canneyt wrote
You must create an instance of TFPCustomDrawBrush and assign it to the canvas.

It is an abstract class.

  TFPCustomDrawBrush = class (TFPCustomBrush)
  private
    procedure Rectangle (left,top, right,bottom:integer);
    procedure FloodFill (x,y:integer);
    procedure Ellipse (left,top, right,bottom:integer);
    procedure Polygon (const points:array of TPoint);
  public
    procedure DoRectangle (left,top, right,bottom:integer); virtual;
abstract; <<<
    procedure DoEllipse (left,top, right,bottom:integer); virtual; abstract;<<<
    procedure DoFloodFill (x,y:integer); virtual; abstract;<<<
    procedure DoPolygon (const points:array of TPoint); virtual; abstract;<<<
  end;

Plus, there is no way to set the brush it seams, because FBrush is private and SetBrush uses a Assign. It never uses a direct assignment, so it will never accept my own brush.

I created this revision to at least allow setting FBrush in sub-classes:

http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev

Any chance of adding it to fpc 2.4.2 rc2? Without this change I can't even use my own modified copy of fpimgcanv, because I also need to change TFPCustomCanvas and if I change it the types start to colide because the LCL also uses fpcanvas.pas.

thanks,

Felipe Monteiro de Carvalho

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 20 lines
On Thu, Nov 4, 2010 at 5:16 PM, Michael Van Canneyt wrote: > You must create an instance of TFPCustomDrawBrush and assign it to the > canvas. It is an abstract class. TFPCustomDrawBrush = class (TFPCustomBrush) private procedure Rectangle (left,top, right,bottom:integer); procedure FloodFill (x,y:integer); procedure Ellipse (left,top, right,bottom:integer); procedure Polygon (const points:array of TPoint); public procedure DoRectangle (left,top, right,bottom:integer); virtual; abstract; <<< procedure DoEllipse (left,top, right,bottom:integer); virtual; abstract;<<< procedure DoFloodFill (x,y:integer); virtual; abstract;<<< procedure DoPolygon (const points:array of TPoint); virtual; abstract;<<< end;

Ah. Indeed; Strange because I recall drawing circles and rectangles ?

Show quoted text 13 lines
Plus, there is no way to set the brush it seams, because FBrush is private and SetBrush uses a Assign. It never uses a direct assignment, so it will never accept my own brush. I created this revision to at least allow setting FBrush in sub-classes: http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev Any chance of adding it to fpc 2.4.2 rc2? Without this change I can't even use my own modified copy of fpimgcanv, because I also need to change TFPCustomCanvas and if I change it the types start to colide because the LCL also uses fpcanvas.pas.

No chance. 2.4.2 final build has already started.

Michael.

Reply by email

Felipe Monteiro de Carvalho
to Michael Van Canneyt

Hello,

Aha, now it works! =D

The default style is bsClear, just changing to bsSolid works. (although the default should probably be bsSolid)

procedure TCDGroupBoxDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
  CDGroupBox: TCDGroupBox);
begin
  ADest.Brush.FPColor := colRed;
  ADest.Brush.Style:=bsSolid;
  ADest.Rectangle(0, 0, CDGroupBox.Width, CDGroupBox.height);
end;

No idea how it works exactly, probably it only uses the brush functions if it isn't the trivial case: bsSolid

I've been having issues with the debugger, so I couldn't properly step into ...

Very good that 2.4.2 rc2 is being built by the way =) The broken generics in rc1 made it problematic =(

thanks,

Felipe Monteiro de Carvalho

Reply by email

Felipe Monteiro de Carvalho
to Felipe Monteiro de Carvalho

I also found where it draws. It seams that TFPPixelCanvas doesn't use the brush routines at all:

procedure TFPPixelCanvas.DoRectangleFill (const Bounds:TRect);
var b : TRect;
begin
  b := Bounds;
  SortRect (b);
  if clipping then
    CheckRectClipping (ClipRect, B);
  with b do
    case Brush.style of
      bsSolid : FillRectangleColor (self, left,top, right,bottom);
      bsPattern : FillRectanglePattern (self, left,top, right,bottom,
brush.pattern);
      bsImage :
        if assigned (brush.image) then
          if FRelativeBI then
            FillRectangleImageRel (self, left,top, right,bottom, brush.image)
          else
            FillRectangleImage (self, left,top, right,bottom, brush.image)
        else
          raise PixelCanvasException.Create (sErrNoImage);
      bsBDiagonal : FillRectangleHashDiagonal (self, b, FHashWidth);
      bsFDiagonal : FillRectangleHashBackDiagonal (self, b, FHashWidth);
      bsCross :
Felipe Monteiro de Carvalho

Reply by email

Birger Jansen
to Felipe Monteiro de Carvalho: I changed the default value of the brush to bsSolid. This should avoid some confusion in…

-----Oorspronkelijk bericht-----
Van: Felipe Monteiro de Carvalho
Verzonden: do 04-11-2010 18:11
Aan: FPC developers' list ;
Onderwerp: Re: [fpc-devel] fcl-image lacking brush and pen?

I changed the default value of the brush to bsSolid. This should avoid some confusion in the long term.

Any chance this will also be changed in TCanvas, which has the same confusing issue?

Kind regards,
Birger

Reply by email

Felipe Monteiro de Carvalho
to Birger Jansen
Birger Jansen wrote
Any chance this will also be changed in TCanvas, which has the same confusing issue?

TCanvas from the LCL? AFAIK the standard brush style is already bsSolid there.

Felipe Monteiro de Carvalho

Reply by email

Birger Jansen
to Felipe Monteiro de Carvalho
TCanvas from the LCL? AFAIK the standard brush style is already bsSolid there. -- Felipe Monteiro de Carvalho

Sorry, you are right. I looked at the wrong piece of code (TCanvas.DoCreateDefaultBrush in canvas.inc). It seems the problem I'm having with 'empty' rectangles is in some Delphi code that is written here.

Kind regards,
Birger

Reply by email