Recent

Author Topic: TextOutAngle broken?  (Read 9333 times)

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
TextOutAngle broken?
« on: June 25, 2015, 05:05:33 pm »
I was just trying to upgrade to bgrabitmap8.7 and found that:

Code: [Select]
procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; c: TBGRAPixel; align: TAlignment); override; overload;

is no longer working. It works in bgrabitmap8.5.2, but does not in bgrabitmap8.6 or later. Any ideas?

Many thanks for your work on this Circular, it is very much appreciated.

Cheers,
VTwin
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4471
    • Personal webpage
Re: TextOutAngle broken?
« Reply #1 on: June 25, 2015, 07:46:39 pm »
Hi VTwin!

I just tested it and it seems to work fine.

Can you provide a simple example where it does not work correctly?

I am happy if my library helps.  :)

Regards
Conscience is the debugger of the mind

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
Re: TextOutAngle broken?
« Reply #2 on: June 25, 2015, 11:45:40 pm »
Circular,

Thanks! It is embedded rather deeply in my code, but I will try to create a simple example. It was strange, the text on my graphs did not appear, so I ran it with each version of BGRABitmap going backwards until it worked again.

VTwin
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
Re: TextOutAngle broken?
« Reply #3 on: June 26, 2015, 12:08:18 am »
Circular,

I can confirm that it works in BGRABitmap 8.5.2 and not in BGRABitmap 8.7. I ran the attached example using both.

Note that (see my sig) I ran it in Carbon and did not test Windows or Linux.

Cheers,
VTwin
« Last Edit: June 26, 2015, 12:11:47 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4471
    • Personal webpage
Re: TextOutAngle broken?
« Reply #4 on: June 26, 2015, 01:17:57 pm »
It works fine here on Windows, so maybe there is a bug with MacOS implementation.

With a simple TextOut, it works?
Conscience is the debugger of the mind

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
Re: TextOutAngle broken?
« Reply #5 on: June 26, 2015, 03:29:27 pm »
Code: [Select]
  bmp.TextOut(20, 20, 'Hello world!', BGRABlack, taLeftJustify);

Works in 8.5.2, does not work in  >= 8.6.  :(

8.6 gives some new warnings:

Code: [Select]
bgralclbitmap.pas(555,7) Warning: unreachable code
bgralclbitmap.pas(642,7) Warning: unreachable code
bgrareadbmp.pas(696,10) Warning: unreachable code

due to this:

TBGRAPixel_RGBAOrder

Is it possibly due to RGB / BGR byte order code?
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4471
    • Personal webpage
Re: TextOutAngle broken?
« Reply #6 on: June 26, 2015, 08:48:12 pm »
The warnings are normal. I guess I will remove them in the future using compiler directives, but that's not a problem in itself.

When you say it is not working, you mean that nothing appears? In that case, maybe it nevers actually draw the picture.

Can you try to do the following?
Code: [Select]
bmp.Canvas.TextOut(20,20, 'Hello world!');
Otherwise, you can put a breakpoint in BGRATextOut procedure of unit BGRAText, and see what is happening. Note: you need to turn off compilation optimisations and turn on debug information (in package option).

Thank you for reporting the bug and solving it with me.  :)
Conscience is the debugger of the mind

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
Re: TextOutAngle broken?
« Reply #7 on: June 27, 2015, 02:32:05 am »
Hi Circular,

My great pleasure to help out. I can't upgrade unless it works in OS X anyway :) A small update:

Code: [Select]
procedure TForm1.FormPaint(Sender: TObject);
var
  bmp: TBGRABitmap;
begin
  bmp := TBGRABitmap.Create(ClientWidth, ClientHeight, BGRAWhite);
  bmp.DrawLineAntialias(10,10,50,50, cssRed, 1.0);
  bmp.TextOut(20, 20, 'Hello world!', BGRABlack, taLeftJustify);
  bmp.Canvas.TextOut(20,20, 'Hello world!');
  bmp.Draw(Canvas, 0, 0, True);                           
  bmp.Free;                                               
end;

The line draws just fine, but no text appears. I tried walking through it, but I got a bit lost as I do not really know what to look for. I can give it another shot, but maybe not tonight.

Cheers,
VTwin
« Last Edit: June 27, 2015, 02:34:31 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4471
    • Personal webpage
