Questions tagged [tcanvas]

TCanvas provides an abstract drawing space for objects that must render their own images.

Use TCanvas as a drawing surface for objects that draw an image of themselves. Standard window controls such as edit controls or list boxes do not require a canvas, as they are drawn by the system.

TCanvas provides properties, events and methods that assist in creating an image by

Specifying the type of brush, pen and font to use.

Drawing and filling a variety of shapes and lines.

Writing text.

Rendering graphic images.

Enabling a response to changes in the current image.

TCanvas has two descendants, TControlCanvas and TMetafileCanvas, which assist in drawing images of controls and in creating metafile images for objects.

25 questions
7
votes
3 answers

How can I get a TEdit's canvas in Delphi?

I want to shorten a filename to fit in a TEdit, something like Edit1.Text := MinimizeName(FileName, Edit1.Canvas, Edit1.Width); Unfortunately this doesn't compile because a TEdit does have a Canvas property directly. The canvas is needed for its…
Joris Groosman
  • 771
  • 8
  • 23
5
votes
2 answers

Setting the Line End Styles for Canvas.LineTo

Is there any way to set the style for the lineends for the TCanvas.LineTo method? It seems to default to rounded ends, which looks very bad for several lines in a row of different colours when Pen.Width is set to a large value (e.g. 9). It looks…
Thomas Mueller
  • 282
  • 5
  • 8
5
votes
2 answers

How can I change the color of textOut of TCanvas (delphi)?

I am drawing text on TCanvas using TextOut() but I need a different text color. What can I do?
sdu
  • 2,740
  • 4
  • 31
  • 30
4
votes
2 answers

How can I keep all properties of a TControlCanvas and restore them later?

I'm trying to write a custom draw cell method for a TDBGridEh. The problem is when I change properties of pen, brush, ... the painting becomes messy. That's because the control does some extra painting itself after it calls the event handler. So I…
saastn
  • 5,717
  • 8
  • 47
  • 78
4
votes
1 answer

Painting a TCanvas to the screen in a compiled ROOT (CERN) application

What are the rules for painting to the screen? My end goal is to put the TCanvas into a class and paint from there, but for now I think that maybe looking at a less complicated example might help. Below is some code that compiles and paints to the…
Jordan
  • 695
  • 2
  • 8
  • 18
3
votes
1 answer

TBitmap looses Clipping region after non-related graphics code

Please consider the following code: type TBaseControl = class(TWinControl) private FBitmap : TBitmap; public constructor Create(AOwner : TComponent); override; procedure DrawBorder; end; TForm1 = class(TForm) Button1:…
Blurry Sterk
  • 1,595
  • 2
  • 9
  • 18
3
votes
2 answers

Drawing a borderline of dots around a TBitmap?

I have written a routine which should add a dotted border to a bitmap: procedure AddDottedBorderToBitmap(aBM: Vcl.Graphics.TBitmap); var c: TCanvas; begin c := aBM.Canvas; c.Pen.Color := clBlack; c.Pen.Mode := pmXor; c.Pen.Style :=…
user1580348
  • 5,721
  • 4
  • 43
  • 105
3
votes
3 answers

Delphi TCanvas object become corrupted after using from dll, how to restore?

Have some problem. I have a form with a canvas, I need access to this canvas from dll by its handle. I do this in this way: from dll canvas := TCanvas.Create; try canvas.Handle := handle; // do some painting on this canvas finally …
Mike K.
  • 145
  • 10
3
votes
2 answers

How to repaint canvas just in time?

The problem is: I draw some rectangle on the desktop, while mouse moving(rectangle size increases) I dont have lags, artefacts, etc, All is good: But when I resize rectangle to lower than it was beed, I have the artefact: The red rectangle is the…
AlexLL
  • 165
  • 1
  • 13
2
votes
1 answer

Set font color in FMX TCanvas

Not sure if I'm missing something here but are you able to set font color in Firemonkey TCanvas? I don't see anything to suggest this in the following property: Canvas.Font. ???? Any help would be great Thanks,
6String_Coder
  • 517
  • 10
  • 30
1
vote
1 answer

Performance Comparing Delphi tCanvas with .Net Graphics

I use Delphi 10.3 and .Net 5.0. I know tCanvas is GDI and Graphics is GDI+ which outperforms the former. But in the following simple codes tCanvas is faster. The 5 times average milliseconds of Delphi is 185.00 and .Net is 351.20. Why is tCanvas…
SHIN JaeGuk
  • 494
  • 1
  • 5
  • 14
1
vote
2 answers

how to move two bitmap-image on a canvas

I am writing an animation program under Delphi 7 consisting of moving two discs on a canvas (I choose a PaintBox) with a bounce effect on the edges. it's woks fine if I load the pictures one by one: In this case, when the two disks that arrive from…
sherlock
  • 13
  • 5
1
vote
1 answer

How to convert TCanvas->Arc value to SVG Arc

I write a converter for my Company from Metafile to SVG (TCanvas->arc). I already finished to convert rectangle or some other elements but i dont get it how i can convert the arc. I write my Code in JavaScript. :) I have a file and i read it in…
1
vote
1 answer

Should I unlock TBitmap canvas after locking it?

I want to draw on a local TBitmap and return it. Because I am outside the main thread, I have to lock the canvas before using it. (How threadsafe is TBitmap) Do I ever have to unlock the canvas, or will TBitmap destructor do it for me? Is it safe to…
VLL
  • 9,634
  • 1
  • 29
  • 54
0
votes
1 answer

How do I copy HTML content to a TCanvas in Delphi?

I have an application that uses a TWebBrowser to display an HTML report. I use a TCanvas, named PrintCanvas to print a page header, footer, and images. Now I'd like to add the content from the TWebBrowser to the canvas so that the HTML report is…
Kyle Williamson
  • 2,251
  • 6
  • 43
  • 75
1
2