Recent

Author Topic: New version of BGRABitmap  (Read 178058 times)

lainz

  • Hero Member
  • *****
  • Posts: 3474
    • Lainz
Re: New version of BGRABitmap
« Reply #90 on: April 29, 2015, 01:42:50 pm »
Hi, I have not tested it on linux yet and only have 32 bit one.

But I have that problem the other day too, It was fixed on svn.
http://forum.lazarus.freepascal.org/index.php/topic,28063.msg175006.html#msg175006

and
http://forum.lazarus.freepascal.org/index.php/topic,28063.msg175022.html#msg175022

I know, of course if you will use it at linux you must check it out there.

Yes, the thing is bgrabitmap uses the LCL... I don't know, there is a new version that works with fpGUI only but never used it...

Edit: I can't compile under windows x64... some recent change broken the compilation.. I will report it.
« Last Edit: April 29, 2015, 01:49:32 pm by 007 »

Fred vS

  • Hero Member
  • *****
  • Posts: 1681
    • StrumPract is the musicians best friend
Re: New version of BGRABitmap
« Reply #91 on: April 29, 2015, 01:49:58 pm »
Quote
..there is a new version that works with fpGUI only but never used it...

Hum, i proposed to help to create a bgrabitmap library because of that => if no LCL => possible working library  :-[
I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

lainz

  • Hero Member
  • *****
  • Posts: 3474
    • Lainz
Re: New version of BGRABitmap
« Reply #92 on: April 29, 2015, 01:56:35 pm »
Ok... Well don't worry- but I can't help you in that  :(, maybe circular the author of bgrabitmap knows how to compile it and get it working under linux.

PD: I'm moving the Library stuff into another thread, to keep this thread readable:
http://forum.lazarus.freepascal.org/index.php/topic,28224.0.html

Bgrabitmap can't compile under Windows x64 now, because of recent changes (reporting it here):
Code: [Select]
bgrapath.pas(2526,32) Error: Call by var for arg no. 1 has to match exactly: Got "LongInt" expected "Int64"
« Last Edit: April 29, 2015, 02:05:47 pm by 007 »

circular

  • Hero Member
  • *****
  • Posts: 3111
    • Personal webpage
Re: New version of BGRABitmap
« Reply #93 on: April 29, 2015, 05:32:19 pm »
Hello!

I am going to see what is happening on Linux...
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3111
    • Personal webpage
Re: New version of BGRABitmap
« Reply #94 on: April 29, 2015, 06:04:23 pm »
It works on my mint here, but maybe the fixes were not in the zip files already.

There are also new features, so here is a new version 8.4 of BGRABitmap with:
- reorganised code of BGRABitmapTypes.
- Gif can be loaded, modified and saved with TBGRAAnimatedGif
- added TDithereingToIndexedImage class to get raw bitmap data of indexed colors (what you would find in a BMP file with a palette)
- final fix to export in PNG with transparency, now it's working perfectly in all cases
- text can be vertically anchored to its basline, or the top, or the center of the small letters, etc. with FontVerticalAnchor property

About BGRAPath unit
- added opened and closed splines in TBGRAPath
- you can draw a path by calling its stroke and fill functions, get it as points, compute its length
Code: [Select]
    function ComputeLength(AAcceptedDeviation: single = 0.1): single;
    function ToPoints(AAcceptedDeviation: single = 0.1): ArrayOfTPointF;
    procedure SetPoints(const APoints: ArrayOfTPointF);
    procedure stroke(ABitmap: TBGRACustomBitmap; AColor: TBGRAPixel; AWidth: single; AAcceptedDeviation: single = 0.1);
    procedure stroke(ABitmap: TBGRACustomBitmap; ATexture: IBGRAScanner; AWidth: single; AAcceptedDeviation: single = 0.1);
    procedure fill(ABitmap: TBGRACustomBitmap; AColor: TBGRAPixel; AAcceptedDeviation: single = 0.1);
    procedure fill(ABitmap: TBGRACustomBitmap; ATexture: IBGRAScanner; AAcceptedDeviation: single = 0.1);
- added cursor to browse a path (TBGRAPathCursor) : you can go forward, backward, set position, choose if the cursor can jump from one shape to another
« Last Edit: April 29, 2015, 06:38:17 pm by circular »
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3111
    • Personal webpage
Re: New version of BGRABitmap
« Reply #95 on: April 29, 2015, 06:13:21 pm »
Here is for example bspline example project in bgraaggtest folder.

The cursor here is shown with two arrows. One that is tangent and the other that is normal.

When you have a TBGRAPathCursor, you can get the coordinate and the tangent of the current point.

Here is the code that draws the path and the arrows:
Code: [Select]
    Path.stroke(bmp, BGRABlack, 2);

    PathCursor := Path.CreateCursor;
    PathCursor.Position := PathPos*PathCursor.PathLength;

    bmp.ArrowEndAsClassic;
    pt := PathCursor.CurrentCoordinate;
    tangent := PathCursor.CurrentTangent;
    bmp.DrawLineAntialias(pt.x,pt.y,pt.x+tangent.x*40,pt.y+tangent.y*40,CSSFireBrick,3);
    bmp.DrawLineAntialias(pt.x,pt.y,pt.x-tangent.y*40,pt.y+tangent.x*40,CSSFireBrick,3);
    bmp.ArrowEndAsNone;

    Cursor.Free;
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3474
    • Lainz
Re: New version of BGRABitmap
« Reply #96 on: April 29, 2015, 06:16:11 pm »
This is insane!
You ever sleep?

circular

  • Hero Member
  • *****
  • Posts: 3111
    • Personal webpage
Re: New version of BGRABitmap
« Reply #97 on: April 29, 2015, 06:23:22 pm »
lol sometimes  :D

Now you can do curved text using the path. I've added examples in testbgrafunc project. It is recommended to use a vectorial text renderer for good quality and speed.

Example of simple curved text: http://forum.lazarus.freepascal.org/index.php/topic,28079.msg176086.html#msg176086

Here is how to browse the path, combine the curved text with a gradient:
Code: [Select]
//draw ellipses along the path, also a simple example on how to travel along a path
procedure DrawRings(ABitmap: TBGRABitmap;
  APath: IBGRAPath; ACount: integer; ARadius: single);
var
  step: single;
  cursor: TBGRACustomPathCursor;
begin
  cursor := APath.getCursor;
  step := cursor.PathLength/ACount;
  cursor.Position:= 0;
  repeat
    with cursor.CurrentCoordinate do
      ABitmap.FillEllipseAntialias(x,y, ARadius,ARadius, CSSDarkSlateBlue);
  until cursor.MoveForward(step) < 0.5*step;
  cursor.Free;
end;

var background : TBGRABitmap;

  procedure PrepareBackground(Width,Height: integer);
  var
    path2: TBGRAPath;
    gradient: TBGRAGradientScanner;
    fontRenderer: TBGRAVectorizedFontRenderer;
  begin
    background := TBGRABitmap.Create(Width,Height,CSSLightSteelBlue);
    fontRenderer := TBGRAVectorizedFontRenderer.Create;
    background.FontRenderer := fontRenderer; //assign text vectorial font renderer
    background.FontHeight := round(size*0.09);
    background.FontQuality := fqFineAntialiasing;

    //half of a circle
    path2 := TBGRAPath.Create;
    path2.arc(width/2,height/2,size*0.4, Pi, 0, true);

    DrawRings(background, path2, 20, size/150);

    fontRenderer.OutlineColor := BGRABlack;
    fontRenderer.OutlineWidth := size/600;
    fontRenderer.OutlineVisible := true;
    background.FontVerticalAnchor := fvaBaseline;

    gradient := TBGRAGradientScanner.Create(CSSYellow, CSSOrange, gtLinear, PointF(0,height/2), PointF(0,height/2+size*0.5));
    background.TextOutCurved(path2, ' Left ...', gradient, taLeftJustify, 0);
    background.TextOutCurved(path2, 'Middle', gradient, taCenter, 0);
    background.TextOutCurved(path2, '... Right ', gradient, taRightJustify, 0);
    gradient.free;

    fontRenderer.OutlineVisible := false;
    background.FontVerticalAnchor := fvaTop;

    path2.Free;
  end;

Functions added in TBGRABitmap:
Code: [Select]
     procedure TextOutCurved(ACursor: TBGRACustomPathCursor; sUTF8: string; AColor: TBGRAPixel; AAlign: TAlignment; ALetterSpacing: single); virtual; abstract; overload;
     procedure TextOutCurved(ACursor: TBGRACustomPathCursor; sUTF8: string; ATexture: IBGRAScanner; AAlign: TAlignment; ALetterSpacing: single); virtual; abstract; overload;
     procedure TextOutCurved(APath: IBGRAPath; sUTF8: string; AColor: TBGRAPixel; AAlign: TAlignment; ALetterSpacing: single); virtual; overload;
     procedure TextOutCurved(APath: IBGRAPath; sUTF8: string; ATexture: IBGRAScanner; AAlign: TAlignment; ALetterSpacing: single); virtual; overload;
When you specify a path as parameter, taLeftJustify means the text starts at the beginning of the path, and taRightJustify that it ends at the end of the path.

When you specify a cursor, taLeftJustify means the text starts at the current position of the cursor and taRightJustify that it ends at the current position of the cursor.
« Last Edit: April 29, 2015, 06:39:27 pm by circular »
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3474
    • Lainz
Re: New version of BGRABitmap
« Reply #98 on: April 29, 2015, 07:37:24 pm »
I can't compile under Windows x64
Code: [Select]
Compilando paquete BGRABitmapPack 8.4: Exit code 1, Errors: 1, Hints: 1
bgrapath.pas(2595,32) Error: Call by var for arg no. 1 has to match exactly: Got "LongInt" expected "Int64"
bgrapath.pas(2035,20) Hint: Found declaration: TBGRAPath.GoToNextElement(var Int64):Boolean;

circular

  • Hero Member
  • *****
  • Posts: 3111
    • Personal webpage
Re: New version of BGRABitmap
« Reply #99 on: April 29, 2015, 08:21:58 pm »
Ah ok. If you replace the type of the variable Pos on line 2561 by the following?
Code: [Select]
var pos: IntPtr;
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3474
    • Lainz
Re: New version of BGRABitmap
« Reply #100 on: April 29, 2015, 08:48:10 pm »
Ah ok. If you replace the type of the variable Pos on line 2561 by the following?
Code: [Select]
var pos: IntPtr;

Yes. That works.

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: New version of BGRABitmap
« Reply #101 on: April 29, 2015, 08:52:34 pm »
I have started to produce documentation generated from the code.

Here is it:
http://wiki.lazarus.freepascal.org/BGRABitmap_Pixel_types
http://wiki.lazarus.freepascal.org/BGRABitmap_Color_definitions
http://wiki.lazarus.freepascal.org/BGRABitmap_Geometry_types

Please tell me how you find it!  :)

Thank you very much circular,Its very good.
Just in few seconds I learn somethings that I didn't know they are exists!
Also consider making documentation and demo showing what BGRABitmap can do like your old demo in LazPaint,With that I learn how using BGRABitmap and what can it do.we talked about it before.

Thank you again  ;)