Re: TextOutAngle broken?
« Reply #8 on: June 27, 2015, 12:32:27 pm »
Ok VTwin.

Nevermind about debugging for now. Can you try the following?

Code: [Select]
procedure TForm1.FormPaint(Sender: TObject);
var
  bmp: TBGRABitmap;
begin
  bmp := TBGRABitmap.Create(ClientWidth, ClientHeight, BGRAWhite);
  bmp.DrawLineAntialias(10,10,50,50, cssRed, 1.0);

  bmp.Canvas.Font.Color := clBlackOpaque;
  bmp.Canvas.Font.Name := 'Helvetica';
  bmp.Canvas.Font.Height := 50;
  bmp.Canvas.TextOut(20,20, 'Hello world!');

  bmp.Canvas.Pen.Color := clBlue;
  bmp.Canvas.MoveTo(10,20);
  bmp.Canvas.LineTo(10,50); //does this line appear (as yellow after negative) ?

  //bmp.Negative; //does adding this call help display the text?

  bmp.Draw(Canvas, 0, 0, True); //does changing True to False help display in this case?
  bmp.Free;
end;

I propose here two alternatives (not both at the same time):
- changing True to False in the parameters of bmp.Draw to bypass processing the image
- adding a call to Negative that requires processing the whole image

Cheers
« Last Edit: June 27, 2015, 12:34:21 pm by circular »
Conscience is the debugger of the mind

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
Re: TextOutAngle broken?
« Reply #9 on: June 27, 2015, 05:30:49 pm »
Circular,

In 8.7:
1) The code you posted displays the red line on white background, no text or blue line.

2) Changing "True" to "False" has no effect.

3) Leaving "True" and adding the call to negative displays "red" line as blue on black background.

In 8.5.2:
1) "red" line is cyan,  "blue" line is blue, text is blue also, white background.

2) Lines and background same, but no text.

3) "red " line is red, "blue" line is yellow, text is yellow, black background.

Cheers,
VTwin

“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4471
    • Personal webpage
Re: TextOutAngle broken?
« Reply #10 on: June 28, 2015, 12:39:42 am »
Thanks.

I am a bit puzzled.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4471
    • Personal webpage
Re: TextOutAngle broken?
« Reply #11 on: June 28, 2015, 04:47:14 pm »
Maybe the bitmap data is not retrieved from the TBitmap.

VTwin, can you put a breakpoint at the first line of LoadFromRawImageImplementation procedure of BGRALCLBitmap, and tell me what way it goes?
Conscience is the debugger of the mind

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
Re: TextOutAngle broken?
« Reply #12 on: June 29, 2015, 05:50:24 pm »
Sorry, I was not available sooner. I'll see what I can do. It does this loop:

Code: [Select]
       
for n := ADestination.Height-1 downto 0 do
begin
  CopyAndSwapIfNecessaryAndReplaceAlpha(PBGRAPixel(psource_byte), PBGRAPixel(pdest_byte), ADestination.Width);
  inc(psource_byte, psource_delta);
  inc(pdest_byte, pdest_delta);
end;

Is that helpful?
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

circular

  • Hero Member
  • *****
  • Posts: 4471
    • Personal webpage
Re: TextOutAngle broken?
« Reply #13 on: June 29, 2015, 10:51:35 pm »
Thanks.

Hmmm... then I don't understand why it would not get the picture.

What happens if you test with the following:
Code: [Select]
procedure TForm1.FormPaint(Sender: TObject);
var
  bmp: TBitmap;
  bgra: TBGRABitmap;
begin
  bmp := TBitmap.Create;
  bmp.width := ClientWidth;
  bmp.Height := ClientHeight;
  bmp.Canvas.FillRect(0,0,bmp.Width,bmp.Height);
  bmp.Canvas.Font.Name := 'Arial';
  bmp.Canvas.Font.Height := 50;
  bmp.Canvas.TextOut(0,0,'Hello');
  bgra := TBGRABitmap.Create(bmp);
  bmp.Free;
  bgra.Negative;
  bgra.Draw(Canvas, 0, 0, True);
  bgra.Free;
end;
Conscience is the debugger of the mind

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
Re: TextOutAngle broken?
« Reply #14 on: June 30, 2015, 02:28:27 am »
I get a nice big white Hello on a black background :)
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

 

TinyPortal © 2005-2018