circular

  • Hero Member
  • *****
  • Posts: 3111
    • Personal webpage
Re: New version of BGRABitmap
« Reply #102 on: April 29, 2015, 09:15:43 pm »
Yes. That works.
Cool! I have replaced the zip file for version 8.4.

Thank you very much circular,Its very good.
Just in few seconds I learn somethings that I didn't know they are exists!
Also consider making documentation and demo showing what BGRABitmap can do like your old demo in LazPaint,With that I learn how using BGRABitmap and what can it do.we talked about it before.

Thank you again  ;)
Thanks for the feedback. It gives me a reliable validation on how the documentation can be.  :)
Conscience is the debugger of the mind

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: New version of BGRABitmap
« Reply #103 on: April 29, 2015, 10:37:42 pm »
Quote
Thanks for the feedback. It gives me a reliable validation on how the documentation can be.
I'm always looking forward of BGRABitmap and trying to appreciate your work any how.

circular

  • Hero Member
  • *****
  • Posts: 3111
    • Personal webpage
Re: New version of BGRABitmap
« Reply #104 on: April 30, 2015, 01:20:42 am »
 :)

I have done the documentation of BGRABitmapTypes except TBGRACustomBitmap and TBGRACustomScanner. So I have added one category:
http://wiki.lazarus.freepascal.org/BGRABitmap_Miscellaneous_types

And have added things in the other categories in the documentation.

The system I use for documenting is very simple. Adding {* ... } comments before one line of code, and generating that into wiki syntax.
Conscience is the debugger of the mind