Lazarus

Programming => Graphics => Graphics and Multimedia => BGRABitmap and LazPaint => Topic started by: circular on April 13, 2014, 08:43:17 pm

Title: New version of BGRABitmap
Post by: circular on April 13, 2014, 08:43:17 pm
Hello,

A new version of BGRABitmap (7.3) has been released.

UTF8 support
In this version, when a UTF8 filename is expected, it is reflected by the name of the function or of the parameter:
Code: [Select]
    constructor TBGRAAnimatedGif.Create(filenameUTF8: string);
When there was no UTF8-handling function, it has been added. The class TFileStreamUTF8 is now used whenever possible to ensure maximum support of any UTF8 character.

Gtk (linux)
There was a bug when drawing an image on the canvas, sometimes the image had offset. This is hopefully corrected in 7.3 (tested on Lubuntu 32-bit).

New units
- BGRAGrayscaleMask: it is a light version of a bitmap having only one grayscale and linear channel. It does not provide any drawing capacities for now, except setpixel and direct pixel access. It is used internally by BGRAText.

- BGRAReadBMP, BGRAReadGif, BGRAReadPCX, BGRAReadPng, BGRAReadPSD, BGRAReadTGA, BGRAReadIco, bgrareadjpeg, BGRAReadXPM: these units are readers for images, that are automatically included in the program, to provide optimisations, corrections and additions to the standard ones provided by FreePascal. You may not need to make explicit reference to them because you can use them using the new TBGRAImageFormat enumeration.

- BGRAReadLzp, BGRAWriteLzp, BGRALzpCommon: this introduce a new version of Lzp format that you can use just like other image formats. The Lzp use by default a kind of RLE that is fast and does a compression that is in general a bit less efficient than PNG but still quite good (and surely much fast than PNG or zstream). It also supports layers. The software LazPaint use this format to store layered images. Note that in BGRABitmap, for now, you can only load and save flat images, so loading a layered image will just give you the flattened image of it.

- BGRAThumbnail: this unit provide fast loading and computation of thumbnails (using to display images for browsing)

- UnzipperExt: provides an unzipper that works with streams and UTF8 filenames

TAnimatedGif
To make it easy to display animated gif without using too much CPU, the following property has been added:
Code: [Select]
    property TimeUntilNextImageMs: integer read GetTimeUntilNextImage;
It returns the time in milliseconds before the next frame will be rendered. The value zero means that the Gif should be updated immedialty.

BGRABitmapTypes
- TResampleFilter provides now rfBox, which is high quality version of the stretched image. Note that the algorithm for stretched draw has been changed, it is to some extent faster and gives nice results except when the size becomes smaller than a half. In this case, not all pixels may be used to compute the resulting image. This makes it fast whatever the size of the original image is.
- TBGRAImageFormat = (ifUnknown, ifJpeg, ifPng, ifGif, ifBmp, ifIco, ifPcx, ifPaintDotNet, ifLazPaint, ifOpenRaster, ifPsd, ifTarga, ifTiff, ifXwd, ifXPixMap) are all the formats read by BGRABitmap. This goes with the following functions:
Code: [Select]
function DetectFileFormat(AFilenameUTF8: string): TBGRAImageFormat;
function DetectFileFormat(AStream: TStream; ASuggestedExtensionUTF8: string = ''): TBGRAImageFormat;
function SuggestImageFormat(AFilenameOrExtensionUTF8: string): TBGRAImageFormat;
function CreateBGRAImageReader(AFormat: TBGRAImageFormat): TFPCustomImageReader;
function CreateBGRAImageWriter(AFormat: TBGRAImageFormat; AHasTransparentPixels: boolean): TFPCustomImageWriter;
- DefaultBGRAImageReader, DefaultBGRAImageWriter: if you want to specify a reader for a specific file format.
- VGAColors: provide the basic 16 colors separately from CSS colors
- The color conversion between HSLA, GSBA and RGBA have been optimised. Also more functions to decode a string describing a color:
Code: [Select]
function BGRAToStr(c: TBGRAPixel; AColorList: TBGRAColorList = nil; AMaxDiff: Word= 0): string;
function StrToBGRA(str: string): TBGRAPixel; //full parse
function StrToBGRA(str: string; const DefaultColor: TBGRAPixel): TBGRAPixel; //full parse with default when error or missing values
function PartialStrToBGRA(str: string; const fallbackValues: TBGRAPixel; out error: boolean): TBGRAPixel; //partial parse allowed
procedure TryStrToBGRA(str: string; var parsedValue: TBGRAPixel; out missingValues: boolean; out error: boolean);

BGRAPolygon
Fixed a bug in FillShapeAliased about the computation of the horizontal position of the polygons.

BGRAScene3d
Added the following function to apply a function on each vertex/face:
Code: [Select]
     procedure ForEachVertex(ACallback: TVertex3DCallback);
    procedure ForEachFace(ACallback: TFace3DCallback);
Added the possibility to set custom flags on vertex/faces with the property CustomFlag.

BGRASliceScaling
UTF8 support to load TBGRASliceScaling and TBGRAMultiSliceScaling objects

BGRASSE
Fixed some compilation issues (constref instead of const).

BGRAStreamLayers
Supports now both Lzp compression, i.e. Zstream and RLE.

BGRAText and BGRATextFX
UTF8 support more explicit. Use of TGrayscaleMask to reduce memory usage and speed it up.
Title: Re: New version of BGRABitmap
Post by: circular on April 13, 2014, 09:05:08 pm
TBGRABitmap
There is no more LoadAsBmp32 as this is handled by BGRAReadBmp.

There are a lot of new functions for loading/saving:
Code: [Select]
     procedure LoadFromFileUTF8(const filenameUTF8: string); virtual;
     procedure LoadFromFileUTF8(const filenameUTF8: string; AHandler: TFPCustomImageReader); virtual;
     procedure SaveToFileUTF8(const filenameUTF8: string); virtual; overload;
     procedure SaveToFileUTF8(const filenameUTF8: string; Handler:TFPCustomImageWriter); virtual; overload;

To create a handler for a specific format, use CreateBGRAImageReader/CreateBGRAImageWriter.

The function Assign can now take instead of TBitmap any TRasterImage.
Code: [Select]
    procedure Assign(ARaster: TRasterImage); override; overload;
FillMask has an additional optional parameter DrawMode:
Code: [Select]
    procedure FillMask(x,y: integer; AMask: TBGRACustomBitmap; color: TBGRAPixel; ADrawMode: TDrawMode); override;
    procedure FillMask(x,y: integer; AMask: TBGRACustomBitmap; texture: IBGRAScanner; ADrawMode: TDrawMode); override;

There are new functions:
Code: [Select]
    procedure CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadePosition: byte; mode: TDrawMode = dmDrawWithTransparency); override;
    procedure CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadeMask: IBGRAScanner; mode: TDrawMode = dmDrawWithTransparency); override;
    procedure StretchPutImage(ARect: TRect; Source: TBGRACustomBitmap; mode: TDrawMode; AOpacity: byte = 255); override;

StretchPutImage does what is says: it is faster than storing the resampled image first with Resample and then use Putimage.
CrossFade: draws a transition between two images. If the fade position is a constant value, then it is equivalent to simple fade between two images. When using a fademask, you can vary the progression of the fade not only during time but also in space. For example you can make the left part of the image show Source1 and the right part show Source2.

You may need to adjust the values of the property ScanOffset if the images are not all aligned on the same top-left corner.

Some functions give you the resulting bounds of drawing an image with an affine transformation:
Code: [Select]
     function GetImageAffineBounds(Origin,HAxis,VAxis: TPointF; Source: TBGRACustomBitmap): TRect;
     function GetImageAngleBounds(x,y: single; Source: TBGRACustomBitmap; angle: single; imageCenterX: single = 0; imageCenterY: single = 0; ARestoreOffsetAfterRotation: boolean = false): TRect;
You should transmit these bounds to the drawing function you use after that.


VerticalFlip and HorizontalFlip now can take a rectangle as a parameter to specify the area to be flipped. Note that these functions do not care about the clipping rectangle, so if you want to take it into account, you need to do an IntersectRect with ClipRect.

Similary ApplyMask take more parameters:
Code: [Select]
    procedure ApplyMask(mask: TBGRACustomBitmap; ARect: TRect; AMaskRectTopLeft: TPoint); override;To specify the area and an offset for the mask. ApplyMask do not care about the clipping rectangle either.

Drawing checkers is now a basic function:
Code: [Select]
    procedure DrawCheckers(ARect: TRect; AColorEven,AColorOdd: TBGRAPixel);
Title: Re: New version of BGRABitmap
Post by: lainz on April 14, 2014, 07:24:38 pm
Thanks for the update!

Now i can load files with ñ (n tilde)
Title: Re: New version of BGRABitmap
Post by: circular on April 14, 2014, 11:39:21 pm
Wonderful  :)
Title: Re: New version of BGRABitmap
Post by: lainz on April 21, 2014, 05:05:09 pm
StretchPutImage is cool you can add StretchAndDraw in a tcanvas as destination?

Also you can add noise filter? Is random bw or random rgb (select one with a radio button) with alpha in a slider. Also in photoshop if i remember well rhere is a blur parameter. Is usefull to add some realism or texture to images. Combined with a blend mode.

Now bgracontrols are faster thanks!

Also we have added uecontrols and analog controls. About 25 usable ui controls! Plus lazpaint!
Title: Re: New version of BGRABitmap
Post by: circular on April 21, 2014, 09:40:02 pm
Yes we are on the right track! That's a lot of great controls!

About StretchAndDraw, well the thing is that it would be equivalent to Resample(rmSimpleStretch) + Draw. It would not be optimised as it is not possible to access video memory directly. However I understand that it would be a bit simpler. I guess I would like to encourage people to resample their image once, store it, and then draw it.

About noise filter, yes it is possible to add it. For now, you can do it using the Function filter, by writing "random" in the expression. I reckon it is not very simple.

Title: Re: New version of BGRABitmap
Post by: circular on May 02, 2014, 08:46:32 pm
New version of BGRABitmap 7.4.

What's new:
- Lanczos filter. Specify rfLanczos2, rfLanczos3 or rfLanczos4 for the ResampleFilter property.
- PutImageAffine, PutImageAngle and FilterRotate have a CorrectBlur parameter that reduces the blur effect due to the mix of pixels
- BGRAGradientScanner.TBGRARandomScanner added: it fills with pixels with random values (grayscale or color)
- BGRATypeWriter.TBGRAPolygonalGlyph has now an option to choose between angle/curve instead of autodetection

Fixes/changes:
- PCX format detection fix
- generic TBitmapTracker fix
- ApplyMask fix for transparent pixels
- randomize called in units where random is used
- BGRAFilters.TFilterTask now has a currentY property

Where to find the sources:
http://sourceforge.net/projects/lazpaint/files/src/
Title: Re: New version of BGRABitmap
Post by: VTwin on May 05, 2014, 06:11:13 pm
Wow! Thanks so much Circular. I really appreciate your work on this.

I am trying to implement some edge detection functions, including Difference of Gaussians or similar. Can I do that using the radial blur?

I noticed you said:

Quote
About noise filter, yes it is possible to add it. For now, you can do it using the Function filter, by writing "random" in the expression. I reckon it is not very simple.

What is "the Function filter"? I can't find a reference. Does it convolve with a kernel?

Thanks again!

Cheers,
Frederick
Title: Re: New version of BGRABitmap
Post by: circular on May 05, 2014, 09:21:23 pm
That is an interesting idea to do the difference of gaussians. You can use a radial blur, however, it is not very fast, so you would better use a fast blur I presume.

About function filter, we were talking with 007 of LazPaint filters (menu Filter). It uses an expression parser to apply a formula to each pixel separately. So this is different from kernels that are use to combine pixels.

In order to implement it, I have added BGRAGradientScanner.TBGRARandomScanner that you can use like that:
Code: [Select]
uses BGRABitmap, BGRABitmapTypes, BGRAGradientScanner;

{ TForm1 }

procedure TForm1.FormPaint(Sender: TObject);
var bmp: TBGRABitmap;
  scan: TBGRARandomScanner;
begin
  bmp := TBGRABitmap.Create(ClientWidth,ClientHeight);
  scan := TBGRARandomScanner.Create(False,255);
  bmp.Fill(scan);
  scan.Free;
  bmp.Draw(Canvas,0,0);
  bmp.Free;
end;
Title: Re: New version of BGRABitmap
Post by: VTwin on May 09, 2014, 02:39:54 pm
Circular,

Thanks for the explanation. I implemented a few edge filters by writing code to convolve and correlate kernels. They are probably not optimal, but work for what I need.

Thanks again for your work on TBGRABitmap. I look forward to any future versions.

Cheers,
Frederick
Title: Re: New version of BGRABitmap
Post by: circular on May 09, 2014, 08:29:40 pm
New version of BGRABitmap 7.5, just to fix an "intellisense typo" that cause a crash with StretchPutImage on 64-bit processors.

http://sourceforge.net/projects/lazpaint/files/src/
Title: Re: New version of BGRABitmap
Post by: circular on July 23, 2014, 04:09:13 pm
New version 7.6 of BGRABitmap!

SVG support
- Basic handling of CSS units in BGRAUnits.pas
- Basic handling of SVG in BGRASVG.pas

How to use SVG:

Code: [Select]
Uses BGRABitmap, BGRABitmapTypes, BGRASVG, BGRAUnits;
var svg: TBGRASVG;
begin
  bmp := TBGRABitmap.Create(500,500, BGRAWhite);

  //it is recommended to initialise the SVG with size and unit
  //otherwise, the size is kind of undefined

  svg := TBGRASVG.Create(10,6,cuCentimeter);
  svg.Content.AppendPath('M1,1 L9,1 9,5 1,5 z', cuCentimeter).fillColor := CSSGreen;
  svg.Content.AppendRect(2,2,6,2, cuCentimeter).fillColor:= BGRA(255,255,0,192);
  with svg.Content.AppendRect(0,0,svg.Units.ConvertWidth(1,cuCentimeter,cuPixel),
  svg.Units.ConvertHeight(1,cuCentimeter,cuPixel), cuPixel) do
  begin
    fillColor := CSSBlue;
    fillOpacity:= 0.2;
  end;
  svg.Content.AppendRoundRect(3,3,4,1, 0.3,0.3, cuCentimeter).fillColor := CSSOrange;
  with svg.Content.AppendLine(150,150,450,250, cuPoint) do
  begin
    strokeColor := BGRABlack;
    strokeOpacity:= 0.8;
  end;
  svg.Content.AppendLine(svg.ViewBox.min,svg.ViewBox.min+svg.ViewBox.size).strokeColor := CSSRed;
  with svg.Content.AppendCircle(5,3,3,cuCentimeter) do
  begin
    strokeColor := CSSRed;
    strokeWidth := FloatWithCSSUnit(2,cuPoint);
    fillNone;
  end;

  //SVG needs to be drawn on a Canvas2D surface
  svg.Draw(bmp.Canvas2D,50,50,cuPoint);
  //SVG can be saved in a file that can be viewed in
  //a web browser or in InkScape for example
  svg.SaveToFile('test.svg');
  svg.Free;
 
  //you can display the bitmap or save it to a file

  bmp.Free;
end;

Drawing improvements
- PutImageAffine and PutImageAngle have more options
- function to get intermediate pixels using integer values only :
Code: [Select]
     function TBGRABitmap.GetPixel256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter = rfLinear; smoothBorder: boolean = true): TBGRAPixel; virtual; abstract;
     function TBGRABitmap.GetPixelCycle256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter = rfLinear): TBGRAPixel; virtual; abstract; overload;
     function TBGRABitmap.GetPixelCycle256(x, y, fracX256,fracY256: int32or64; AResampleFilter: TResampleFilter; repeatX: boolean; repeatY: boolean): TBGRAPixel; virtual; abstract; overload;

- TBGRAPath (in unit BGRAPath) can contain any path (supports SVG definition of a path)
- arc definition: TArcDef, ArcDef(...) to be used with TBGRAPath
Code: [Select]
function Html5ArcTo(const p0, p1, p2: TPointF; radius: single): TArcDef;
function SvgArcTo(const p0: TPointF; rx, ry, xAngleRadCW: single; largeArc,
  anticlockwise: boolean; const p1: TPointF): TArcDef;
function ArcStartPoint(const arc: TArcDef): TPointF;
function ArcEndPoint(const arc: TArcDef): TPointF;
function IsLargeArc(const arc: TArcDef): boolean;

- function to draw paths:
Code: [Select]
     procedure TBGRABitmap.DrawPath(APath: IBGRAPath; c: TBGRAPixel; w: single); virtual; abstract;
     procedure TBGRABitmap.DrawPath(APath: IBGRAPath; texture: IBGRAScanner; w: single); virtual; abstract;
     procedure TBGRABitmap.FillPath(APath: IBGRAPath; c: TBGRAPixel); virtual; abstract;
     procedure TBGRABitmap.FillPath(APath: IBGRAPath; texture: IBGRAScanner); virtual; abstract;

Canvas2D
- Canvas2d has helper functions that use LCL types, TAffineMatrix, TBGRAPath, TArcDef, to draw ellipses

Notably Canvas2d now support text drawing, with any matrix transformation. To do so, you need to specify a text renderer that supports vectorial drawing:
Code: [Select]
uses BGRABitmap, BGRABitmapTypes, BGRAVectorize;
var bmp: TBGRABitmap;
begin
  bmp := TBGRABitmap.Create;
  bmp.Canvas2D.fontRenderer := TBGRAVectorizedFontRenderer.Create; //here we supply an adequate font renderer
  bmp.Canvas2D.font := '20px Arial';
  bmp.Canvas2D.fillStyle(BGRABlack);
  bmp.Canvas2D.textBaseline := 'top'; //we can align the text to baseline, top, bottom...
  bmp.Canvas2D.translate(50,50);
  bmp.Canvas2D.scale(10,10);
  bmp.Canvas2D.rotate(-30*Pi/180);
  bmp.Canvas2D.fillText('Test1',0,0);
end;

Misc
- LZP format can store paletted RGB (automatically reduce the size of images with less than 256 colors)
- Fixed a bug with TBGRABitmap.SaveToFile calling the wrong sub function
- Fixed a bug with fill function when there would be a point without a successor
- optimisation of bitmap rotation
- more robust streaming of layered images
- other small fixes

http://sourceforge.net/projects/lazpaint/files/src/

Cheers
Title: Re: New version of BGRABitmap
Post by: exdatis on July 23, 2014, 11:51:11 pm
Thank you very much, circular!
Title: Re: New version of BGRABitmap
Post by: circular on July 24, 2014, 05:48:33 pm
You're welcome!  :D
Title: Re: New version of BGRABitmap
Post by: Dibo on July 24, 2014, 11:34:50 pm
Nice to see how BGRABitmap is growing up and now you are going to CSS world. I'm impressed. Maybe in future we will have good alternative for HTMLPort or IpHTMLPanel ;) . I have question, you are drawing text by your self right? I mean, you are not using OS API for that. I always wanted to create "own drawed" TEdit like control. Main purpose is:
- Text hint / placeholder on all platforms (Qt, Gtk, Windows). This is a hint which is showed when edit text is empty. Normally only Gtk (ver 3+) and Qt has it, but due that windows edit doesn't, LCL is not publishing this property
- Extra buttons inside TEdit

My questions is: do BGRABitmap has some handy routines for text drawing? I tried do this using TCanvas but I have problems with calculating word wrap for static and selected text (it was dependend on OS API), cursor pos etc.
Title: Re: New version of BGRABitmap
Post by: taazz on July 25, 2014, 12:52:31 am
- Text hint / placeholder on all platforms (Qt, Gtk, Windows). This is a hint which is showed when edit text is empty. Normally only Gtk (ver 3+) and Qt has it, but due that windows edit doesn't, LCL is not publishing this property
http://msdn.microsoft.com/en-us/library/windows/desktop/bb761701%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb761701%28v=vs.85%29.aspx)
Title: Re: New version of BGRABitmap
Post by: Dibo on July 25, 2014, 09:50:50 am
- Text hint / placeholder on all platforms (Qt, Gtk, Windows). This is a hint which is showed when edit text is empty. Normally only Gtk (ver 3+) and Qt has it, but due that windows edit doesn't, LCL is not publishing this property
http://msdn.microsoft.com/en-us/library/windows/desktop/bb761701%28v=vs.85%29.aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb761701%28v=vs.85%29.aspx)
My mistake. It is on windows and Qt but not on Gtk2 (added in Gtk3). I made a mistake with button in tabsheets (available on Gtk and Qt but not on Windows)
Title: Re: New version of BGRABitmap
Post by: circular on July 25, 2014, 03:21:12 pm
BGRABitmap uses the underlying OS to produce fonts. However it tries to look the same on all platforms. You can have a try simply in a window, to draw text, measure it, etc. and if you find it give acceptable results for you, then it is ok. If there are differences between OS's, I would be happy to know about it.
Title: Re: New version of BGRABitmap
Post by: taazz on July 25, 2014, 04:42:32 pm
My mistake. It is on windows and Qt but not on Gtk2 (added in Gtk3).

Dumn! I was hopping that the next release would have this feature surfaced, now we have to wait for a stable release of gtk3. Oh well.
Title: Re: New version of BGRABitmap
Post by: circular on August 07, 2014, 05:53:29 pm
Here is a new version of BGRABitmap (7.7) for a quick fix of a bug in 3d rendering. You don't need to update now unless you work with 3d models with shading.

http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap7.7.zip/download

Title: Re: New version of BGRABitmap
Post by: circular on September 21, 2014, 08:04:32 pm
New version of BGRABitmap ( 7.8 )

- can read MioMap BMP files (files start with RL instead of BM)
- function to define a rectangle not with right/bottom but with width/height
Code: [Select]
function RectWithSize(left,top,width,height: integer): TRect;- GDK offset fix (Linux)
- fast blur with large radius fix
- PNG grayscale+alpha 16 bit fix

http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap7.8.zip/download
Title: Re: New version of BGRABitmap
Post by: circular on October 11, 2014, 01:55:54 pm
New version of BGRABitmap (7.9)
http://sourceforge.net/projects/lazpaint/files/src/

Fixes:
- fixes for GIF on big endian machines
- fix for TBGRACanvas.Rectangle function with Filled:=False
- fix for ArcStartPoint function

Added:
- added support for arrows
- added function ComputeArc(const arc: TArcDef; quality: single): ArrayOfTPointF;

Example for arrows:
Code: [Select]
uses BGRABitmap, BGRABitmapTypes;

{ TForm1 }

procedure TForm1.FormPaint(Sender: TObject);
const w=9;
var bmp:TBGRABitmap;
begin
  bmp := TBGRABitmap.Create(ClientWidth,ClientHeight,BGRAWhite);

  bmp.ArrowStartAsTail;
  bmp.ArrowStartRepeat := 2;
  bmp.ArrowEndAsTriangle(0.25,False,True);
  bmp.DrawPolyLineAntialias(
    bmp.ComputeOpenedSpline([PointF(80,80),PointF(ClientWidth-160,ClientHeight div 2),PointF(ClientWidth-80,ClientHeight-20)],ssCrossingWithEnds),
    BGRABlack,w);
  bmp.ArrowStartRepeat := 1; //restore default value

  bmp.ArrowStartAsClassic(True,True,3);
  bmp.ArrowStartOffset := -8;
  bmp.ArrowEndAsClassic(False,True);
  bmp.DrawPolyLineAntialias(
    bmp.ComputeOpenedSpline([PointF(40,60),PointF(ClientWidth div 3,20),PointF(ClientWidth-80,40)],ssCrossingWithEnds),
    BGRABlack,w);
  bmp.ArrowStartOffset := 0; //restore default value

  bmp.ArrowStartAsClassic(True,True);
  bmp.ArrowStartSize := PointF(1,2);
  bmp.ArrowStartOffset := -5.5;
  bmp.ArrowStartRepeat := 3;
  bmp.ArrowEndAsTriangle(0.75);
  bmp.DrawLineAntialias(20,90, 80,ClientHeight-40,
    BGRABlack,w);
  bmp.ArrowStartSize := PointF(2,2); //restore default values
  bmp.ArrowStartOffset := 0;
  bmp.ArrowStartRepeat := 1;

  bmp.ArrowStartAsClassic;
  bmp.ArrowEndAsClassic(False,False,2);
  bmp.DrawLineAntialias(ClientWidth-40,40,ClientWidth-40,ClientHeight-80,BGRABlack,w);

  bmp.Draw(Canvas,0,0);
  bmp.Free;
end;

To define an arrow, use ArrowStartAs... and ArrowEndAs...

Some properties are there to customise the head/tail:
- ArrowStartRepeat is the number of repetition of the arrow head/tail. The default value is 1.
- ArrowStartOffset is the offset of the head/tail relative to the start of the line, one unit being equal to the width of the line. The default value is 0.
- ArrowStartSize is the size of the arrow head, one unit being equal to the width of the line. The default value is PointF(2,2)

ArrowEnd... and ArrowStart... are the same except ArrowEnd is relative to the end of the line

The arrows are applied to DrawLineAntialias and DrawPolyLineAntialias functions
Title: Re: New version of BGRABitmap
Post by: circular on October 12, 2014, 06:40:49 pm
Here is a version 7.9.2. It is a quick fix for arrows. It also solves one problem with multipolygon filling.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap7.9.2.zip/download
Title: Re: New version of BGRABitmap
Post by: circular on November 06, 2014, 11:32:28 am
Here is version 7.9.3. It fixes bezier curves in Canvas2d and improves speed on Linux for text rendering.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap7.9.3.zip/download
Title: Re: New version of BGRABitmap
Post by: Xirax on February 27, 2015, 02:42:50 am
For any one interest to BGRABitmap its good to take a look at Jimi:
http://forum.lazarus.freepascal.org/index.php/topic,27524.0.html (http://forum.lazarus.freepascal.org/index.php/topic,27524.0.html)
Title: Re: New version of BGRABitmap
Post by: circular on March 12, 2015, 07:24:09 pm
Thanks for the link Xirax.

Here is a new version of BGRABitmap 8.0.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.0.zip/download

Box blur
A very fast blur is available. It is "box blur", where the area around a pixel is blurred as a square. You can use it with:

- text effects (set ShadowQuality:= rbBox)
- FilterBlurRadial (use rbBox as blur type)
- Canvas2d (set shadowFastest:= true)

3d rendering
It is essentially an upgrade to support more OBJ files :
- it is possible now to define custom normals
- negative vertex reference has been added
- loading materials from MTL file (using LoadMaterialsFromFileUTF8 function)

Often, the material file has the same name as the object file, so you can get the correct filename:
Code: [Select]
materialFilename := ChangeFileExt(objectFilename,'.mtl')
Color quantization
This goes with new classes to handle palettes. In BGRAPalette unit, there are different kind of palettes. The types you are likely to create are :
- TBGRAPalette: a palette where you can add and remove colors
- TBGRAWeightedPalette: a palette where each color has a weight. So if you add the same color multiple times, its weight increases

In order to reduce the number of colors or to save a bitmap to a file with a small number of colors, the class TBGRAColorQuantizer is available BGRAColorQuantization unit.

First instantiate TBGRAColorQuantizer with a bitmap or a palette. It will procude a reduced palette. The maximum number of color in this palette is defined by the property ReductionColorCount (by default 256). There are different ways to handle transparency, indicated by TAlphaChannelPaletteOption :
- acIgnore: it means alpha channel is considered separately from the color
- acTransparentEntry: it means that one entry in the palette will be the transparent color, with alpha = 0
- acFullChannelInPalette: it means that there will be if necessary a gradient of alpha values represented in the palette (this is recommended for example if you save in PNG format)

Here is for example how you would produce a 256 color PNG file:
Code: [Select]
uses BGRAColorQuantization, BGRABitmapTypes, BGRABitmap;
var
  quant : TBGRAColorQuantizer;
  sourceBmp: TBGRABitmap;
begin
  sourceBmp := TBGRABitmap.Create('picture_in_32_bits.bmp');
  quant := TBGRAColorQuantizer.Create(sourceBmp, acFullChannelInPalette);
  quant.SaveBitmapToFile(daFloydSteinberg, sourceBmp, 'picture_in_8_bits.png');
  quant.Free;
  sourceBmp.Free;
end;

Here is for example how you would produce a 16 color BMP file:
Code: [Select]
uses BGRAColorQuantization, BGRABitmapTypes, BGRABitmap;
var
  quant : TBGRAColorQuantizer;
  sourceBmp: TBGRABitmap;
begin
  sourceBmp := TBGRABitmap.Create('picture.jpg');
  quant := TBGRAColorQuantizer.Create(sourceBmp, acIgnore);
  quant.ReductionColorCount := 16;
  quant.SaveBitmapToFile(daFloydSteinberg, sourceBmp, 'picture_in_4_bits.bmp');
  quant.Free;
  sourceBmp.Free;
end;
Title: Re: New version of BGRABitmap
Post by: aradeonas on March 22, 2015, 04:30:19 pm
Thank you very much circular.
Its good to see a new version specially Blure.
@circular is there any roadmap for BGRA and its control?
Title: Re: New version of BGRABitmap
Post by: circular on March 22, 2015, 07:43:21 pm
Indeed box blur is pretty fast.  :)

For BGRABitmap itself, there is not much on the todo list. There are possible improvements in different areas : SVG format, GIF format, font handling, grayscale bitmap stored in memory, more file formats. However none of those are essential nor have I received any request in that direction, except one minor request for line spacing with text rendering.

For LazPaint, I am adding new features and hope to release a new version soon.

I wrote LZP file format reference there:
http://wiki.freepascal.org/LazPaint_LZP_Format

Regarding controls, the simplest would be to see with 007 on BGRA Control thread. He is doing a great job maintaining the package.
Title: Re: New version of BGRABitmap
Post by: aradeonas on March 22, 2015, 07:52:01 pm
Thanks but I have request for you ;)
If we have more vector tools like SVG format and adding them to Canvas2D it will be great.I like vector UI very much.
Also a big thing that I think BGRABitmap need is documentation and more demos maybe because for someone like me is hard to learn and all I learned is from demos that you made in old BGRABitmap topics and demos in old LazPaint package.Also a new home like a website will be good.
Because when I talk to developers most of them don't know BGRABitmap is exists and one of my reason in working with Lazarus is BGRABitmap so more people know it more request come ;)
PS,tutorial (http://wiki.freepascal.org/BGRABitmap_tutorial) is not enough for this beautiful world.
Title: Re: New version of BGRABitmap
Post by: circular on March 22, 2015, 09:17:12 pm
Well I would appreciate some help writing the documentation.

I take a note of your request for more SVG and Canvas2d.
Title: Re: New version of BGRABitmap
Post by: aradeonas on March 22, 2015, 09:23:20 pm
Make a plan for documentation and we come to help.
Some one like me may not write documentation but can help in organizing,checking,making demo and many tiny stuff that make you bored.
Title: Re: New version of BGRABitmap
Post by: circular on March 23, 2015, 10:04:30 am
I don't really know where to start. Maybe make a reference of all functions and of all classes? Generate it automatically?
Title: Re: New version of BGRABitmap
Post by: aradeonas on March 23, 2015, 04:39:19 pm
Yes sure its needed.Because when some one like me with no experience browse source don't know what these functions do.A summary comment do the job like TBlendOperation,What each one do?
But for a graphic library full of color there is big need for functions demos to developer see the difference.It help very much,without your old demos and tutorial I'm sure I cant learn much. A big demo application that like tour show how functions works like my previous example show what is the difference of TBlendOperation.
I know it may need much work but @circular you made a brilliant work but when I test introducing it to my friends they its not clear for them how much power it has.
More user is like more blood in BGRABitmap's body.
For these you make a plane and I will help in whatever you think I can useful.

Title: Re: New version of BGRABitmap
Post by: aradeonas on March 23, 2015, 11:46:34 pm
There are many documentation tools that you can simply find but I think its good to look it this (http://synopse.info/fossil/wiki?name=SynProject).
Its used for BIG mORMot documentation (http://synopse.info/files/html/Synopse mORMot Framework SAD 1.18.html) and maybe it works for BGRABitmap.
Title: Re: New version of BGRABitmap
Post by: circular on March 24, 2015, 12:49:53 am
We could for example do a reference like this:
http://wiki.lazarus.freepascal.org/TBGRABitmap_class

What do you think?
Title: Re: New version of BGRABitmap
Post by: aradeonas on March 24, 2015, 01:07:39 am
Its clean and being part of wiki has its benefits.
But we have a problem that all you or any body else write specialty about functions remain just in wiki and not in source,I think it can be better to use a system like I said that have documentation in code and a separate documentation.
Also I stick to demos,They are more useful to show how system works specially for a graphic library that work with eye.It can get more work but has many benefits.
Title: Re: New version of BGRABitmap
Post by: circular on March 24, 2015, 01:25:41 am
I understand.

In the code, there is inheritance and overriding, so many functions have headers in multiple files. So where to put the description? A copy of the description in BGRABitmapTypes and in BGRADefaultBitmap?
Title: Re: New version of BGRABitmap
Post by: aradeonas on March 24, 2015, 01:34:25 am
Yes.
Some one like me and many others use Ctrl+Mouse hover for browsing the code and best place I think is BGRADefaultBitmap because always I want to check a function I will go to it and read comments.
Title: Re: New version of BGRABitmap
Post by: circular on March 24, 2015, 02:37:12 am
I have added on SVN the same info as inline comments. It looks like this:
Code: [Select]
    { Draws the UTF8 encoded string, with color c.
      If align is taLeftJustify, (x,y) is the top-left corner.
      If align is taCenter, (x,y) is at the top and middle of the text.
      If align is taRightJustify, (x,y) is the top-right corner.
      The value of FontOrientation is taken into account, so that the text may be rotated. }
    procedure TextOut(x, y: single; sUTF8: string; c: TBGRAPixel; align: TAlignment); override; overload;

    { Same as above functions, except that the text is filled using texture.
      The value of FontOrientation is taken into account, so that the text may be rotated. }
    procedure TextOut(x, y: single; sUTF8: string; texture: IBGRAScanner; align: TAlignment); override; overload;

    { Same as above, except that the orientation is specified, overriding the value of the property FontOrientation. }
    procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; c: TBGRAPixel; align: TAlignment); override; overload;
    procedure TextOutAngle(x, y: single; orientationTenthDegCCW: integer; sUTF8: string; texture: IBGRAScanner; align: TAlignment); override; overload;

    { Draw the UTF8 encoded string at the coordinate (x,y), clipped inside the rectangle ARect.
      Additional style information is provided by the style parameter.
      The color c or texture is used to fill the text. No rotation is applied. }
    procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; c: TBGRAPixel); override; overload;
    procedure TextRect(ARect: TRect; x, y: integer; sUTF8: string; style: TTextStyle; texture: IBGRAScanner); override; overload;

    { Returns the total size of the string provided using the current font.
      Orientation is not taken into account, so that the width is along the text.  }
    function TextSize(sUTF8: string): TSize; override;

Is this what you had in mind?
Title: Re: New version of BGRABitmap
Post by: aradeonas on March 24, 2015, 09:41:19 am
Exactly.Thank you very much.explanation is enough and easy to understand.
But for another example for my idea about demo consider this that for complex functions like "FillEllipseLinearColorAntialias" its hard to explain it and also to understand just with reading.
Title: Re: New version of BGRABitmap
Post by: circular on March 24, 2015, 12:10:59 pm
Ok, I think I get the idea.
Title: Re: New version of BGRABitmap
Post by: circular on April 02, 2015, 04:16:06 pm
Here is a new version of BGRABitmap 8.1 with some fixes:

- Memory leak fix for palettes, fix for weighted palette
- Better reliability of color reduction in BGRAColorQuantization

And some new features:

- Loading and saving palettes in various formats (Paint.NET, Gimp, Adobe Swatch Exchange, KOffice, Jasc Paint Shop Pro)
- TBGRABitmap.SaveToStreamAs procedure (to specify the format using TBGRAImageFormat enum)

http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.1.zip/download
Title: Re: New version of BGRABitmap
Post by: circular on April 14, 2015, 12:05:48 pm
New version of BGRABitmap (8.2) with two new methods for TBGRABitmap object:
Code: [Select]
    procedure LoadFromDevice(DC: THandle);
    procedure LoadFromDevice(DC: THandle; ARect: TRect);
    procedure TakeScreenshotOfPrimaryMonitor;
    procedure TakeScreenshot(ARect: TRect);

To take a screenshot of a monitor, you can do:
Code: [Select]
bmp.TakeScreenShot(Screen.Monitors[numMonitor].BoundsRect);
To take a screenshot of the whole desktop, you can do:
Code: [Select]
bmp.TakeScreenShot(Screen.DesktopRect);
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.2.zip/download
Title: Re: New version of BGRABitmap
Post by: circular on April 14, 2015, 07:08:27 pm
Quote
There is some challenge here, to do text rendering without LCL. For now, BGRABitmap uses TBitmap to render text.
AggPas accomplishes that without problem. The code is there if you want to take a peek. ;)
Well yes and no. It works if a truetype font file is provided as far as I remember. One could parse the font directory of the system, but that would take some time, and would be complicated to port. And still only TrueType fonts would be handled.

Also BGRABitmap needs UTF8 classes to access files (unit lazutf8classes).
Title: Re: New version of BGRABitmap
Post by: circular on April 15, 2015, 02:44:06 pm
When trying to get BGRABitmap to work with fpGUI, I cannot find the following:
- to get a canvas to draw on a TfpgImage like on a window (this could be used to render text)
- to get an image from any canvas (not essential however)
- to draw data directly from data (opaque or transparent) : this can be achieved of course by creating an image
- to read an icon file (the type TIcon is in LCL)
- average level tree (the unit AvgLvlTree is in LCL)
- reading DOM/XML (the units laz2_DOM, laz2_XMLRead, laz2_XMLWrite are in LCL)

About UTF8 classes, it is ok as there as some functions in FreePascal to do that.

What would you suggest Graeme?
Title: Re: New version of BGRABitmap
Post by: marcov on April 15, 2015, 02:49:46 pm
- average level tree (the unit AvgLvlTree is in LCL)
- reading DOM/XML (the units laz2_DOM, laz2_XMLRead, laz2_XMLWrite are in LCL)

All these are in lazutils for quite a while, which are parts that used to be LCL that are not LCL dependent.

So most logically, use lazutils package.
Title: Re: New version of BGRABitmap
Post by: Graeme on April 15, 2015, 03:59:24 pm
- to get a canvas to draw on a TfpgImage like on a window (this could be used to render text)
fpGUI's TfpgCanvas is not a TFPCustomCanvas descendant and doesn't surface the internal image buffer, so not all functionality is the same as FCL or LCL. Saying that, when I've needed that (probably twice in the last 10 years), I've used  TAggPas to attach to a TfpgImage, do my painting using the AggPas API. Alternatively, I've also used FPImgCanv from FCL, then convert the fpImage to a TfpgImage.

With the fpGUI redesign I'm busy with, where AggPas will become the default reference rendering engine and switching to a single window handle per form (not widget), this should be a lot easier. But the 'develop' branch is not there yet.

Quote
- to get an image from any canvas (not essential however)
Same as the above answer - as a work-around you could Canvas.Pixels[], but probably not the fastest workaround. ;)

Quote
- to draw data directly from data (opaque or transparent) : this can be achieved of course by creating an image
I've always used an image for this. You have direct access to the image data via the TfpgImage.ImageData and .ImageDataSize properties.

Quote
- to read an icon file (the type TIcon is in LCL)
Use FCL's FPImage and convert it to a TfpgImage - I saw no need to reinvent the wheel. See the fpg_imgfmt_png.pas unit for an example.

Quote
About UTF8 classes, it is ok as there as some functions in Free Pascal to do that.
Indeed, fpGUI has supported Unicode (UTF-8) for years without depending on LCL. ;-)  The fpg_utils.pas unit shows how fpGUI accomplishes file access - mostly via the fpgToOSEncoding() and fpgFromOSEncoding() functions.
Title: Re: New version of BGRABitmap
Post by: circular on April 15, 2015, 06:00:30 pm
- average level tree (the unit AvgLvlTree is in LCL)
- reading DOM/XML (the units laz2_DOM, laz2_XMLRead, laz2_XMLWrite are in LCL)

All these are in lazutils for quite a while, which are parts that used to be LCL that are not LCL dependent.

So most logically, use lazutils package.
Thanks. I will try that.

- to get a canvas to draw on a TfpgImage like on a window (this could be used to render text)
fpGUI's TfpgCanvas is not a TFPCustomCanvas descendant and doesn't surface the internal image buffer, so not all functionality is the same as FCL or LCL.
Yes but the operating system provides ways to draw on a window and to draw on a bitmap, so you could provide a TBitmap with a Canvas.

Quote
Quote
- to get an image from any canvas (not essential however)
Same as the above answer - as a work-around you could Canvas.Pixels[], but probably not the fastest workaround. ;)
Nope that would be too slow. So how to retrieve an image, a screenshot, etc. ?

Quote
Quote
- to draw data directly from data (opaque or transparent) : this can be achieved of course by creating an image
I've always used an image for this. You have direct access to the image data via the TfpgImage.ImageData and .ImageDataSize properties.
It is slower than a DIB section because creating the bitmap takes time. Also it seems that the image is always drawn as opaque.

Quote
Quote
- to read an icon file (the type TIcon is in LCL)
Use FCL's FPImage and convert it to a TfpgImage - I saw no need to reinvent the wheel. See the fpg_imgfmt_png.pas unit for an example.
Yes but I would like to provide support for ICO format.
Title: Re: New version of BGRABitmap
Post by: circular on April 15, 2015, 09:54:45 pm
Ok, so using LazUtils, I have AvgLvlTree, XML and some support for FreeType (only for ASCII chars, otherwise it is buggy). So that's kind of working.

Also with DIB section, it would be slightly faster.

Without transparency, only using a mask, there would be two different ways of drawing on a Canvas, either opaque or with 1-bit transparency.

Title: Re: New version of BGRABitmap
Post by: circular on April 16, 2015, 12:59:44 am
Here is a new version of BGRABitmap 8.3 that can be used with fpgui_toolkit. It fixes also a type issue for FreeBSD.

http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.3.zip/download

Here is an example project. First open the following packages: fpgui_toolkit, LazUtils and BGRABitmapPack4fpGui. Then copy "arial.ttf" file in the directory of the project. Finally open the project and run.
Title: Re: New version of BGRABitmap
Post by: VTwin on April 26, 2015, 10:29:26 am
Hello,

I just attempted to upgrade BGRABitmap from 7.9.3 to 8.3.1 and am getting:

Code: [Select]
RunError(211)
I am using code like this:

Code: [Select]
t := TBGRABitmap.Create(fPbx.Width, fPbx.Height, bc); 
...
t.Draw(fPbx.Canvas, 0, 0, False);

to draw into the Canvas of a TPaintBox. It is triggered at this line:

Code: [Select]
function TBGRADefaultBitmap.GetBitmap: TBitmap;
begin
  if FAlphaCorrectionNeeded and CanvasAlphaCorrection then
    LoadFromBitmapIfNeeded;
  if FDataModified or (FBitmap = nil) then
  begin
    RebuildBitmap;
    FDataModified := False; // <-------------------
  end;
  Result := FBitmap;
end;

I'd appreciate any insight on why this is happening. Thanks!

Cheers,
VTwin
Title: Re: New version of BGRABitmap
Post by: circular on April 26, 2015, 01:48:59 pm
Oh I may have forgotten something.

Would it fix the problem to replace "BGRADefaultBitmap" by "BGRALCLBitmap", and "TBGRADefaultBitmap" by "TBGRALCLBitmap" in BGRABitmap.pas ?
Title: Re: New version of BGRABitmap
Post by: circular on April 27, 2015, 12:46:05 am
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!  :)
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 27, 2015, 01:22:24 am
Quote
Here is a new version of BGRABitmap 8.3 that can be used with fpgui_toolkit.

Hello.

Wow, thanks for your demo LCL-fpGUI toolkit and BGRABitmap.  ;)

Hum, do you have plan for Pure-fpGUI toolkit and BGRABitmap ?

Pure fpGUI toolkit is autonomous and does not depend on LCL.
But BGRABitmap has LCL dependencies...

Many thanks.

Fre;D
Title: Re: New version of BGRABitmap
Post by: lainz on April 27, 2015, 01:25:40 am
Nice wiki :)

It looks like the c# declarations for .net source files in visual studio.
Title: Re: New version of BGRABitmap
Post by: circular on April 27, 2015, 01:51:21 am
Quote
Here is a new version of BGRABitmap 8.3 that can be used with fpgui_toolkit.

Hello.

Wow, thanks for your demo LCL-fpGUI toolkit and BGRABitmap.  ;)

Hum, do you have plan for Pure-fpGUI toolkit and BGRABitmap ?

Pure fpGUI toolkit is autonomous and does not depend on LCL.
But BGRABitmap has LCL dependencies...
No no, bgrabitmappack4fpgui does not depend on LCL. It depends on LazUtils, fpgui_toolkit and FCL. And fpgui_toolkit does not depend on LCL.

Nice wiki :)

It looks like the c# declarations for .net source files in visual studio.
Happy you find it nice :)
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 27, 2015, 02:00:26 am
Quote
No no, bgrabitmappack4fpgui does not depend on LCL. It depends on LazUtils, fpgui_toolkit and FCL. And fpgui_toolkit does not depend on LCL.

Ha, perfect but... when trying to compile your fpGUI demo i get that error message =>

BGRABitmapPack4fpGUI needs =>
LazUtils => here error with => Not Found !
fpGUI_toolKit

?

And i cannot compile it...
Title: Re: New version of BGRABitmap
Post by: circular on April 27, 2015, 02:26:58 am
Try the following: in Lazarus, open the packages LazUtils and fpGUI_toolkit, then open BGRABitmapPack4fpGui. Can you compile it then ?
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 27, 2015, 02:35:29 am
Hello and thanks to answer.

I have installed LazUtils from Lazarus 1.2.6.

Now at compil i get that error message :

Quote
paswstring.pas(379,43) Error: Incompatible types: got "<address of procedure(PWideChar;var AnsiString;Int64);Register>" expected "TUnicodeStringManager.<procedure variable type of procedure(PWideChar;var RawByteString;Word;Int64);Register>"

Maybe it is because i use last fpc 3.0.1 ?

Is LazUtils absolutely necessary, does it not exist something else more flexible  ?
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 27, 2015, 02:51:22 am
Quote
Maybe it is because i use last fpc 3.0.1 ?

Yep, with fpc 2.4 it works  ;)

Huh, Circular, what a perfect work you have done.  ;D

It works perfectly and it is pure-fpGUI => incredible.   :o

Where are you with your plan to do a BGRABitmap library ?
If you agree, it will be a pleasure to help you for that.

I am totally impressed  :-X

Hum, the top of the top will be if BGRABitmap was free of LazUtils package. (I never was able to create libraries with LCL dependencies)

Many, many thanks.

Fre;D

PS: In attachment arial.ttf needed for your demo  ;)

Title: Re: New version of BGRABitmap
Post by: VTwin on April 27, 2015, 07:59:49 am
Oh I may have forgotten something.

Would it fix the problem to replace "BGRADefaultBitmap" by "BGRALCLBitmap", and "TBGRADefaultBitmap" by "TBGRALCLBitmap" in BGRABitmap.pas ?

Yes indeed circular, that fixed the problem! Many thanks.

BGRABitmap is fantastic, thanks for all your work on this.

P.S. Maybe we will see the day when BGRAControls will be a complete widget set for Lazarus?  :)

Cheers,
VTwin
Title: Re: New version of BGRABitmap
Post by: circular on April 27, 2015, 12:35:04 pm
Is LazUtils absolutely necessary, does it not exist something else more flexible  ?
It is necessary to render FreeType fonts.

Quote
Maybe it is because i use last fpc 3.0.1 ?
Yep, with fpc 2.4 it works  ;)
I am interested if you have an idea on how to make it work with both compilers. What function has changed?

Quote
Huh, Circular, what a perfect work you have done.  ;D

It works perfectly and it is pure-fpGUI => incredible.   :o
Thanks.  :)

Quote
Where are you with your plan to do a BGRABitmap library ?
If you agree, it will be a pleasure to help you for that.
Of course, you are welcome to help. I am writing the documentation. Basically the tasks consists in adding comments in the source code. Then this is transformed into a beautiful wiki. Would you like to hear more about this task?

BGRABitmap is fantastic, thanks for all your work on this.
You're welcome.

Quote
P.S. Maybe we will see the day when BGRAControls will be a complete widget set for Lazarus?  :)
Ahah maybe.  :D

To be honest I have no idea how to do that.
Title: Re: New version of BGRABitmap
Post by: Graeme on April 27, 2015, 01:15:26 pm
To be honest I have no idea how to do that.
Leave that to me!  ;) I'll make it happen with fpGUI Toolkit, or at least try and make it so the software renderer for fpGUI is configurable at compile time between AggPas and BGRABitmap. If I complete one, the other shouldn't be too difficult to add. [last famous worlds]

Regards,
  Graeme
Title: Re: New version of BGRABitmap
Post by: circular on April 27, 2015, 02:15:35 pm
Ok Graeme.  :)

So it would be possible to customize the appearance of controls with fpGUI? Or do you think about compiling the current BGRAControls with fpGUI?
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 27, 2015, 04:03:41 pm
Quote
I am interested if you have an idea on how to make it work with both compilers. What function has changed?
=>
paswstring.pas(379,43) Error: Incompatible types: got "<address of procedure(PWideChar;var AnsiString;Int64);Register>" expected "TUnicodeStringManager.<procedure variable type of procedure(PWideChar;var RawByteString;Word;Int64);Register>"

Quote
Quote

    Where are you with your plan to do a BGRABitmap library ?
    If you agree, it will be a pleasure to help you for that.

Of course, you are welcome to help. I am writing the documentation. Basically the tasks consists in adding comments in the source code. Then this is transformed into a beautiful wiki. Would you like to hear more about this task?

Hum, i was taking to transform BGRABitmap unit into a library... :-[

Like i did for fpGUIlib => https://github.com/fredvs/fpGUIlib (https://github.com/fredvs/fpGUIlib)
or uoslib => https://github.com/fredvs/uoslib (https://github.com/fredvs/uoslib)

Fre;D
Title: Re: New version of BGRABitmap
Post by: circular on April 27, 2015, 04:52:24 pm
Quote
I am interested if you have an idea on how to make it work with both compilers. What function has changed?
=>
paswstring.pas(379,43) Error: Incompatible types: got "<address of procedure(PWideChar;var AnsiString;Int64);Register>" expected "TUnicodeStringManager.<procedure variable type of procedure(PWideChar;var RawByteString;Word;Int64);Register>"
Yes I saw that in your previous response, but that does not give me a name. Hmm, oh I see, it is a unit in LazUtils. I suppose it is about Ansi2WideMoveProc or Wide2AnsiMoveProc.

Anyway it will probably be updated by someone in the LCL team for future versions.

Quote
Hum, i was taking to transform BGRABitmap unit into a library... :-[

Like i did for fpGUIlib => https://github.com/fredvs/fpGUIlib (https://github.com/fredvs/fpGUIlib)
or uoslib => https://github.com/fredvs/uoslib (https://github.com/fredvs/uoslib)
Ah ok. Well I don't intend to do that for now so I don't need help there. Are you unsure that I would not authorize you to do so? Would it entail something regarding the structure of BGRABitmap?
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 27, 2015, 05:03:17 pm
Quote
Are you unsure that I would not authorize you to do so?
Hum, BGRABitmap is yours, i think normal to ask it to you... :-[

Quote
Would it entail something regarding the structure of BGRABitmap?
Not the global structure but each procedure/function will be adapted if the library is classical native or Java native.
Title: Re: New version of BGRABitmap
Post by: lainz on April 27, 2015, 05:22:58 pm
Quote
Are you unsure that I would not authorize you to do so?
Hum, BGRABitmap is yours, i think normal to ask it to you... :-[

Quote
Would it entail something regarding the structure of BGRABitmap?
Not the global structure but each procedure/function will be adapted if the library is classical native or Java native.

I've started the library some time ago (with circular help), is in bgracontrols package, but left it since I will not use it as is, but if you're interested check it out.
bgracontrols\test\test_bgrabitmap_library test project
bgracontrols\bgra_pascalscript_library the library is based on the bgrabitmap pascal script implementation (that of course is limited to the declared functions in BGRAPascalScript.pas), because that is the name I choose...

I don't know if you have the ability to include the classes like in the bgrabitmap source to get the real power. And also I must ask you If you know if you can get it working with visual studio and c# for example...
Title: Re: New version of BGRABitmap
Post by: Dibo on April 27, 2015, 10:37:27 pm
Just quickly made Windows 7 fpGUI style using BGRABitmap. Antyalias, effects, rounding, everything is working fine. It is amazing. Something is wrong with scrollbars but it is probably my mistake with coordinates. Draw speed seems to be faster than LCL version, probably that it omit Gtk/Qt level and draw directly on X11. Well done circular :)

Suggestion: Missing handy method for color convertion from TfpgColor to TBGRAPixel. For now I need to use fpgColorToRGBTriple and then its RED GREEN BLUE property in BGRA(red, green, blue)

Attached screenshot and source. Tested on Kubuntu 64 bit
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 27, 2015, 11:29:18 pm
Quote
Posted by: 007
I've started the library some time ago (with circular help), is in bgracontrols package, but left it since I will not use it as is, but if you're interested check it out.
bgracontrols\test\test_bgrabitmap_library test project
bgracontrols\bgra_pascalscript_library the library is based on the bgrabitmap pascal script implementation (that of course is limited to the declared functions in BGRAPascalScript.pas), because that is the name I choose...

Ha, ok, you did it like that => using Pascal Script.
I have to study it because i do that way =>

Code: [Select]
library BGRABitmap;
uses
   BGRABitmap
  ,BGRABitmapTypes;

 function getBlue(AColor: TBGRAColor): byte;  cdecl;
  begin
    Result := getBlue(aColor);
  end;

....

exports
   getBlue name 'getblue',
...
begin
end.

Quote
And also I must ask you If you know if you can get it working with visual studio and c# for example...

I am not sure to understand... but if you want to know if a fpc library could be used with other languages =>
Of course fpc libraries work with visual studio programs, Python programs, even Java programs (with some modifs).
All compiler/language that can deal with native libraries can deal with fpc libraries.  ;D

Fre;D
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 28, 2015, 02:07:58 am
Quote
And also I must ask you If you know if you can get it working with visual studio and c# for example...

Hum, i think i understand what you mean...  :-[

If you want a Universal Library, there are some things to take care.

- do not use complicated class as parameters or result (only byte, integer, float, boolean => strings is possible but less easy)
- if complicated custom classes are needed like create a TBGRABitmap => you may use a array of TBGRABitmap declared inside the library. => so the foreign program call a procedure who will increment the array of TBGRABitmap.

Fre;D
Title: Re: New version of BGRABitmap
Post by: lainz on April 28, 2015, 02:24:44 am
Ok. Basically check my code works as you suggested in both comments. With an internal array and these kind of functions.

The code does.not need pascal script but an unit called bgrapascalscript.pas is used to reuse the code in both projects. Check it out. Maybe you want to contribute to this unit direcly we can give you svn access.

Yes, strings are objects in c#. And all unicode of 16 bits.
Edit: here it is, how to pass strings from c# to a lazarus .dll http://forum.lazarus.freepascal.org/index.php/topic,28209.0.html

The question was basically because i'm new to c#. I even did not finish reading the book from the ms website.

Title: Re: New version of BGRABitmap
Post by: circular on April 28, 2015, 07:04:15 am
Just quickly made Windows 7 fpGUI style using BGRABitmap. Antyalias, effects, rounding, everything is working fine. It is amazing. Something is wrong with scrollbars but it is probably my mistake with coordinates. Draw speed seems to be faster than LCL version, probably that it omit Gtk/Qt level and draw directly on X11. Well done circular :)
Wow it looks great Dibo :)

Quote
Suggestion: Missing handy method for color convertion from TfpgColor to TBGRAPixel. For now I need to use fpgColorToRGBTriple and then its RED GREEN BLUE property in BGRA(red, green, blue)
I suppose you can use ColorToBGRA()
Title: Re: New version of BGRABitmap
Post by: lainz on April 28, 2015, 08:32:29 am
Just quickly made Windows 7 fpGUI style using BGRABitmap. Antyalias, effects, rounding, everything is working fine. It is amazing. Something is wrong with scrollbars but it is probably my mistake with coordinates. Draw speed seems to be faster than LCL version, probably that it omit Gtk/Qt level and draw directly on X11. Well done circular :)

Suggestion: Missing handy method for color convertion from TfpgColor to TBGRAPixel. For now I need to use fpgColorToRGBTriple and then its RED GREEN BLUE property in BGRA(red, green, blue)

Attached screenshot and source. Tested on Kubuntu 64 bit

Please upload it to BGRA-Controls!
(Yes, I know, is full of things, but.. you know, people find all the stuff there)
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 28, 2015, 01:02:17 pm
@ 007

Hello.

I have checked your bgra_pascalscript_library.lpr.

Wow, perfect, nice work.  ;)

Some little detail to be more Universal...

Maybe replace all TBGRAColor with longword => example =>
Code: [Select]
function rgb(red, green, blue: byte): longword; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
  begin
    Result := BGRAPascalScript.rgb(red, green, blue);
  end;       
                         

And replace all String with PChar => example =>
Code: [Select]
procedure bgra_SaveToFile(id: integer; filename: PChar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
  begin
    BGRAPascalScript.bgra_SaveToFile(id, filename);
  end;


"_" character in exports-name is interpreted as sub-class in some language (Java,..).
Also, to avoid mangle-name   =>
Code: [Select]
exports
  bgra_GetHighestID name 'bgragethighestid',
   ...   

Fre;D

Title: Re: New version of BGRABitmap
Post by: Graeme on April 28, 2015, 05:13:54 pm
So it would be possible to customize the appearance of controls with fpGUI? Or do you think about compiling the current BGRAControls with fpGUI?
Once done, fpGUI's TfpgCanvas class will use AggPas or BGRAControls to render everything. This is already possible with AggPas, but it needs some more improvements. I also plan to extend the TfpgCanvas class's interface so it is easier to take advantage of the features AggPas and BRGABitmap provides.
Title: Re: New version of BGRABitmap
Post by: lainz on April 28, 2015, 05:49:27 pm
Quote
Maybe replace all TBGRAColor with longword => example =>
Code: [Select]
function rgb(red, green, blue: byte): longword; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
  begin
    Result := BGRAPascalScript.rgb(red, green, blue);
  end;       
   
     

I know that TBGRAColor is an alias, there is a problem on using it? Or is just for readability?                 

Quote
And replace all String with PChar => example =>
Code: [Select]
procedure bgra_SaveToFile(id: integer; filename: PChar); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
  begin
    BGRAPascalScript.bgra_SaveToFile(id, filename);
  end;

I know, the same is for C#. The thing is I will change it with PWideChar, it works too in Java?

Quote
"_" character in exports-name is interpreted as sub-class in some language (Java,..).
Also, to avoid mangle-name   =>
Code: [Select]
exports
  bgra_GetHighestID name 'bgragethighestid',
   ...   

Ok. I will add the name alias as you suggested.

Also I have a question about using enum that in lazarus is something like:
Code: [Select]
TMedianOption = (moNone, moLowSmooth, moMediumSmooth, moHighSmooth);
in c# is like:
Code: [Select]
enum TMedianOption : byte {moNone, moLowSmooth, moMediumSmooth, moHighSmooth};
I supose that lazarus is using the byte enumeration. (I've readed it somewhere?) So they are basically alias to numbers.
moNone is 0 in both languages.

Another thing is if using struct is the same, like records.. TRect...
I've not tested, but I think it is not the same
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 28, 2015, 11:06:47 pm
Quote
The thing is I will change it with PWideChar, it works too in Java?
For a Java native library it is a other story... =>

Code: [Select]
Library javaBGRABitmap;
uses
   Jni,
   BGRABitmap
  ,BGRABitmapTypes;

procedure bgra_SaveToFile(PEnv: PJNIEnv; Obj: JObject; id: integer; filename: JString); {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
  begin
    BGRAPascalScript.bgra_SaveToFile(id, (PEnv^^).GetStringUTFChars(PEnv, filename, nil));

     (PEnv^^).ReleaseStringUTFChars(PEnv, filename, nil);   /// to free memory
  end;
...

exports
bgra_GetHighestID name 'Java_bgra_gethighestid',
...
begin
end.

Quote
So, you will create another library, or want access to keep improving this?
No, no, you did it perfectly, i do not want to create a new one,  i only proposed my help ( i did not knew that you have already done it ).  :-[

Fre;D

Title: Re: New version of BGRABitmap
Post by: lainz on April 28, 2015, 11:59:02 pm
Ok. Well you have sourceforge account? I can give you svn access if you want to help keep improving this.
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 29, 2015, 01:30:47 am
Quote
Well you have sourceforge account?

Yes => fredvs

PS: You may avoid mangle-name problems for all exported methods => those too =>
Code: [Select]
exports
  ...,
  rgb name 'rgb',  // why not => rgb name 'bgrargb' ?
  rgba name 'rgba',
  getBlue name 'getblue',
  getGreen name 'getgreen',
  getRed name 'getred',
  getAlpha name 'getalpha',
  setBlue name 'setblue',
  setGreen name 'setgreen',
  setRed name 'setred',
  setAlpha name 'setalpha',
...
 

Fre;D
Title: Re: New version of BGRABitmap
Post by: lainz on April 29, 2015, 02:13:31 am
Quote
Well you have sourceforge account?

Yes => fredvs

PS: You may avoid mangle-name problems for all exported methods => those too =>
Code: [Select]
exports
  ...,
  rgb name 'rgb',  // why not => rgb name 'bgrargb' ?
  rgba name 'rgba',
  getBlue name 'getblue',
  getGreen name 'getgreen',
  getRed name 'getred',
  getAlpha name 'getalpha',
  setBlue name 'setblue',
  setGreen name 'setgreen',
  setRed name 'setred',
  setAlpha name 'setalpha',
...
 

Fre;D

Added. Add all the stuff you need to work in java and new functions. You have complete access so you can upload files releasing the .dll .so and headers when you want.
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 29, 2015, 02:59:10 am
Quote
Added. Add all the stuff you need to work in java and new functions. You have complete access so you can upload files releasing the .dll .so and headers when you want.

 :) OK, thanks.

PS : I do not see problems to modify it to have a Java native library.
PS2: But i do not really see how to use BGRABitmap library in Java (with what Java-widgetset or Java-canvas ?).

Fre;D
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 29, 2015, 03:16:29 am
Quote
uses
  Interfaces,

Huh, you use Interfaces...

Im not sure it will work with Interfaces  :-X

I will try (but every time i have try to use Interfaces in library... i loosed).

Fre;D
Title: Re: New version of BGRABitmap
Post by: lainz on April 29, 2015, 03:19:03 am
I dont know.. also i have the same problem with c# (no idea of c# graphics at all, i know that xamarin studio uses gtk and visual studio the windows native stuff)..

ok... i have no idea right now im not in the code pc but try removing it and see what happens.
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 29, 2015, 03:25:41 am
Quote
I dont know.. also i have the same problem with c# (no idea of c# graphics at all, i know that xamarin studio uses gtk and visual studio the windows native stuff)..

ok... i have no idea right now im not in the code pc but try removing it and see what happens.

I have to jump into your code and study BGRABitmap.
And then see how to use BGRABitmap with Java.
=> on TODO list => ASAP.

Fre;D


Title: Re: New version of BGRABitmap
Post by: lainz on April 29, 2015, 03:31:11 am
Ok. I also dont know fully bgrabitmap, im just another contributor  :)

I will try to finish adding the filters so at least we have a dll to apply filters to bitmaps.

If you can just make it works as is now with java will be ok too.
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 29, 2015, 03:41:33 am
Quote
If you can just make it works as is now with java will be ok too.

Ok, i will try (but i would prefer without Interfaces  :-X )
Title: Re: New version of BGRABitmap
Post by: lainz on April 29, 2015, 03:48:50 am
removed interfaces and working.

if you need add "ifdef java" or something like that if needed or just make a copy of the library in a new folder. also if you can include the header you make.
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 29, 2015, 03:52:35 am
Quote
removed interfaces and working.

Ha, ok, perfect  ;D

I will try it tomorrow  ;)

Fre;D
Title: Re: New version of BGRABitmap
Post by: Fred vS on April 29, 2015, 01:15:57 pm
@ 007 =>

Trying to compile your bgra_pascalscript_library.lpr with Linux 64 bit =>
Quote
.../bgrabitmap/bgragtkbitmap.pas(191,24) Error: Identifier not found "TBGRAPtrBitmap"
=>

Added in uses section of BGRAGtkBitmap => bgradefaultbitmap => now it compiles but at linking =>
Quote
/usr/bin/ld: ../bgrabitmap/lib/x86_64-linux/2.6.4/bgrabitmaptypes.o: relocation R_X86_64_32S against `TC_BGRABITMAPTYPES_RESAMPLEFILTERSTR' can not be used when making a shared object; recompile with -fPIC

=> Have try to compile with -fPIC parameter but same error.   %)

=> Aaargh,  bgra_pascalscript_library.lpr needs LCL => I knew it will be problems for library  :-X



So i left (temporally) Linux and have try to compile on Windows (via wine) => ok, it works.  ;D

PS: Windows is not my workshop OS, i would highly prefer to first develop bgrabitmap java library in Linux then cross-compil (or compil via wine) to Windows .

So to test the Java library I must install Windows on Virtual Box (and all the fpc + Java stuffs) and work on bgrabitmap java library this way (but it is not my funniest way to develop)  :( .

PS2:  Have you try to compile your bgra_pascalscript_library.lpr in Linux 64 ? If yes, how did you do it ?

Thanks.

Fre;D
Title: Re: New version of BGRABitmap
Post by: lainz 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.
Title: Re: New version of BGRABitmap
Post by: Fred vS 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  :-[
Title: Re: New version of BGRABitmap
Post by: lainz 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"
Title: Re: New version of BGRABitmap
Post by: circular on April 29, 2015, 05:32:19 pm
Hello!

I am going to see what is happening on Linux...
Title: Re: New version of BGRABitmap
Post by: circular 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
Title: Re: New version of BGRABitmap
Post by: circular 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;
Title: Re: New version of BGRABitmap
Post by: lainz on April 29, 2015, 06:16:11 pm
This is insane!
You ever sleep?
Title: Re: New version of BGRABitmap
Post by: circular 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.
Title: Re: New version of BGRABitmap
Post by: lainz 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;
Title: Re: New version of BGRABitmap
Post by: circular 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;
Title: Re: New version of BGRABitmap
Post by: lainz 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.
Title: Re: New version of BGRABitmap
Post by: aradeonas 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  ;)
Title: Re: New version of BGRABitmap
Post by: circular 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.  :)
Title: Re: New version of BGRABitmap
Post by: aradeonas 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.
Title: Re: New version of BGRABitmap
Post by: circular 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.
Title: Re: New version of BGRABitmap
Post by: circular on May 01, 2015, 01:46:00 am
Here is a new version of BGRABitmap 8.5.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.5.zip/download

There is no new feature, but it can be compiled for:
- LCL (as before)
- fpGUI (as with 8.4, and the color swap is fixed for TColor type)
- without GUI

Three packages are available, one for each.

Basic tests are provided here:
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap_basic_test.zip/download
Title: Re: New version of BGRABitmap
Post by: lainz on May 01, 2015, 05:15:52 am
Edit: it's me or the nogui version has dependencies that are not neccesary? at least under windows I removed all dependencies except LazUtils from that package and compiled fine...

---

For example I think the bgrabitmap library .dll doesn't need the GUI, but I need fpGUI toolkit to use the nogui package.

Also the bgrapascalscript.pas is inside bgracontrols that requiers bgrabitmappack...

I've changed the library: removed bgracontrols as dependency, added the relative path to bgrapascalscript.pas and added the nogui package of bgrabitmap.

The size trimmed about 240kb.

So it's a good option to save size, at least some.
Title: Re: New version of BGRABitmap
Post by: circular on May 01, 2015, 09:53:40 am
Oh you are right. Not exactly sure what happened, but yes, it is possible to remove fpGUI dependency of course.

Fixed in version 8.5.1.

Yes, without GUI, it is slightly smaller, you don't need to have the package fpGUI and also, with fpGUI the format of TColor is reversed: clBlue has the value of $0000FF whereas with LCL and no GUI it has the value of $FF0000.
Title: Re: New version of BGRABitmap
Post by: lainz on May 01, 2015, 01:25:16 pm
Ok it's working.
Title: Re: New version of BGRABitmap
Post by: VTwin on May 02, 2015, 07:52:14 am
To be honest I have no idea how to do that.
Leave that to me!  ;) I'll make it happen with fpGUI Toolkit, or at least try and make it so the software renderer for fpGUI is configurable at compile time between AggPas and BGRABitmap. If I complete one, the other shouldn't be too difficult to add. [last famous worlds]

Regards,
  Graeme

This sounds very exciting, but would it require X11 on OS X? The Cocoa interface is not yet ready, luckily Yosemite still supports Carbon. I think many of us wonder what happens when Apple finally pulls the plug on Carbon. QT I suppose, but it would be very cool to have a cross platform BGRABitmap widget set for Lazarus.

Cheers,
VTwin

     
Title: Re: New version of BGRABitmap
Post by: Fred vS on May 02, 2015, 12:09:41 pm
Quote
but it would be very cool to have a cross platform BGRABitmap widget set for Lazarus.

Hmm, it exists already.
In new release of BGRABitmap you may use BGRABitmap with pure-fpGUI widgetset.
Title: Re: New version of BGRABitmap
Post by: VTwin on May 02, 2015, 01:11:08 pm
 Very cool!!

I guess that is in bgrabitmap_basic_test? I didn't follow all the discussion. I will see if I can make it work.

VTwin
Title: Re: New version of BGRABitmap
Post by: Fred vS on May 02, 2015, 03:09:28 pm
@ Circular.

Hello  :)

I have checked all the files of BGRABitmap package and none does mention of your name nor that it is part of BGRABitmap.

Please, to avoid problems, could you add something like that at begin of each file ? =>

Quote
{ This file is part of BGRABitmap, drawing routines with alpha blending and antialiasing. These routines allow to manipulate 32bit images in BGRA format.

This code is under modified LGPL (see COPYING.modifiedLGPL.txt). This means that you can link this library inside your programs for any purpose. Only the included part of the code must remain LGPL.

If you make some improvements to this library, please notify here:
http://www.lazarus.freepascal.org/index.php/topic,12037.0.html

Contact : circular at operamail.com }

Idem for BGRAControls.

PS . Now, because of BGRABitmap library, you will interest not only the gentle people of fpc.  :-\
PS2: I encourage strongly all other Open-Source developers to do the same.  ;)

Fre;D

Title: Re: New version of BGRABitmap
Post by: lainz on May 02, 2015, 03:32:24 pm
Hi, why this is related with Code Typhoon thing? :) Too much posting in this forum. I must take a break.
Title: Re: New version of BGRABitmap
Post by: Fred vS on May 02, 2015, 05:53:29 pm
Quote
Hi, why this is related with Code Typhoon thing

No, but it is better for everybody to know it when using it.  :-X
Title: Re: New version of BGRABitmap
Post by: lainz on May 02, 2015, 10:58:43 pm
Quote
Hi, why this is related with Code Typhoon thing

No, but it is better for everybody to know it when using it.  :-X

Ok I did it for BGRA-Controls.
Title: Re: New version of BGRABitmap
Post by: circular on May 06, 2015, 06:00:07 pm
New version 8.5.2 of BGRABitmap:
- compilation fix for Qt
- compilation fix for Archlinux 64-bit
Title: Re: New version of BGRABitmap
Post by: circular on May 23, 2015, 12:55:36 am
Hello people!

New version of BGRABitmap 8.6, with support for OpenGL.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.6.zip/download

There are different packages depending on what you want to use :
- BGRABitmapPack4LCL_OpenGL: to be used with an LCL form and LazOpenGLContext
- BGRABitmapPack4NoGUI_OpenGL: to be used without the LCL for example with ZenGL

Note: for ZenGL, there is a specific unit BGRAZenGL that must be linked directly to the program, for example by copying it to the ZenGL source folder and adding it to the Uses clause.

For all the other cases, there is a unit BGRAOpenGL that is included in the package.

Features

TBGLBitmap: an version of TBGRABitmap that provides a Texture property (see IBGLTexture)
IBGLTexture: an OpenGL texture, that can be drawn in the current OpenGL context, with stretch/rotation/color effect
TBGLSprite: a sprite that stores a texture that can be used with the sprite engine (BGLSpriteEngine). To free a sprite, call QueryDestroy and it will be freed on the next timer function of the sprite engine

BGLSpriteEngine: can draw all the sprites, call their timer function, and free all the sprites (so you don't need to call each free function for each sprite)

BGLViewPort: sets the matrix to match the view port pixel coordinates

Here is a sample project that uses the package LazOpenGLContext.
Title: Re: New version of BGRABitmap
Post by: aradeonas on May 23, 2015, 10:23:10 am
Quote
Please stay close to me!
I love this part!

As always you made great thing quickly!

circular I think you should add demos like it in BGRABitmap folder or elsewhere in SourceForge,Its very good.

Thanks
Title: Re: New version of BGRABitmap
Post by: circular on May 23, 2015, 12:39:59 pm
Thank you  :)

I've added it in bgrabitmap\test4lcl_opengl and as a zip file bgrabitmap_test4lcl_opengl.zip.

Here is also a test for ZenGL in a zip file bgrabitmap_test4zengl.zip.
https://sourceforge.net/projects/lazpaint/files/src/
Title: Re: New version of BGRABitmap
Post by: lainz on May 26, 2015, 02:24:45 pm
Nice! It's possible to have a BGRAVirtualScreen but something like BGRAOpenGLScreen?
Title: Re: New version of BGRABitmap
Post by: circular on May 26, 2015, 06:09:18 pm
It is a good idea. I have started to develop a canvas for OpenGL in the same style as TBGRABitmap. For now, I found how to provide aliased functions. Doing direct antialiasing seems impossible, except maybe using multisampling. So basically all functions would be like Ellipse, Rectangle, etc. with floating point coordinates, but rendered without antialising.

The antialiasing would be possible with a multisample property of the BGRAOpenGLScreen. So that would not be an antialiasing as nice as TBGRABitmap, but still better than nothing. I don't know yet how far I can get with that.
Title: Re: New version of BGRABitmap
Post by: lainz on May 26, 2015, 09:26:22 pm
Ok, keep going ;)

With this I can upgrade my game that just uses bitmaps and improve the rendering speed / FPS a lot right?
Title: Re: New version of BGRABitmap
Post by: circular on May 26, 2015, 09:28:51 pm
Absolutely.  :)

If there are a few sprites, you can easily get 200 frames per second. So definitely you can do a lot of things in one frame until you get to 60 frames per second.
Title: Re: New version of BGRABitmap
Post by: lainz on May 26, 2015, 10:11:17 pm
Ok!

Now I can't install BGRABitmap:

Code: [Select]
bgrafreetype.pas(124,15) Error: There is no method in an ancestor class to be overridden: "TBGRAFreeTypeDrawer.DrawGlyph(LongInt,TFreeTypeRenderableFont,Single,Single,TFPColor);"
If I remove the override thing, there are other errors:

Code: [Select]
bgrafreetype.pas(566,7) Error: identifier idents no member "RenderGlyph"
bgrafreetype.pas(568,7) Error: identifier idents no member "RenderGlyph"
bgrafreetype.pas(581,54) Error: Incompatible type for arg no. 5: Got "TFPColor", expected "TBGRAPixel"

Both $IFDEF BGRABITMAP_USE_LCL12 and $IFDEF BGRABITMAP_USE_LCL15 are enabled in Lazarus 1.4.0 32-bits.

So, I removed "use bgrafreetype" unit in package and compiled.
Title: Re: New version of BGRABitmap
Post by: Dick Maley on May 27, 2015, 01:03:12 am
I am trying to build "bgracontrols.lpk".

It throws an error in "BCToolBar.pas".

The error is:
bctoolbar.pas(84,10) Error: identifier idents no member "HorizLine"

All code is newly downloaded.

Why am I getting this error?

Thank you.

Dick Maley



Title: Re: New version of BGRABitmap
Post by: circular on May 27, 2015, 10:38:05 pm
Hi 007!

Ah yes, there are compilation options in bgrabitmap.inc so that it is possible deactivate some features depending on the version. I noticed that testing version using LCL_FULLVERSION was not working so I've put directives in this file.

I guess most people have Lazarus 1.4 or lower, so I changed those directives so that by default functions of Lazarus 1.5 are not used.
Title: Re: New version of BGRABitmap
Post by: lainz on May 28, 2015, 05:43:04 pm
Hi 007!

Ah yes, there are compilation options in bgrabitmap.inc so that it is possible deactivate some features depending on the version. I noticed that testing version using LCL_FULLVERSION was not working so I've put directives in this file.

I guess most people have Lazarus 1.4 or lower, so I changed those directives so that by default functions of Lazarus 1.5 are not used.

Ok thanks!

I am trying to build "bgracontrols.lpk".

It throws an error in "BCToolBar.pas".

The error is:
bctoolbar.pas(84,10) Error: identifier idents no member "HorizLine"

All code is newly downloaded.

Why am I getting this error?

Thank you.

Dick Maley

What's your OS and Lazarus version, BGRABitmap version, BGRAControls version?

Here is working under Windows and Lazarus 1.4, BGRABitmap and BGRAControls trunk.
Title: Re: New version of BGRABitmap
Post by: Josh on June 09, 2015, 08:38:40 am
Hi Circular,

Not sure if this is a Bug/Problem.

I have just upgraded to 8.6 and now I am having a problem with TBCLabel.
If I have background style set to bbsClear, and no caption the tbclabel background goes black, if caption is set then TBCLabel Background is correct.
If you set the Border to bboSolid, it display correctly. Setting to bboNone it display wrong.

Only happened when Upgraded to 8.6.
I have attached lpi,unit and lfm.

Another problem which is not so easy to replicate, is that after upgrade on a project that uses TBGRAShape, i was getting a black background color; when Fill Opacity is set at 0 (obscuring the underlying image), If I set this to 1, then I can see the underlying image as required.

I suspect other controls maybe effected.

Going back to 8.5.2 all is ok.

Bgracontrols 3.6

Title: Re: New version of BGRABitmap
Post by: circular on June 10, 2015, 12:41:56 am
@josh:
Does it solve the problem to add in the unit BGRAWinBitmap the line
Quote
if Empty then exit;
in the procedure TBGRAWinBitmap.Draw, in the following block:
Quote
else
  begin
    if Empty then exit; //add here
    if LineOrder = riloTopToBottom then VerticalFlip;
    LoadFromBitmapIfNeeded;
    ACanvas.StretchDraw(Rect, Bitmap);
    if LineOrder = riloTopToBottom then VerticalFlip;
  end;
?
Title: Re: New version of BGRABitmap
Post by: Josh on June 10, 2015, 06:55:46 am
Hi Circular

I have done a quick test, and it appears to solve the problem with tbclabel.

AFter I made the  change, I clean and built (delete all) the project I attached, the IDE form had not updated, but the exe file has changed.
If I copy Paste the tbclabel on the form and set caption to blank, the new label does update. But the Existing one does not.
Hope that makes sense.

So yes the exe is now fine, which is the main concern.

Cheers
Josh

Title: Re: New version of BGRABitmap
Post by: lainz on June 10, 2015, 07:08:17 am
Hi Circular

I have done a quick test, and it appears to solve the problem with tbclabel.

AFter I made the  change, I clean and built (delete all) the project I attached, the IDE form had not updated, but the exe file has changed.
If I copy Paste the tbclabel on the form and set caption to blank, the new label does update. But the Existing one does not.
Hope that makes sense.

So yes the exe is now fine, which is the main concern.

Cheers
Josh

Try deleting all the lib folders from bgrabitmap, bgracontrols and your project and build the ide again.
Title: Re: New version of BGRABitmap
Post by: Josh on June 10, 2015, 08:53:38 am
Hi
I have tried deleting lib folders, rebuilding ide, clean up and delete project.
The problem is in the IDE,
the compiled exe is fine.
I was going to upload a 3MB video showing the issue, however the forum will not allow this.

It is probably something I have done/not done :)
Title: Re: New version of BGRABitmap
Post by: circular on June 10, 2015, 10:16:42 am
I had a similar problem, solved by going in the BGRABitmap package, and doing "Clean and recompile". Then running/recompiling the IDE would work well.
Title: Re: New version of BGRABitmap
Post by: Josh on June 10, 2015, 07:35:10 pm
Hi Circular,

Yes that done the trick.

Thanks for your and 007's prompt response.
Title: Re: New version of BGRABitmap
Post by: circular on June 11, 2015, 02:29:50 pm
Here is a version 8.6.2 that fixes what we just talked about, i.e., not to draw an empty bitmap on Windows.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.6.2.zip/download
Title: Re: New version of BGRABitmap
Post by: lainz on June 12, 2015, 05:33:27 am
Thanks!
Title: Re: New version of BGRABitmap
Post by: circular on June 23, 2015, 11:14:04 am
New version of BGRABitmap 8.7.
http://sourceforge.net/projects/lazpaint/files/src/bgrabitmap8.7.zip/download

What's new with OpenGL:
- BGLCanvas: a canvas for OpenGL surface. It provides basic features: aliased drawing, with convex polygons and solid pen of width 1. It also handles rectangular clipping, sprites and linear color gradients (through parameters definining vertices colors).
- TBGLPath: a path that can be drawn on the OpenGL surface (with current limitations: solid color and pen of width 1)
- IBGLTexture now has a ResampleFilter property that can be either orfBox (no interpolation) or orfLinear (linear interpolation)
- property TBGLBitmap.MaxTextureSize that returns the maximum size allowed by OpenGL for textures (first instantiate an empty TBGLBitmap, then check this value, then resize to the desired size)

Other:
- added Arc and Pie functions to TBGRABitmap
- slight optimization of CheckEmpty function

 :)
Title: Re: New version of BGRABitmap
Post by: aradeonas on June 23, 2015, 01:29:24 pm
BGRABitmap is the big reason that I like developing with Lazarus.Thank you circular ;)
When you think we have a chance to render big bitmaps smoothly as needed in projects like the other one we talk about before?
Title: Re: New version of BGRABitmap
Post by: Roland57 on June 23, 2015, 03:29:58 pm
Congratulations!
Title: Re: New version of BGRABitmap
Post by: circular on June 23, 2015, 09:16:01 pm
I appreciate you appreciate  :)

@aradeonas: Well, for big pictures, it is possible to do a class that splits an image into a series of textures. This would not be too complicated as long as there are no affine transformations, because in that case, the borders of the textures might appear with pixel artefacts.
Title: Re: New version of BGRABitmap
Post by: aradeonas on June 23, 2015, 09:23:02 pm
Sometimes I need to change all screen and splinting into series may not increasing speed as needed as discussed project.
Its a question for me in some apps how they do such things or browsers with high speed render for java scripts.

Anyway BGRABitmap is the loveliest library I even use in Pascal.
Title: Re: New version of BGRABitmap
Post by: circular on June 23, 2015, 11:52:48 pm
Oh I see what you mean.

I guess they use the drivers that are provided by the system, which relies on hardware acceleration. For example, there is hardware scrolling, so that only the parts that were hidden need to be redrawn. You could maybe do that with a scrollbox component.
Title: Re: New version of BGRABitmap
Post by: aradeonas on June 24, 2015, 07:56:28 am
Yes we can do that,I done that one time for a map project but problem is still there for the project we talked about,projects that need a FullHD render without big delay.
I bring the project as example because it is in my head and doesn't go away ;)
Title: Re: New version of BGRABitmap
Post by: circular on June 24, 2015, 02:47:07 pm
Have you an example of an application that has fast full HD render?
Title: Re: New version of BGRABitmap
Post by: aradeonas on June 24, 2015, 04:58:56 pm
Maybe.That project I emailed you not a FullHD render but with even splitting its not good enough and it made me question how I can draw rapidly as some apps.
Title: Re: New version of BGRABitmap
Post by: lainz on July 02, 2015, 02:42:19 pm
Hi, this is a small suggestion: Add LoadFromResourceName like TPicture has for BGRABitmap. Also a Create(Instance...).. Is easier than ever now to store the resources with the IDE in the project options (Or that option was always there and I just noticed that recently? =) Well, no more dealing with .res or .rc files by hand.

Maybe this can be added as IBGLTexture list of constructor functions too.

There are other interesting methods in TPicture like LoadFromClipboardFormat, LoadFromLazarusResource and SaveToClipboardFormat that maybe you're interested to add too.

Maybe you already know it using it in lazpaint or other projects, is just as:

Code: [Select]
uses
  LCLType

procedure TBCCustomImageButton.LoadFromBitmapResource(Resource: string; ResourceType: PChar);
var
  res: TResourceStream;
begin
  res := TResourceStream.Create(HInstance, Resource, ResourceType);

  if BitmapOptions.Bitmap <> nil then
    BitmapOptions.Bitmap.Free;

  BitmapOptions.Bitmap := TBGRABitmap.Create(res);
  res.Free;
end;     

I don't know if the ResourceType will be other than RT_RCDATA.
Title: Re: New version of BGRABitmap
Post by: circular on July 02, 2015, 07:49:48 pm
Yes, that's a good idea.
Title: Re: New version of BGRABitmap
Post by: lainz on July 03, 2015, 07:50:50 pm
Yes, that's a good idea.

Well, is just a small idea. Thanks for the big idea BGRA ! :)
Title: Re: New version of BGRABitmap
Post by: lainz on July 09, 2015, 05:49:04 pm
Hi,

BGRABitmap latest repository SVN mirror is now on GitHub
https://github.com/bgrabitmap/lazpaint/
Title: Re: New version of BGRABitmap
Post by: circular on July 09, 2015, 07:58:54 pm
Cool!

In fact, Git is great when you have multiple branches on the same project. I discovered that with SourceTree.
Title: Re: New version of BGRABitmap
Post by: lainz on July 09, 2015, 09:30:44 pm
Ok.

In this case is just a mirror for convenience. I've created this some years ago but just remember today that I must update it ;)

But I follow some projects that has branches and that feature is really cool.
Title: Re: New version of BGRABitmap
Post by: exdatis on July 10, 2015, 07:39:15 am
Thanks!
Title: Re: New version of BGRABitmap
Post by: circular on July 11, 2015, 05:36:23 pm
Hello!

I have included the examples with the latest version of BGRABitmap (8.7). That makes it easier to download if you are using zip files.

I have found some way to reduce the file size to 1MB only by reducing the size of icons and images and merging two folders.

Enjoy!
Title: Re: New version of BGRABitmap
Post by: lainz on July 12, 2015, 04:42:06 am
What do you think about doing a graphics contest with BGRABitmap?
With categories like:
- UI Design: Includes creating a control or just UI elements.
- Photo manipulation: Editing photos by code, creating custom filters and so on.
- Generated textures: Creating textures by code.
Everyone can send their application. Only one participation per category. Requisite is using BGRABitmap only. Time until a month of the day of started the contest, for example.
The decision of the best project is up to you or one or more users. Or can be done with a poll.
And the winner.. wins ;)
Everything made in the contest will be stored in a public repository so everyone gets benefit of this contest.
And finally we can upload a YouTUBE video with all the stuff. If this works we can do it monthly.
Title: Re: New version of BGRABitmap
Post by: aradeonas on July 12, 2015, 06:38:07 am
I liked it so much,it can be very good and also fun but I think it will better with more categories.
Title: Re: New version of BGRABitmap
Post by: circular on July 12, 2015, 11:04:28 am
It sounds good from the begining to the end.  :)

Doing it every month, hmm, I am not convinced there will be enough people for that!

Hmm what are categories for? To make it easier to compare?
Title: Re: New version of BGRABitmap
Post by: lainz on July 12, 2015, 11:39:12 am
It sounds good from the begining to the end.  :)

Nice!

Doing it every month, hmm, I am not convinced there will be enough people for that!

In fact it can be any time or when an ammount of people is reached.

Hmm what are categories for? To make it easier to compare?

Yes for that. There is a winner for each category. We compare the same kind of content. But can be a single one, it does not matter too much.
Title: Re: New version of BGRABitmap
Post by: aradeonas on July 12, 2015, 01:08:55 pm
It could have all categories winner too.
Although I think we need a first run for estimation.
Title: Re: New version of BGRABitmap
Post by: lainz on July 12, 2015, 01:26:55 pm
It could have all categories winner too.
Although I think we need a first run for estimation.

Good idea. Well I think circular must make the thread and be the jury. But if he wants to participate a poll will be required.

I want to participate too :)
Title: Re: New version of BGRABitmap
Post by: aradeonas on July 12, 2015, 01:54:47 pm
Yes I want to participate too,I have ideas for it ;)
Title: Re: New version of BGRABitmap
Post by: circular on July 12, 2015, 02:36:00 pm
I would prefer a poll, that would be more democratic.  8-)

I guess we can suggest categories but let people do what they want. And in the end, we can consider multiple winners.

Does that sound good?

What time do we let for people to do their software? One month? That would be up to the 12th of august. Two month? That would be up to the 12th of september? Maybe people do other things in september and would could say up to the 31th of august.
Title: Re: New version of BGRABitmap
Post by: aradeonas on July 12, 2015, 03:46:06 pm
I think one month for example up to 13th august is a good start,after that when people wants more time then you can decide but one month is long enough I think.
Title: Re: New version of BGRABitmap
Post by: lainz on July 12, 2015, 07:32:57 pm
I would prefer a poll, that would be more democratic.  8-)
Ok.

I guess we can suggest categories but let people do what they want. And in the end, we can consider multiple winners.
Ok. The last thing is if we can upload only one or multiple software. For example If I choose to make an UI and a Photo manipulation, I can upload both or I must choose one? (for that was the main idea of categories, to participate in different ways).

Edit: maybe is ok, put the categories and just let the participants do what they want, and limit the number of submitted works to 2 per participant. For example..

What time do we let for people to do their software? One month? That would be up to the 12th of august. Two month? That would be up to the 12th of september? Maybe people do other things in september and would could say up to the 31th of august.

I think one month for example up to 13th august is a good start,after that when people wants more time then you can decide but one month is long enough I think.

Just create the thread now. The rest are details that can be finished on the go. No one will be angry for that :)
Title: Re: New version of BGRABitmap
Post by: circular on July 12, 2015, 09:47:09 pm
Ok.

Here is the thread: http://forum.lazarus.freepascal.org/index.php/topic,29038.0.html

 :)
Title: Re: New version of BGRABitmap
Post by: lainz on July 12, 2015, 10:45:55 pm
Ok.

Here is the thread: http://forum.lazarus.freepascal.org/index.php/topic,29038.0.html

 :)

Nice!
Please everyone get in! No matter how good you are (i'm like a noob, just an user). This will be a richer experience with more people participating in the BGRABitmap graphic contest!
Title: Re: New version of BGRABitmap
Post by: aradeonas on July 13, 2015, 12:37:14 am
Yes BGRABitmap is unique and sure it will help all.
Title: Re: New version of BGRABitmap
Post by: circular on March 11, 2016, 06:54:43 pm
New version of BGRABitmap (8.8.2).

Download location:
https://sourceforge.net/projects/lazpaint/files/src/

What's new compared to version 8.8 regarding OpenGL:

Other new things:

Example of usage of DomantColor:
Code: Delphi  [Select][+][-]
  1. uses BGRAColorQuantization;
  2.  
  3. function GetDominantColor(ABitmap: TBGRABitmap): TBGRAPixel;
  4. var quant: TBGRAColorQuantizer;
  5. begin
  6.   quant := TBGRAColorQuantizer.Create(ABitmap, acIgnore, 16);
  7.   result := quant.DominantColor;
  8.   quant.Free;
  9. end;  

Example of gradient dithering:
Code: Delphi  [Select][+][-]
  1.     uses BGRABitmap, BGRABitmapTypes;
  2.      
  3.     { TForm1 }
  4.      
  5.     procedure TForm1.FormPaint(Sender: TObject);
  6.     begin
  7.       with TBGRABitmap.Create(ClientWidth,ClientHeight) do
  8.       begin
  9.         GradientFill(0,0,Width,Height div 2, BGRA(80,80,80),BGRA(140,140,140),gtLinear,
  10.                                        PointF(0,0),PointF(Width,0),
  11.                                        dmSet,true,False,daFloydSteinberg);
  12.         GradientFill(0,Height div 2,Width,Height, BGRA(80,80,80),BGRA(140,140,140),gtLinear,
  13.                                        PointF(0,0),PointF(Width,0),
  14.                                        dmSet,true,False,daNearestNeighbor);
  15.         Draw(self.Canvas, 0,0);
  16.         Free;
  17.       end;
  18.     end;  
Title: Re: New version of BGRABitmap
Post by: aradeonas on March 11, 2016, 08:35:18 pm
Good news for me.
Thanks Circular.
Title: Re: New version of BGRABitmap
Post by: wp on March 11, 2016, 11:55:44 pm
The new version does not compile with Laz trunk/fpc3.0 (it does with 1.6/3.0). The issues are in unit BGRAUTF8, the compiler complains about
Quote
bgrautf8.pas(91,22) Error: Identifier not found "UTF8ToSys"
bgrautf8.pas(96,22) Error: Identifier not found "SysToUTF8"
bgrautf8.pas(121,22) Error: Identifier not found "FileOpenUTF8"
bgrautf8.pas(126,22) Error: Identifier not found "FileCreateUTF8"
bgrautf8.pas(131,22) Error: Identifier not found "FileCreateUTF8"
bgrautf8.pas(136,22) Error: Identifier not found "FileExistsUTF8"
bgrautf8.pas(142,22) Error: Identifier not found "FindFirstUTF8"
bgrautf8.pas(147,22) Error: Identifier not found "FindNextUTF8"
bgrautf8.pas(152,12) Error: Identifier not found "FindCloseUTF8"

Title: Re: New version of BGRABitmap
Post by: circular on March 13, 2016, 12:52:41 am
Hmmm... those functions have been removed?
Title: Re: New version of BGRABitmap
Post by: wp on March 13, 2016, 01:30:18 am
They are in LazFileUtils, LazUtf8, and maybe some other units of the LazUtils package (see Juha's mail to the mailing list of July 7 2015). There were wrappers all the time with "deprecated" warnings, but they were disabled recently.
Title: Re: New version of BGRABitmap
Post by: circular on March 13, 2016, 09:20:34 am
Ok. I made wrappers in BGRAUTF8 to make it easier to adapt this code. I wanted to avoid redundant code as those functions were already defined.

Does it solve the problem to add
{$UNDEF BGRABITMAP_USE_LCL}

after
{$i bgrabitmap.inc}

?
Title: Re: New version of BGRABitmap
Post by: wp on March 13, 2016, 10:05:29 am
Yes, it compiles with BGRABITMAP_USE_LCL undefined, of course - but then some of the available functions are duplicated. Instead, I used LazFileUtils and LazUtf8 instead of FileUtil and LCLProc (see attached zipped unit), and now BGRABitmapPack compiles with Laz trunk, 1.6, all 1.4, and even 1.2.
Title: Re: New version of BGRABitmap
Post by: JuhaManninen on March 13, 2016, 10:15:04 am
They are in LazFileUtils, LazUtf8, and maybe some other units of the LazUtils package (see Juha's mail to the mailing list of July 7 2015). There were wrappers all the time with "deprecated" warnings, but they were disabled recently.

You can still use the wrappers by defining "EnableWrapperFunctions" but I don't recommend it. The functions will give deprecated warnings and later you must fix it properly anyway. Just use the right units, it is not a big change.
Title: Re: New version of BGRABitmap
Post by: circular on March 13, 2016, 10:37:24 am
Oh ok. I was not aware of that.

I updated on SVN and replaced the zip file with the fix.
Title: Re: New version of BGRABitmap
Post by: lainz on March 19, 2016, 08:36:51 pm
I've updated GitHub mirror of BGRABitmap\lazpaint. Other repos like bgracontest, bgracontrols, bgragames already updated, uecontrols maybe outdated.

https://github.com/bgrabitmap
Title: Re: New version of BGRABitmap
Post by: circular on March 19, 2016, 10:28:44 pm
Thanks!  :)
Title: Re: New version of BGRABitmap
Post by: VTwin on March 26, 2016, 03:17:55 pm
Thanks for your fantastic work on this circular!

I just ran through some of the demos in 8.8.2 and it is very impressive. The bspline demo is very helpful to see the effect of the options.

So far the only issue I see on OS X is the text display. I'm using the workaround from Zittergie:

http://forum.lazarus.freepascal.org/index.php/topic,29064.0.html

In bgrapixel.inc:

Code: Pascal  [Select][+][-]
  1.  (*
  2.  {$IFDEF DARWIN}
  3.     {$DEFINE BGRABITMAP_RGBAPIXEL}
  4.  {$ENDIF}
  5.  *)    
  6.  

Maybe an OS X guru here can help track this down.

Cheers,
VTwin


Title: Re: New version of BGRABitmap
Post by: circular on April 01, 2016, 05:15:39 pm
Hmmm so the text is still not displayed  :'(

The thing is that not using RGBA order for MacOS is slower, as it requires to swap red and blue each time an image is drawn on the screen. So it would be great to have some help from an OS X guru.

In the meantime, here is a new version 8.8.3:
- small bug fixes
- compatibility with NoGUI and ZenGL
- compilation of BGRABitmapPack4lcl_opengl in separate folder to avoid interference with the regular package
- embedded ZenGL examples in test4other folder
- added support for font rendering with OpenGL. Default renderer is LCL. One can specify font size, quality, color, gradient color, etc. See example in test4lcl_opengl folder
- added frame per second event in TBGLVirtualScreen component

Example of usage of font with OpenGL:
Code: Pascal  [Select][+][-]
  1. font := BGLFont('Arial', 20, CSSLightYellow,CSSBlack, [fsBold]);
Creates a font with face 'Arial', em-height 20 pixels, color light yellow with black outline, with style bold.

Code: Pascal  [Select][+][-]
  1. font.TextOut(ctx.Width-5,0,'Text at the upper-right corner',taRightJustify);
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 05, 2016, 10:46:07 am
Oh a new version!
Thanks dear Circular.
Title: Re: New version of BGRABitmap
Post by: circular on April 05, 2016, 08:05:42 pm
You're welcome. I would say that one thing that is next on my list is antialiased drawing and pen width with OpenGL.
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 05, 2016, 09:41:48 pm
You're welcome. I would say that one thing that is next on my list is antialiased drawing and pen width with OpenGL.
Another happy news for me.
You made this day a good day for me Circular  ;)
Title: Re: New version of BGRABitmap
Post by: circular on April 06, 2016, 10:56:14 pm
New version 8.8.4!

Added to BGRABitmap+ZenGL

Added to OpenGL more generally
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 09, 2016, 11:29:28 am
Hi,

I have a problem with new OpenGL package settings.
I have a package that used BGRABitmap and its OpenGL package so I just add OpenGL package in dependencies and everything was fine but now I got this problem that my package doesn't know what package it should use and have problem on finding BGRABitmapTypes units.
I cant make  two version of my package with and without OpenGL so what should I do?
Title: Re: New version of BGRABitmap
Post by: circular on April 09, 2016, 11:53:04 am
Hmm is it possible for your package to use only bgrabitmappack4lcl_opengl? This package provides TBGRABitmap as well as TBGLBitmap.
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 09, 2016, 12:48:44 pm
No really, I need both bgrabitmappack4lcl_opengl and bgracontrols package :|
I need both BGLVirtualScreen and BGRAVirtualScreen so I can switch in one app between them. I tried many ways but no success.
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 09, 2016, 02:11:26 pm
Another question.
How should I use TBGRABitmap image with BGL?
Take a look at this :
Quote
    b:=TBGRABitmap.Create;
    b.TakeScreenshotOfPrimaryMonitor;
    Tex:=BGLTexture(b);   
I write this in opengltest1 and colors will be reversed but if you load it TBGLBitmap it will be OK.
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 09, 2016, 02:45:25 pm
You're welcome. I would say that one thing that is next on my list is antialiased drawing and pen width with OpenGL.
Antialiased drawing including images drawings? Like when you use StretchPutImage?
Title: Re: New version of BGRABitmap
Post by: circular on April 09, 2016, 03:38:03 pm
Antialiased drawing including images drawings? Like when you use StretchPutImage?
Well this antialiasing is already done by OpenGL, isn't it?

No really, I need both bgrabitmappack4lcl_opengl and bgracontrols package :|
I need both BGLVirtualScreen and BGRAVirtualScreen so I can switch in one app between them. I tried many ways but no success.
I suggest to try to go in BGRAControls and change its dependency to bgrabitmappack4lcl_opengl

I write this in opengltest1 and colors will be reversed but if you load it TBGLBitmap it will be OK.
Oh that's a bug. I fixed it on SVN for you.
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 09, 2016, 03:56:22 pm
Quote
Well this antialiasing is already done by OpenGL, isn't it?
I dont know for sure but I know it is not smooth for sure, I just resize an image with BGRABitmap with high quality and another time with OpenGL and OpenGL version is not as smooth as BGRABitmap one.
Quote
I suggest to try to go in BGRAControls and change its dependency to bgrabitmappack4lcl_opengl
Just worked, Thanks.
Quote
Oh that's a bug. I fixed it on SVN for you.
Works as it should. Thanks.
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 09, 2016, 03:57:20 pm
I want to try BGRABitmap with OS X, what problem we have with it and what can I test for help?
Title: Re: New version of BGRABitmap
Post by: circular on April 09, 2016, 05:40:55 pm
Quote
Well this antialiasing is already done by OpenGL, isn't it?
I dont know for sure but I know it is not smooth for sure, I just resize an image with BGRABitmap with high quality and another time with OpenGL and OpenGL version is not as smooth as BGRABitmap one.
Oh I see what you're saying. For now basically you would need to call Resample to create a reduced image, and then display it, and then free it.

Quote
Quote
I suggest to try to go in BGRAControls and change its dependency to bgrabitmappack4lcl_opengl
Just worked, Thanks.
Cool  :)

Quote
I want to try BGRABitmap with OS X, what problem we have with it and what can I test for help?
That would be great. The problem is with LCL font rendering. So using the normal package, if you use TBGRABitmap.TextOut, it does not work.  :'(
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 09, 2016, 05:45:12 pm
Quote
Oh I see what you're saying. For now basically you would need to call Resample to create a reduced image, and then display it, and then free it.
But it is slow and yes there is tricks for better result but it will be very good to have it in BGL.
Quote
That would be great. The problem is with LCL font rendering. So using the normal package, if you use TBGRABitmap.TextOut, it does not work.
Just font? I remember you talked about low speed with Lainz before.
OK I will check it.
Title: Re: New version of BGRABitmap
Post by: circular on April 09, 2016, 06:43:16 pm
Quote
Oh I see what you're saying. For now basically you would need to call Resample to create a reduced image, and then display it, and then free it.
But it is slow and yes there is tricks for better result but it will be very good to have it in BGL.
Yes that's slow. The thing is that as far as I know OpenGL does not provide high quality resampling, apart from trilinear filtering, but in this case, you need to prepare the texture with different sizes.

Quote
Quote
That would be great. The problem is with LCL font rendering. So using the normal package, if you use TBGRABitmap.TextOut, it does not work.
Just font? I remember you talked about low speed with Lainz before.
OK I will check it.
Well basically it is the Canvas property that does not work. But this can be avoided most of the time, except when drawing text, because the default renderer depends on LCL rendering that is done on the Canvas. I am sometimes thinking about removing the Canvas property from TBGRABitmap, so that people would not be tempted to use it!

It is a bit slow indeed because the text is first drawn on a TBitmap.Canvas and then copied on the TBGRABitmap. And with fine resampling, this is much slower because a huge TBitmap is created to render with quality and is scaled down afterwards on a TBGRABitmap.

It would be faster to retrieve the shapes as Bezier curves instead. I know there a functions for that on Windows but that would not be cross-platform.
Title: Re: New version of BGRABitmap
Post by: aradeonas on April 09, 2016, 07:39:12 pm
Unfortunately I cant use multiple texture because I need it while resizing.
About font I will test it and if I found out something useful I will tell you.
Title: Re: New version of BGRABitmap
Post by: circular on April 09, 2016, 08:01:00 pm
Ok.  8-)
Title: Re: New version of BGRABitmap
Post by: circular on May 15, 2016, 08:40:38 pm
New version of BGRABitmap (8.9):

Bug fixes:

Note that package BGRABitmapPack4LCL_OpenGL has been merged into BGRAPitmapPack. The component TBGLVirtualScreen has been moved in a new package called BGLControls. OpenGL package is now independent of the RGB order of the system.

It is simpler to first uninistall BGRABitmap and BGRAControl packages, rebuild Lazarus, and then do the update to this version. Otherwise it is a bit complicated to remove the packages.

Here is an example using OpenGL (it is 5x faster)
Title: Re: New version of BGRABitmap
Post by: aradeonas on May 15, 2016, 08:56:24 pm
Wow. You made many changes!
I like these OpenGL changes although my focus is on using OpenGL on 2D project. I always dislike the lack of easy and complete tools to do fast graphics.
Thank you.
Title: Re: New version of BGRABitmap
Post by: circular on May 15, 2016, 11:20:43 pm
You're very welcome.
Title: Re: New version of BGRABitmap
Post by: circular on May 27, 2016, 09:53:19 pm
New version 8.9.1 with:
- PNG loading optimization
- fixes for 3D rendering with OpenGL

http://sourceforge.net/projects/lazpaint/files/
Title: Re: New version of BGRABitmap
Post by: lainz on May 27, 2016, 10:26:01 pm
I've updated GitHub mirror with this version, also for bgra-controls svn.

https://github.com/bgrabitmap
Title: Re: New version of BGRABitmap
Post by: circular on May 27, 2016, 11:05:02 pm
I am thinking about switching to Git. I was able to install TortoiseGit and it works fine.

Maybe what I could do is to use the Git repository you created on GitHub, and when I release a new version, I would update the SVN on SourceForge. So on SourceForge there would only be releases, and on GitHub there would be all changes.
Title: Re: New version of BGRABitmap
Post by: lainz on May 27, 2016, 11:56:47 pm
I am thinking about switching to Git. I was able to install TortoiseGit and it works fine.

Maybe what I could do is to use the Git repository you created on GitHub, and when I release a new version, I would update the SVN on SourceForge. So on SourceForge there would only be releases, and on GitHub there would be all changes.

GitHub also has website hosting, like in sourceforge but much easier, you can add the lazpaint version .txt and language updates on GitHub too. https://pages.github.com/

Also you can upadate directly bgracontrols and the other repos I've created before. Add new repositories is easy. The website is created under a branch, at least as is works in one of my projects. You can switch between branches easy with the GitHub application for desktop and manage all instead of using tortoise git, but it don't give you the nice icon overlays.

Edit: also you can upload releases on GitHub, like in sourceforge upload the zip's.
Title: Re: New version of BGRABitmap
Post by: Graeme on May 28, 2016, 01:03:50 am
I am thinking about switching to Git.
That would be a wise move. ;-)

Quote
I was able to install TortoiseGit and it works fine.
I recommend you rather learn the command line, and use the GUI tools that come standard with Git (eg: git-gui, gitk). They are ALWAYS the most up-to-date tools. Plus when using the command line, it is consistent across any platforms, and you have the full power of Git at your fingertips. I switched to Git in 2009, and on occation try out various Git GUI's and none of them can do everything you can do from the command line. They are all slower, cumbersome and take up desktop space (compared to a small terminal window).

Quote
So on SourceForge there would only be releases, and on GitHub there would be all changes.
I would ditch SourceForge completely. I'm actually thinking about doing the same thing with my projects. SourceForge supports Git (which is what I already use), but most of my projects are mirrored on Github too. Seeing that I frequently push and pull from both SourceForge and Github, I have immediately noticed that Github is so much faster. Plus, Github also supports project web pages, personal/author web pages, project binary releases, bug tracking, code review with inline comments etc.

Moving from SVN to Git is very easy too. Git can import the whole SVN history without trouble. Then simply add Github (or any other remote server) as a remote repository and push to that remote. Conversion - done!
Title: Re: New version of BGRABitmap
Post by: Graeme on May 28, 2016, 01:07:46 am
Edit: also you can upload releases on GitHub, like in sourceforge upload the zip's.

Correct, every Tag made in your repository becomes an automatic release. You can then extend such a release with a description and alternative downloads. eg:
  https://github.com/graemeg/xananews/releases (https://github.com/graemeg/xananews/releases)
Title: Re: New version of BGRABitmap
Post by: mse on May 28, 2016, 09:41:13 am
I am thinking about switching to Git. I was able to install TortoiseGit and it works fine.
There is also a handy git client written in Free Pascal:
https://sourceforge.net/projects/mseuniverse/
Quote
Maybe what I could do is to use the Git repository you created on GitHub, and when I release a new version, I would update the SVN on SourceForge. So on SourceForge there would only be releases, and on GitHub there would be all changes.
Another git project hosting option is GitLab (successor of Gitorious):
https://about.gitlab.com/gitlab-com/
Title: Re: New version of BGRABitmap
Post by: circular on May 28, 2016, 10:27:16 am
There is also a handy git client written in Free Pascal:
https://sourceforge.net/projects/mseuniverse/
Interesting.

Quote
Another git project hosting option is GitLab (successor of Gitorious):
https://about.gitlab.com/gitlab-com/
Ok. As Lainz has already created a repository on GitHub, for this project I will switch to this one to avoid confusion. But thanks for the link.

Edit: also you can upload releases on GitHub, like in sourceforge upload the zip's.

Correct, every Tag made in your repository becomes an automatic release. You can then extend such a release with a description and alternative downloads. eg:
  https://github.com/graemeg/xananews/releases (https://github.com/graemeg/xananews/releases)
Indeed, I have found the release mechanism by clicking on the release counter and it works fine!

However I don't find the interface as easy to understand as I would like. It is ok for a developer to spend some time learning how to use this website, but for the general public, that's complicated.
Title: Re: New version of BGRABitmap
Post by: circular on May 28, 2016, 10:59:16 am
I would ditch SourceForge completely. I'm actually thinking about doing the same thing with my projects.
SourceForge has its drawbacks, however it is simpler in my opinion. The download button appears straight away, tabs are more visible, etc.
Title: Re: New version of BGRABitmap
Post by: circular on May 28, 2016, 11:49:56 am
Ok, so now LazPaint repository is on GitHub:

https://github.com/bgrabitmap/lazpaint

(I will update SVN repository at each release)

Releases will be on GitHub and SourceForge:

https://github.com/bgrabitmap/lazpaint/releases
https://sourceforge.net/projects/lazpaint/
Title: Re: New version of BGRABitmap
Post by: Cyr on May 30, 2016, 01:35:27 pm
I'm faced with problem described http://forum.lazarus.freepascal.org/index.php/topic,32787.0.html (http://forum.lazarus.freepascal.org/index.php/topic,32787.0.html) when I try to compile  lpk on the Linux Mint 64 bit and I had some errors when compile under Raspberry PI 3 (Lazarus 1.6 FPC 3.0.0). Could you test the pack and improve these problems?
Title: Re: New version of BGRABitmap
Post by: circular on May 31, 2016, 04:29:57 pm
Done!

New version of BGRABitmap 8.9.2:
- fixed bugs and compilation on 64-bit
- fixed color for materials with texture (OpenGL)
- fixed LazPaint file format detection

Download location:
https://sourceforge.net/projects/lazpaint/files/src/
https://github.com/bgrabitmap/lazpaint/releases
(made the zip archive smaller)
Title: Re: New version of BGRABitmap
Post by: kito on June 01, 2016, 02:48:44 am
Hello ..
Quote
" ...fixed bugs and compilation on 64-bit..."

lazarrus 1.6 / fpc 3    / linux mint  64-bit 

still getting this error :

Quote
' bgraopengl3d.pas(719,1) Error: Internal error 2012090607 '

 hop you still have time to fix it ,if this error related to the package , circular 

Title: Re: New version of BGRABitmap
Post by: circular on June 01, 2016, 06:47:50 am
Does it help to put
Code: Pascal  [Select][+][-]
  1. {$PUSH}{$OPTIMIZATION OFF}
  2. ...
  3. {$POP}
  4.  
around the procedure?

Or to reduce the optimization in compilation options?
Title: Re: New version of BGRABitmap
Post by: kito on June 01, 2016, 05:54:02 pm
 :) it helped . every thing seems perfect now , thank you
Title: Re: New version of BGRABitmap
Post by: circular on June 01, 2016, 07:13:38 pm
Wonderful  :)
Title: Re: New version of BGRABitmap
Post by: circular on June 02, 2016, 10:40:15 pm
I've added the directive on SVN/Git.
Title: Re: New version of BGRABitmap
Post by: lainz on June 06, 2016, 05:25:47 pm
About OpenGL AntiAliasing you can ask here:
http://forum.lazarus-ide.org/index.php/topic,32892.0/topicseen.html

or here:
http://forum.lazarus-ide.org/index.php/topic,32800.msg212368.html#msg212368

both seems to handle AA
Title: Re: New version of BGRABitmap
Post by: circular on June 09, 2016, 10:38:12 pm
Yes, I might find some help/inspiration there.
Title: Re: New version of BGRABitmap
Post by: lainz on June 10, 2016, 12:59:16 am
How about a port of BGRABitmap for web HTML/JS? Is just an idea.

Of course to handle bitmaps you need them in a web server, they can't be loaded at local...
Title: Re: New version of BGRABitmap
Post by: aradeonas on June 10, 2016, 02:02:04 am
How about a port of BGRABitmap for web HTML/JS? Is just an idea.

Of course to handle bitmaps you need them in a web server, they can't be loaded at local...
Sound interesting and very useful, how do you thing about it?
Title: Re: New version of BGRABitmap
Post by: lainz on June 10, 2016, 02:54:00 am
I think that can use the canvas element and already working functions.

Then create a class BGRABitmap (TypeScript can help, I don't know when the OO will come to JS, I know is in development or something like that, but not readed about it long time ago, in the meantime using TypeScript will do the job).

And all the same as possible to reuse the code.

Other thing that can be done is create a new JSBGRABitmap pascal code that converts all the calling code into JS canvas. So you can change the type: TBGRABitmap to TJSBGRABitmap and instead of saving to bitmap saving to text format with all the code to run in a browser.

Or a mix of both, having a class in JS and then another in pascal that creates the .js and html automatically.

But are just ideas, maybe is too complex to do it! And who will use it? There are a lot of graphical libs out there for JS, I don't know if worth the effort.
Title: Re: New version of BGRABitmap
Post by: kapibara on June 10, 2016, 05:43:51 am
I experienced this error while trying to install bgrabitmap8.9.2 in Lazarus trunk under Ubuntu 16.04:

Compile package BGRABitmapPack 8.9.2: Exit code 256, Errors: 1, Hints: 10
bgraopengl3d.pas(425,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(433,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(441,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(449,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(457,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(474,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(482,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(490,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(498,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(506,18) Hint: Variable "$result" does not seem to be initialized
bgraopengl3d.pas(719,1) Error: Internal error 2012090607
Title: Re: New version of BGRABitmap
Post by: aradeonas on June 10, 2016, 10:14:36 am
Quote
Other thing that can be done is create a new JSBGRABitmap pascal code that converts all the calling code into JS canvas. So you can change the type: TBGRABitmap to TJSBGRABitmap and instead of saving to bitmap saving to text format with all the code to run in a browser.

Or a mix of both, having a class in JS and then another in pascal that creates the .js and html automatically.

But are just ideas, maybe is too complex to do it! And who will use it? There are a lot of graphical libs out there for JS, I don't know if worth the effort.
You are right, problem is what it's use and I think it should go with CEF. and in the other hand we can reverse this idea and use power up using JS and HTML and it's canvas to be used in our native pascal so you can reuse so much codes out there in your app natively, think about it as using HTML and JS as a resource and show them with BGRABitmap. You can say people can use CEF and these recourse but it has it's own downside like needing a huge library and messing around with it.
Title: Re: New version of BGRABitmap
Post by: lainz on June 10, 2016, 05:10:08 pm
Well you need in that case to convert the html canvas element and involved js to pascal in some way with bgrabitmap, I think is most difficult that way, or it's for me.

Most of the code out there maybe work with libraries, you need to convert them to pascal.

Using Chrome Embedded Framework is not my idea.

Well there are many options for both sides.
Title: Re: New version of BGRABitmap
Post by: lainz on June 12, 2016, 08:10:28 pm
I mean something like this:
http://forum.lazarus-ide.org/index.php/topic,32959.0.html
Title: Re: New version of BGRABitmap
Post by: circular on June 12, 2016, 09:59:28 pm
@kapibara: see previous answer http://forum.lazarus-ide.org/index.php/topic,24239.msg211858.html#msg211858
Title: Re: New version of BGRABitmap
Post by: kapibara on June 14, 2016, 05:24:07 am
@circular That worked. Thanks.
Title: Re: New version of BGRABitmap
Post by: circular on July 01, 2016, 11:12:06 pm
New version of BGRABitmap 9.0:
- support for Phoxo file format (simply add BGRAPhoxo unit to uses clause and you can load and save a layered image TBGRALayeredBitmap from unit BGRALayers)
- fix 3d transparency when color is not set per vertex but per object
- fix for ICO format reader on Linux
- fix for OpenGL calls on Linux
- fix memory errors in testbgrafunc project
- added loading options for TBGRABitmap.LoadFromFile and LoadFromStream (see thread (http://forum.lazarus.freepascal.org/index.php/topic,33046.msg213881.html#msg213881))
- compilation fixes

https://sourceforge.net/projects/lazpaint/files/src
Title: Re: New version of BGRABitmap
Post by: aradeonas on July 01, 2016, 11:48:28 pm
Ah, 9 is here.
Thanks Circular.
Title: Re: New version of BGRABitmap
Post by: circular on July 16, 2016, 09:08:35 am
New version of BGRABitmap 9.1:
- added TBGRASphereDeformationScanner and TBGRAVerticalCylinderDeformationScanner in BGRATransform
- added BGRAToGrayscaleLinear function (same as BGRAToGrayscale except that there is no gamma correction)
- moving some filter code into scanners (BGRAFilterScanner.pas), that brings the following new scanners: TBGRAFilterScannerGrayscale, TBGRAFilterScannerNegative, TBGRAFilterScannerSwapRedBlue, TBGRAFilterScannerNormalize
- added function TBGRABitmap.InplaceNormalize that makes use of the TBGRAFilterScannerNormalize
- fixed bugs with box blur ( http://forum.lazarus.freepascal.org/index.php/topic,33356.0.html )
- fixed some rare bugs when drawing shape outlines due to number precision
- added property Pen to TBGRABitmap, that has the usual properties of the Pen and also a StrokeMatrix property that allows to distort the pen
- in Canvas2D added the skewx and skewy transforms
- ability to draw path with TBGRAMultishapeFiller (need to provide the Pen property as a parameter)
- did some optimizations of Canvas2d related to masks
- fixed bugs with SVG ( including https://sourceforge.net/p/lazpaint/bugs/26/ and https://github.com/bgrabitmap/lazpaint/issues/1 ) and added to draw it with a certain alignment, or stretched arbitrarily. Now simple SVG files are rendered correctly. Gradients are not supported yet though.
- added multiplication operator between affine matrix and array of TPointF
- fixed text quality using system rendering
- fixed recognition of Phoxo format

https://sourceforge.net/projects/lazpaint/files/src
Title: Re: New version of BGRABitmap
Post by: circular on July 16, 2016, 09:44:18 am
Here is an example of the StrokeMatrix:
Code: Pascal  [Select][+][-]
  1. uses BGRABitmapTypes, BGRATransform;
  2.  
  3. { TForm1 }
  4.  
  5. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  6. var
  7.   i: Integer;
  8. begin
  9.   for i := 0 to 5 do
  10.   begin
  11.     Bitmap.Pen.StrokeMatrix := AffineMatrixSkewXDeg(-10*i);
  12.     Bitmap.Pen.LineCap := pecSquare;
  13.     Bitmap.DrawLineAntialias(40,40+i*80,Bitmap.Width div 2-40,40+i*80, BGRABlack,30);
  14.     Bitmap.Pen.LineCap := pecRound;
  15.     Bitmap.DrawLineAntialias(Bitmap.Width div 2+40,40+i*80,Bitmap.Width-40,40+i*80, BGRABlack,30);
  16.   end;
  17. end;  
Title: Re: New version of BGRABitmap
Post by: circular on July 16, 2016, 09:48:51 am
Here is an example of SVG (in testcanvas2d project, example 5):
Code: Pascal  [Select][+][-]
  1. uses BGRASVG;
  2.  
  3. procedure TForm1.Test5(ctx: TBGRACanvas2D);
  4. var svg: TBGRASVG;
  5. begin
  6.   svg := TBGRASVG.Create;
  7.   svg.LoadFromFile('Amsterdammertje-icoon.svg');
  8.   svg.StretchDraw(ctx, taCenter,tlCenter, 0,0,ctx.Width/3,ctx.Height);
  9.  
  10.   svg.LoadFromFile('BespectacledMaleUser.svg');
  11.   svg.StretchDraw(ctx, ctx.Width/3,0,ctx.Width*2/3,ctx.Height/2);
  12.  
  13.   ctx.save;
  14.   ctx.beginPath;
  15.   ctx.rect(ctx.Width/3,ctx.Height/2,ctx.Width*2/3,ctx.Height/2);
  16.   ctx.clip;
  17.   svg.LoadFromFile('Blue_gyroelongated_pentagonal_pyramid.svg');
  18.   svg.Draw(ctx, taCenter,tlCenter, ctx.Width*2/3,ctx.Height*3/4);
  19.   ctx.restore;
  20.  
  21.   svg.Free;
  22.  
  23.   ctx.beginPath;
  24.   ctx.lineWidth:= 1;
  25.   ctx.strokeStyle(BGRABlack);
  26.   ctx.moveTo(ctx.Width/3,0);
  27.   ctx.lineTo(ctx.Width/3,ctx.Height);
  28.   ctx.moveTo(ctx.Width/3,ctx.Height/2);
  29.   ctx.lineTo(ctx.Width,ctx.Height/2);
  30.   ctx.stroke;
  31. end;  
Title: Re: New version of BGRABitmap
Post by: lainz on July 16, 2016, 04:56:16 pm
circular you will put the release in GitHub too?

You can track the GitHub downloads (not as good as SF but at least is something) here: http://www.somsubhra.com/github-release-stats/?username=bgrabitmap&repository=lazpaint

Edit: you can edit the current release and add the new sources only, if you want to keep the tags only pointing to lazpaint not bgrabitmap. Else you can create a tag pointing v9.1 and will not be related to lazpaint but to bgrabitmap only. You can mix if you want.
Title: Re: New version of BGRABitmap
Post by: aradeonas on July 16, 2016, 07:36:58 pm
Thanks circular ;)
Title: Re: New version of BGRABitmap
Post by: circular on July 16, 2016, 07:49:30 pm
Hi Lainz!

I am not sure how to do that. I have the impression that the release thing is only available for the whole repository, and I use that for LazPaint.
Title: Re: New version of BGRABitmap
Post by: lainz on July 16, 2016, 10:30:58 pm
Hi Lainz!

I am not sure how to do that. I have the impression that the release thing is only available for the whole repository, and I use that for LazPaint.

Ok you're right is the state of the whole repository that is pointed..
Title: Re: New version of BGRABitmap
Post by: circular on October 10, 2016, 10:23:17 pm
Hi people!

Here is the latest version of BGRABitmap (9.2):
- compilation fix for QT
- fixes for OpenGL
- adding SoftLight blend mode according to SVG specification
- added fast (simplified) colour comparison with FastBGRALinearDiff and FastBGRAExpandedDiff
- improving scanners and using it in BGRAFilter unit
- keep weight information in approximation palette TBGRAApproxPalette
- slight correction of affine transformation and added opacity parameter to FillQuadAffineMapping function

https://sourceforge.net/projects/lazpaint/files/src/
Title: Re: New version of BGRABitmap
Post by: lainz on October 10, 2016, 11:23:09 pm
Well done  :)
Title: Re: New version of BGRABitmap
Post by: Okoba on October 11, 2016, 12:17:13 pm
Well done!
Title: Re: New version of BGRABitmap
Post by: circular on October 11, 2016, 02:58:18 pm
Thank you thank you  :-[
Title: Re: New version of BGRABitmap
Post by: lainz on October 15, 2016, 11:37:32 pm
Hi circular, I can't compile LazPaint 6.4.1 release BGRABitmap 8.9.2 under Ubuntu 64 bits (the git 'trunk' is working fine, just that release) with Lazarus 1.6 fpc 3.0, something related with open gl stuff, I not take a note of the error and just switched to trunk because of course that old release will not be updated and that was already fixed.

I want to compile that version because an user on GitHub reported that wants a 64 bit version (https://github.com/bgrabitmap/lazpaint/issues/7). Well maybe we can do that for the next release.
Title: Re: New version of BGRABitmap
Post by: circular on October 15, 2016, 11:46:40 pm
Hmmm... well there are three solutions:
- we find a way to fix this error
- you compile with an older version of BGRABitmap
- you wait for the next release

This next release has been delayed but I guess I will have more free time now.

Note: thanks to the automatic update of windows 10, I could not log on my computer anymore. I had to clear everything.  %)
Title: Re: New version of BGRABitmap
Post by: lainz on October 15, 2016, 11:50:31 pm
Ok I will wait, I already seen how to create a basic package for linux (not tested but seems easy), I'm impressed how fast can run a virtual machine, I have both Ubuntu 32 and 64. Remembering that older versions of lazarus can't run on ubuntu (older ubuntu too) due to keyboard problems and other stuff, now everything works fine.
Title: Re: New version of BGRABitmap
Post by: circular on October 16, 2016, 12:20:28 am
About building a Deb package, someone sent me instructions (in French) on how they did the package. I did not really understand so I am not sure how to translate.

There are also some scripts to test that it is the correct cpu (32 or 64bit) that can apparently be embedded in the package.
Title: Re: New version of BGRABitmap
Post by: lainz on October 16, 2016, 12:39:37 am
Thankyou I will check it. That I get from internet:

- The deb contains the system structure, then you can copy the files in the desired folders where the files should be installed.
- So you have a folder for the binary, other for the application files, other for the icon, other for the documentation, a file with the description and so on.
- And must be lowercase underscore major and minor like "lazpaint_7.0"
- You can create the deb from command line

But I've not tried by myself, I will try soon. Maybe there is a deb making utility we can use instead of the command line (Ok, the document say what can we use).

Ok I see the two scripts to verify.
Title: Re: New version of BGRABitmap
Post by: lainz on October 17, 2016, 10:22:29 pm
@Circular

I've updated the LazPaint repository with a new folder called 'deb' that contains simple instructions on how to make a lazpaint deb with the command-line with no need of installing third party software, also includes all the stuff (except the binaries of course) needed to include in the deb package.
Title: Re: New version of BGRABitmap
Post by: circular on October 18, 2016, 07:38:21 pm
Thank you for taking the time to do that.  :)
Title: Re: New version of BGRABitmap
Post by: circular on October 19, 2016, 05:42:17 pm
New version 9.2.1 with:
- bug fix when using a texture with zero size
- added properties and functions to TBGRAPixel
- TBGRABitmap is now defined via class(...) so that pressing CTRL-SHIFT-C on "bmp" variable will add the correct variable type:
Code: Pascal  [Select][+][-]
  1. procedure test;
  2. begin
  3.   bmp := TBGRABitmap.Create(100,100);
  4. end;

Details of TBGRAPixel:
Code: Pascal  [Select][+][-]
  1.   TBGRAPixel = packed record
  2.   private
  3.     function GetClassIntensity: word;
  4.     function GetClassLightness: word;
  5.     procedure SetClassIntensity(AValue: word);
  6.     procedure SetClassLightness(AValue: word);
  7.   public
  8.     {$IFDEF BGRABITMAP_RGBAPIXEL}
  9.     red, green, blue, alpha: byte;
  10.     {$ELSE}
  11.     blue, green, red, alpha: byte;
  12.     {$ENDIF}
  13.     procedure FromRGB(ARed,AGreen,ABlue: Byte; AAlpha: Byte = 255);
  14.     procedure FromColor(AColor: TColor; AAlpha: Byte = 255);
  15.     procedure FromString(AStr: string);
  16.     procedure FromFPColor(AColor: TFPColor);
  17.     procedure ToRGB(out ARed,AGreen,ABlue,AAlpha: Byte); overload;
  18.     procedure ToRGB(out ARed,AGreen,ABlue: Byte); overload;
  19.     function ToColor: TColor;
  20.     function ToString: string;
  21.     function ToGrayscale(AGammaCorrection: boolean = true): TBGRAPixel;
  22.     function ToFPColor: TFPColor;
  23.     class Operator := (Source: TBGRAPixel): TColor;
  24.     class Operator := (Source: TColor): TBGRAPixel;
  25.     property Intensity: word read GetClassIntensity write SetClassIntensity;
  26.     property Lightness: word read GetClassLightness write SetClassLightness;
  27.   end;  

https://sourceforge.net/projects/lazpaint/files/src/
Title: Re: New version of BGRABitmap
Post by: circular on November 10, 2016, 12:28:48 am
New version 9.2.2 with minor fixes.
- fixed zero value when using custom gamma factor like 2.2 instead of 1.7
- updated reference to BGRABitmap package in OpenGL tests
- avoid ambiguous names for color conversion functions introduced in version 9.2.1 in TBGRAPixelHelper and TExpandedPixelHelper. It is unlikely but you may need to change your code accordingly if it doesn't compile straight away, use intellisense to find the new function name. If you don't find how to fix, leave a message on this thread.

https://github.com/bgrabitmap/bgrabitmap/releases

Important note: bgrabitmap library is going to be separated tomorrow from lazpaint repository. For now, the repository "bgrabitmap/lazpaint" contains both lazpaint and bgrabitmap. After the split, the repository "bgrabitmap/bgrabitmap" will contain the library and "bgrabitmap/lazpaint" will only contain LazPaint. So if you are working from Git, after pulling latest changes, bgrabitmap will disappear. You will need to checkout the new dedicated repository.
Title: Re: New version of BGRABitmap
Post by: circular on November 10, 2016, 10:24:47 am
New repository created for bgrabitmap:

Git URL: https://github.com/bgrabitmap/bgrabitmap.git
Browse URL: https://github.com/bgrabitmap/bgrabitmap
Zip download URL: https://github.com/bgrabitmap/bgrabitmap/releases

LazPaint repository:

Git URL: https://github.com/bgrabitmap/lazpaint.git
Browse URL: https://github.com/bgrabitmap/lazpaint

BGRABitmap library will soon be deleted from this repository, so if you are using it, checkout the new repository "bgrabitmap/bgrabitmap" and open the package files you are using in Lazarus to update the reference. You may need to recompile Lazarus to update the components based on BGRABitmap.

SourceForge repository

SourceForge repository contains LazPaint but doesn't contain BGRABitmap anymore.
Title: Re: New version of BGRABitmap
Post by: lainz on November 10, 2016, 03:49:39 pm
Thanks for the updates.

I recommend you that soon remove the sourceforge downloads and code repository, because people if it's there will download it, doesn't matter if outdated.
Title: Re: New version of BGRABitmap
Post by: circular on November 10, 2016, 05:11:26 pm
Agreed. I have moved all bgrabitmap zip files into old folder. Now only lazpaint source and binaries remain in view.

Apparently there is a way to remove the SVN repository. But I am not sure how to do that. Instead I could remove all the files locally and commit that.
Title: Re: New version of BGRABitmap
Post by: lainz on November 10, 2016, 05:15:09 pm
Apparently there is a way to remove the SVN repository. But I am not sure how to do that. Instead I could remove all the files locally and commit that.

Yes, there's a padlock at the right, click on it to unlock it and there will appear gears for each element in the page, click on code gear and then delete.
Title: Re: New version of BGRABitmap
Post by: VTwin on November 10, 2016, 10:51:18 pm
Hi circular,

Thanks! I just downloaded 9.9.2 from git and am having trouble getting a basic test program compiled. On Windows 7 I get:

Code: Pascal  [Select][+][-]
  1. Compile package FCL 1.0.1: Success
  2. Compile package LazUtils 1.0: Success, Warnings: 2, Hints: 5
  3. lazfileutils.pas(109,23) Hint: Parameter "ExceptionOnError" not used
  4. lazfilecache.pas(75,65) Hint: Parameter "EmptyOnError" not used
  5. paswstring.pas(118,10) Hint: Mixing signed expressions and longwords gives a 64bit result
  6. winfileutil.inc(21,53) Warning: Symbol "UTF8ToSys" is deprecated: "Use the function in LazUTF8 unit"
  7. winfileutil.inc(21,13) Warning: Symbol "SysToUTF8" is deprecated: "Use the function in LazUTF8 unit"
  8. lazutf8sysutils.pas(32,35) Hint: Local variable "SystemTime" does not seem to be initialized
  9. ttfile.pas(374,5) Hint: User defined: workaround for fpc bug 23868 when compiling with -O2
  10. Compile package LCLBase 1.6.0.4: Success
  11. Compile package LCL 1.6.0.4: Success, Warnings: 6
  12. win32proc.pp(716,41) Warning: Symbol "Handle" is deprecated: "use Reference.Handle instead"
  13. win32int.pp(21,26) Warning: User defined: Fix implicit pointer conversions
  14. win32pagecontrol.inc(71,17) Warning: Symbol "IsUnpaged" is deprecated
  15. win32pagecontrol.inc(334,24) Warning: Symbol "IsUnpaged" is deprecated
  16. win32pagecontrol.inc(644,18) Warning: Symbol "IsUnpaged" is deprecated
  17. win32callback.inc(557,58) Warning: Local variable "BytesCount" does not seem to be initialized
  18. Compile Project, OS: win32, CPU: i386, Target: project1.exe: Exit code 1, Errors: 15, Warnings: 1, Hints: 6
  19. basiccolorspace.inc(272,9) Warning: Function result variable does not seem to initialized
  20. blendpixelinline.inc(950,25) Hint: Converting the operands to "Int64" before doing the add could prevent overflow errors.
  21. blendpixelinline.inc(950,67) Hint: Mixing signed expressions and longwords gives a 64bit result
  22. blendpixelinline.inc(950,67) Hint: Converting the operands to "Int64" before doing the subtract could prevent overflow errors.
  23. blendpixelinline.inc(950,92) Hint: Converting the operands to "Int64" before doing the multiply could prevent overflow errors.
  24. blendpixelinline.inc(952,25) Hint: Converting the operands to "Int64" before doing the add could prevent overflow errors.
  25. blendpixelinline.inc(952,31) Hint: Converting the operands to "Int64" before doing the subtract could prevent overflow errors.
  26. bgradefaultbitmap.pas(254,17) Error: There is no method in an ancestor class to be overridden: "constructor TBGRADefaultBitmap.Create(AnsiString);"
  27. bgradefaultbitmap.pas(259,17) Error: There is no method in an ancestor class to be overridden: "constructor TBGRADefaultBitmap.Create(AnsiString,Boolean);"
  28. bgradefaultbitmap.pas(260,17) Error: There is no method in an ancestor class to be overridden: "constructor TBGRADefaultBitmap.Create(AnsiString,Boolean,TBGRALoadingOptions);"
  29. bgradefaultbitmap.pas(282,14) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.NewBitmap(AnsiString):TBGRACustomBitmap;"
  30. bgradefaultbitmap.pas(287,14) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.NewBitmap(AnsiString,Boolean):TBGRACustomBitmap;"
  31. bgradefaultbitmap.pas(288,14) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.NewBitmap(AnsiString,Boolean,TBGRALoadingOptions):TBGRACustomBitmap;"
  32. bgradefaultbitmap.pas(696,15) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.TextOut(Single,Single,AnsiString,TBGRAPixel,TAlignment);"
  33. bgradefaultbitmap.pas(700,15) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.TextOut(Single,Single,AnsiString,IBGRAScanner,TAlignment);"
  34. bgradefaultbitmap.pas(703,15) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.TextOutAngle(Single,Single,LongInt,AnsiString,TBGRAPixel,TAlignment);"
  35. bgradefaultbitmap.pas(704,15) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.TextOutAngle(Single,Single,LongInt,AnsiString,IBGRAScanner,TAlignment);"
  36. bgradefaultbitmap.pas(706,15) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.TextOutCurved(TBGRACustomPathCursor,AnsiString,TBGRAPixel,TAlignment,Single);"
  37. bgradefaultbitmap.pas(707,15) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.TextOutCurved(TBGRACustomPathCursor,AnsiString,IBGRAScanner,TAlignment,Single);"
  38. bgradefaultbitmap.pas(712,15) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.TextRect(RECT,LongInt,LongInt,AnsiString,TTextStyle,TBGRAPixel);"
  39. bgradefaultbitmap.pas(713,15) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.TextRect(RECT,LongInt,LongInt,AnsiString,TTextStyle,IBGRAScanner);"
  40. bgradefaultbitmap.pas(717,14) Error: There is no method in an ancestor class to be overridden: "TBGRADefaultBitmap.TextSize(AnsiString):<record type>;"
  41.  

It compiles ok on Mac 10.11.6, but I was getting strange colors, that I was trying to figure out.

It is just a basic program with "bgrabitmaptypes, bgrabitmap" in the uses clause. Any thoughts on what is going on?

Cheers,
VTwin
Title: Re: New version of BGRABitmap
Post by: lainz on November 10, 2016, 11:51:58 pm
You can upload your test project? So is easy to test if works in any other context.
Title: Re: New version of BGRABitmap
Post by: VTwin on November 11, 2016, 12:07:37 am
Thanks lainz,

I'm testing again on another system, and then will post it.

Cheers,
VTwin
Title: Re: New version of BGRABitmap
Post by: VTwin on November 11, 2016, 02:05:42 am
I tried running this on a new machine (MacBook Pro with Windows 7 on VirtualBox). I'm having trouble reproducing errors, but am still not able to get this to run. On Windows 7 (64 bit) it is now compiling, but I get a blank form. On Mac 10.11.5 I get a blue rectangle instead of the expected red.

Code: [Select]
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  StdCtrls,
  BGRABitmap, BGRABitmapTypes;

type

  { TForm1 }

  TForm1 = class(TForm)
    PaintBox1: TPaintBox;
    procedure FormCreate(Sender: TObject);
    procedure FormPaint(Sender: TObject);
  private
    { private declarations }
    fBmp: TBGRABitmap;
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
var
  w, h: integer;
  tsp: TBGRAPixel;
begin
  tsp := BGRA($00, $00, $00, $00);
  w := PaintBox1.Width;
  h := PaintBox1.Height;
  fBmp := TBGRABitmap.Create(w, h);
  fBmp.FillRect(0, 0, w-1, h-1, cssWhite, dmSet);
  fBmp.FillRect(0, 0, w-1, h-1, cssRed, dmDrawWithTransparency);
  fBmp.Rectangle(0, 0, w-1, h-1, cssBlack, tsp, dmDrawWithTransparency);
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  fBmp.Draw(PaintBox1.Canvas, 1, 1, true);
end;

end.

See attached project.

I appreciate any suggestions.

Cheers,
VTwin
Title: Re: New version of BGRABitmap
Post by: VTwin on November 11, 2016, 02:24:05 pm
I commented out in TBRAPixel.inc:

Code: Pascal  [Select][+][-]
  1.      
  2.       (*** BUG *** {$IFDEF DARWIN}
  3.         {$DEFINE BGRABITMAP_RGBAPIXEL}
  4.       {$ENDIF} ***)
  5.  

as in previous versions. Now on Mac (10.10.5) the expected blue rectangle is cyan with a blue border.  %)

VTwin
Title: Re: New version of BGRABitmap
Post by: lainz on November 11, 2016, 03:14:52 pm
There are some things I see:

1) You can use BGRAPixelTransparent instead of tsp
Quote
fBmp.Rectangle(0, 0, w-1, h-1, cssBlack, BGRAPixelTransparent, dmDrawWithTransparency);

2) You must use OnPaint event of PaintBox, not of Form
Quote
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
  fbmp.Draw(PaintBox1.Canvas, 1, 1, true);
end;

Edit:

3) Also you need only a line to paint black border filled with red:
Quote
  //fBmp.FillRect(0, 0, w-1, h-1, cssWhite, dmSet);
  //fBmp.FillRect(0, 0, w-1, h-1, cssRed, dmDrawWithTransparency);
  fBmp.Rectangle(0, 0, w, h, cssBlack, cssRed, dmDrawWithTransparency); //<---

4) You can use w, h, and 0, 0 coordinates to paint to fill the entire rectangle
Quote

fBmp.Rectangle(0, 0, w, h,...

fbmp.Draw(PaintBox1.Canvas, 0, 0, true);
Title: Re: New version of BGRABitmap
Post by: VTwin on November 11, 2016, 03:53:29 pm
lainz,

Thanks! I had the white background because it was a Form to set the transparency, and the form's background was not white, but yes, I can simplify it. Using (w, h) also makes sense, thanks. Now I have:

EDIT

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.   w, h: integer;
  4. begin
  5.   w := PaintBox1.Width;
  6.   h := PaintBox1.Height;
  7.   fBmp := TBGRABitmap.Create(w, h);
  8.   //fBmp.FillRect(0, 0, w, h, cssWhite, dmSet);
  9.   //fBmp.FillRect(0, 0, w, h, cssRed, dmDrawWithTransparency);
  10.   //fBmp.Rectangle(0, 0, w, h, cssBlack, BGRAPixelTransparent, dmDrawWithTransparency);
  11.   fBmp.Rectangle(0, 0, w, h, cssBlack, cssRed, dmDrawWithTransparency);
  12. end;
  13.  
  14. procedure TForm1.PaintBox1Paint(Sender: TObject);
  15. begin
  16.   fBmp.Draw(PaintBox1.Canvas, 0, 0, true);
  17. end;        
  18.  

but still get the cyan square with blue border. :( I'll work on it more tonight.

Cheers,
VTwin
Title: Re: New version of BGRABitmap
Post by: lainz on November 11, 2016, 03:58:45 pm
Code: Pascal  [Select][+][-]
  1.  w := PaintBox1.Canvas.Width;
  2.   h := PaintBox1.Canvas.Height;

That's the wrong code.

You must use PaintBox width and height, not canvas.
Code: Pascal  [Select][+][-]
  1. w := PaintBox1.Width;
  2.   h := PaintBox1.Height;

Edit: OK, you updated your post with the right code. About the cyan color instead of red, I'm not sure why that happens on Mac.
Title: Re: New version of BGRABitmap
Post by: circular on November 11, 2016, 05:53:02 pm
I have removed SVN repository from SourceForge, it only contains LazPaint now.
Title: Re: New version of BGRABitmap
Post by: circular on November 11, 2016, 07:02:00 pm
@VTwin:
I suppose the error "There is no method in an ancestor class to be overridden" you're getting is related to the string type. In principle there is {$H+} at the top of both units BGRABitmapTypes and BGRADefaultBitmap so the type "string" is the same.

What if you replace "string" by "ansistring"?

About the strange colors, what is the endianness of your Mac computer?
Title: Re: New version of BGRABitmap
Post by: VTwin on November 12, 2016, 12:54:32 am
lainz,

Thanks. Yes I realized as soon as I posted that I had tried using the width and height of the Canvas. As soon as I switched back, I got the image again. The colors, so far, are a mystery.

circular,

Thanks. I was not able to reproduce the ancestor class error. I switched machines, and also reinstalled Lazarus as I was getting some odd errors. I just checked again and Windows 7 is compiling the test program ok, and giving the expected colors.

I thought perhaps this might be related to the known Mac bug. I use PaintBox often, and did not note a problem until now, so I was trying to isolate it.

As far as I can tell, from internet searches, the current i86 Macs are all little endian. The old Motorola Macs were big endian. I have not checked this myself in code though. If you wish to refresh my memory on a simple test, I can try that.

Cheers,
VTwin

Just to add, I use BGRABitmap extensively on Mac, Windows, and Linux, and normally it works extremely well. This is an unusual case that is puzzling. 
Title: Re: New version of BGRABitmap
Post by: VTwin on November 12, 2016, 01:20:52 am
Just checked on Linux Ubuntu. The test program compiles and runs as expected. Since OS X has Linux underpinnings, I am surprised at the difference.
Title: Re: New version of BGRABitmap
Post by: circular on November 12, 2016, 10:39:22 am
Hi VTwin,

So if I understand well, you were able to compile BGRABitmap on Windows 7.

On MacOS X, yes, I suppose it is little endian. Do you still have the strange colors?

What you described look like the RGBA format was interpreted as BGRA a format and the BGRA format interpreted as ARGB. That's a bit strange. The procedure that creates the bitmap as in procedure TBGRALCLBitmap.RebuildBitmap in bgralclbitmap.pas. Maybe you can try to debug and add a breakpoint there, and see what it does.
Title: Re: New version of BGRABitmap
Post by: VTwin on November 12, 2016, 06:14:20 pm
Hi circular,

Thanks. Yes, the program runs as expected now on Windows. The error messages disappeared after I reinstalled Lazarus.

I am nearly certain it is little endian, I checked with a script I found. Yes, the colors are strange. Attached are two forms showing DEFINE BGRAPIXEL_RGBAPIXEL results and UNDEF BGRAPIXEL_RGBAPIXEL results.

I tried adding bgralclbitmap.pas to the project, and added a breakpoint, but it did not seem to call TBGRALCLBitmap.RebuildBitmap.

VTwin
Title: Re: New version of BGRABitmap
Post by: VTwin on November 12, 2016, 06:21:01 pm
Here is the updated project if another Mac user would like to confirm.

Cheers,
VTwin

EDIT: It works as expected on Linux.
Title: Re: New version of BGRABitmap
Post by: Josh on November 12, 2016, 09:07:58 pm
Hi

Just tested, getting same problem. I think however its a problem with TPainBox; if you create a similar tbitmaps and send the generted image from bgrabitmap it renders correct/similar on cocoa and carbon

I have attached moded project, Maybe you can try sending to bug tracker.

Hope it  helps in some way
Title: Re: New version of BGRABitmap
Post by: VTwin on November 13, 2016, 12:06:01 am
Hi josh,

Excellent, thanks!! :D It may be a problem with TCanvas in general as I got the same result with TForm.Canvas.

I'm having trouble loading your moded project though. I didn't have bgracontrols installed, and am having trouble figuring out how to install it. I thought I had it, but am getting errors. I seem to have trouble with packages.  :(

Maybe there is another workaround...

Cheers,
VTwin
 
Title: Re: New version of BGRABitmap
Post by: Josh on November 13, 2016, 12:28:53 am
Hi

My fault, I was trying some other controls to make sure they worked as well, and forgot to take out the dependencies.

Attached project that should have all non used dependencies removed.

I tried to get tpl_scope component to work on osx, and gave up after a while; this also uses tpaintbox. I also was using a paintbx to render the wave form of an audio file; this worked fine in windows; but on osx it was intermittent; some times it would render and sometime it would display nothing; I even made it create a file of the ordinates it should be rendering;  just to make sure the value were in range and all was fine; so I concluded an intermittent bug when drawing lines within pb; and as the values were sent were fine further concluded it had something to do with colors not being drawn correctly.  Last time I checked bugtracker; there were a few open paintbox issues.

Hopefully these bugs/issues will get solved soon.
Title: Re: New version of BGRABitmap
Post by: VTwin on November 13, 2016, 02:00:33 am
Hi josh,

Many thanks, I can now open the project. But when I hit the line:

BPR.Picture.Bitmap:=FBMPR.Bitmap;

I get:

Project project1 raised exception class 'FPImageException' with message:
Failed to create bitmap handle

Maybe I screwed something up? I reinstalled Lazarus just in case, but no dice yet.

Cheers,
VTwin

Title: Re: New version of BGRABitmap
Post by: VTwin on November 13, 2016, 02:17:52 am
I'm having luck with this:

Code: Pascal  [Select][+][-]
  1. imgR.Picture.Bitmap.SetSize(w, h);
  2. fBmpR.Draw(imgR.Picture.Bitmap.Canvas, 0, 0, true); {EDIT}

where imgR is a TImage. Seems confusing, but works. :)
Title: Re: New version of BGRABitmap
Post by: Josh on November 13, 2016, 02:51:34 am
Hi
Thats odd, I just downloaded the project I uploaded and compiled and run ok.

Maybe its Lazarus and FPC differences.

I am using FPC 3.1.1 and Laz 1.7 (SVN 53325)  Think its a couple of days old

Title: Re: New version of BGRABitmap
Post by: VTwin on November 13, 2016, 03:01:04 am
Hi josh,

Yes seems odd. It is possible I messed something up, but think I have a clean install. I'm on the last stable release, FPC 3.0.0 and Laz 1.6.0.

Thanks for checking, I appreciate your help!

Cheers,
VTwin
Title: Re: New version of BGRABitmap
Post by: Josh on November 13, 2016, 03:32:29 am
just thought,

Can you check the project dependencies in Project Inspector, its possible that there may be an error in the differnce in location of BGRABITMAP, If it appears with a line through it; remove the dependency and then add your bgrabitmap dependency in.
Also maybe worth checking your project options are all set, ie Darwin, Compile for i386 and widgetset is set to Carbon. These can change sometimes between versions.

Title: Re: New version of BGRABitmap
Post by: VTwin on November 13, 2016, 02:45:23 pm
I don't see anything strange, no red lines. Just in case I removed BGRABitmapPack using the Project Inspector, and then added in the one in the directory containing 9.2.2 bgrabitmap. No change. Widgetset is Carbon, Darwin, i386.

However, I copied the code using TImage into my original program where I encountered the problem, and am still getting the old behavior with odd colors. %)

EDIT

In my original program I get:

Warning: other unit files search path (aka unit path) of "MyProg" contains "/Users/.../bgrabitmap", which belongs to package "BGRABitmapPack"

Confused, maybe this is a problem?
Title: Re: New version of BGRABitmap
Post by: Thaddy on November 13, 2016, 03:32:42 pm
In my original program I get:
Warning: other unit files search path (aka unit path) of "MyProg" contains "/Users/.../bgrabitmap", which belongs to package "BGRABitmapPack"
Confused, maybe this is a problem?

Maybe this is due to the fact that in the latest trunk LazPaint and Bgrabit stuff is now separated?  You probably have an older install somewhere of the LazPaint stuff.
Re-installing both and cleaning out the directories first might help.
https://github.com/bgrabitmap/bgrabitmap
Title: Re: New version of BGRABitmap
Post by: VTwin on November 13, 2016, 05:24:22 pm
Thaddy, Thanks. Yes, I had an extra reference. I think it was because I had bgrabitmappack in "Required Packages", AND had the bgrabitmap directory in the Paths "Other unit files". Got that cleared up.

It is finally working!!! :D Using TImage was the trick as josh suggested. Hooray!!

I'll file a bug report. Many thanks all.

Cheers,
VTwin
Title: Re: New version of BGRABitmap
Post by: circular on November 13, 2016, 05:40:24 pm
Hello VTwin,

It is surprising that drawing on Canvas doesn't work. Can you try the following test program to check what happens when using different formats with TRawImage?

Here is the result on Windows10.
Title: Re: New version of BGRABitmap
Post by: VTwin on November 13, 2016, 07:17:42 pm
Hello circular,

I get a bad access exception, so:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.PaintBox4Paint(Sender: TObject);
  2. var bmp: TBitmap;
  3. begin
  4.   bmp := MakeBitmapSample(Label4.Caption);
  5.   //PaintBox4.Canvas.Draw(0,0,bmp);
  6.   bmp.Free;
  7. end;


but here is the form with the other three.

Cheers,
VTwin

I'm on OS X 10.10.5 at the moment.
Title: Re: New version of BGRABitmap
Post by: VTwin on November 13, 2016, 07:35:38 pm
On Ubuntu 14.04 there is no exception, all four are the same with correct colors.
Title: Re: New version of BGRABitmap
Post by: circular on November 13, 2016, 08:27:48 pm
@VTwin:
Thanks. Ok, maybe the strange colors happen when there is no alpha channel. What happens if you remove the alpha channel:
Code: Pascal  [Select][+][-]
  1.   with raw.Description do
  2.   begin
  3.     Init;
  4.     Format := ricfRGBA;
  5.     Depth := 24; // used bits per pixel
  6.     Width := imageWidth;
  7.     Height := imageHeight;
  8.     BitOrder := riboBitsInOrder;
  9.     LineOrder := riloTopToBottom;
  10.     BitsPerPixel := 32;
  11.     LineEnd := rileDWordBoundary;
  12.     RedPrec := 8;
  13.     GreenPrec := 8;
  14.     BluePrec := 8;
  15.     AlphaPrec := 0; //no alpha channel
  16.     RedShift := (pos('R',channelOrder)-1)*8;
  17.     GreenShift := (pos('G',channelOrder)-1)*8;
  18.     BlueShift := (pos('B',channelOrder)-1)*8;
  19.     AlphaShift := (pos('A',channelOrder)-1)*8;
  20.     {$IFDEF ENDIAN_BIG}
  21.     ByteOrder := riboMSBFirst;
  22.     RedShift := 24-RedShift;
  23.     GreenShift := 24-GreenShift;
  24.     BlueShift := 24-BlueShift;
  25.     AlphaShift := 24-AlphaShift;
  26.     {$ELSE}
  27.     ByteOrder := riboLSBFirst;
  28.     {$ENDIF}
  29.   end;
Title: Re: New version of BGRABitmap
Post by: circular on November 13, 2016, 08:29:46 pm
when I hit the line:

BPR.Picture.Bitmap:=FBMPR.Bitmap;

I get:

Project project1 raised exception class 'FPImageException' with message:
Failed to create bitmap handle
This is a problem I've had before. In my memory, it is related to the fact that when you assign a bitmap like that, it becomes a shared bitmap and that causes some problems. You can use TBGRABitmap.MakeBitmapCopy to have a bitmap you can safely assign.
Title: Re: New version of BGRABitmap
Post by: VTwin on November 13, 2016, 08:44:56 pm
I replaced the old

Code: Pascal  [Select][+][-]
  1. with raw.Description do
  2.   begin
  3.   ...
  4.   end;

with the one you posted. Interesting!

Thanks, I wondered about assigning a bitmap like that. Makes sense.
Title: Re: New version of BGRABitmap
Post by: circular on November 13, 2016, 11:31:27 pm
Thank you for testing, I think I know what to do about it.
Title: Re: New version of BGRABitmap
Post by: circular on November 14, 2016, 12:23:43 am
Hello VTwin,

I have tried to apply a fix for opaque rendering on MacOS in order to solve the strange colors.

Can you try with the branch "dev-bgrabitmap" to see if it works?
https://github.com/bgrabitmap/bgrabitmap/tree/dev-bgrabitmap

Regards
Title: Re: New version of BGRABitmap
Post by: VTwin on November 14, 2016, 02:15:04 am
I'm on it! ;)
Title: Re: New version of BGRABitmap
Post by: VTwin on November 14, 2016, 02:50:42 am
Hi circular,

I'm throwing everything I've got at it. The PaintBox test program, three 100,000+ line graphics intensive programs, I don't see a flaw. I think you did it. Way cool!  8)

Cheers,
VTwin
Title: Re: New version of BGRABitmap
Post by: circular on November 14, 2016, 02:57:35 pm
Thank you very much for testing!  :)

New version 9.2.3
- fixed opaque rendering on Canvas for MacOS
- avoiding some hints/warnings

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: esvignolo on November 14, 2016, 06:16:26 pm
I made a build of LazPaint for OSX (with this fixes), and now work well too :)

Thanks!

Thank you very much for testing!  :)

New version 9.2.3
- fixed opaque rendering on Canvas for MacOS
- avoiding some hints/warnings

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: circular on November 14, 2016, 11:32:30 pm
Cool! I hope we will be able to test LazPaint on MacOS for next release. Last time I could try on a Mac, I vaguely remember there was some problems with the multiple windows.
Title: Re: New version of BGRABitmap
Post by: lainz on November 15, 2016, 09:49:13 pm
Available in the three major desktop platforms, that's great! The next is to run it on android, at least not the full LazPaint but a similar application. Maybe the UI can be made in java Android Studio and use the bgrabitmap library.. I'm not sure I never programmed for android with Lazarus, only with Android Studio.
Title: Re: New version of BGRABitmap
Post by: circular on November 15, 2016, 11:46:25 pm
New version of BGLControls (v1.2):
- smoothing of elapsed milliseconds in TBGLVirtualScreen when SmoothedElapse property is set to True

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: lainz on November 15, 2016, 11:53:37 pm
Many thanks for this. I tried to make a game in Unity and there's no smooth by default (as far as I know). So it's a really nice addition. I don't understand half or more of things you code but well I at least can use the stuff you made.  ::)
Title: Re: New version of BGRABitmap
Post by: circular on November 16, 2016, 06:33:49 am
I am happy you like it.  :)

We are doing great progress together regarding OpenGL so thank you very much.
Title: Re: New version of BGRABitmap
Post by: Roland57 on November 16, 2016, 01:46:19 pm
@circular

Have you ever thought of extending BGRABitmap to Delphi?
Title: Re: New version of BGRABitmap
Post by: circular on November 16, 2016, 09:39:19 pm
Not really as I don't have latest version of Delphi. I am not even sure what is the latest version as the Delphi.NET has been more or less discontinued or something like that.
Title: Re: New version of BGRABitmap
Post by: Roland57 on November 16, 2016, 10:55:53 pm
The latest Delphi has a free version.  ;)

https://www.embarcadero.com/fr/products/delphi/starter/promotional-download
Title: Re: New version of BGRABitmap
Post by: lainz on November 17, 2016, 12:51:59 am
The latest Delphi has a free version.  ;)

https://www.embarcadero.com/fr/products/delphi/starter/promotional-download

Thankyou I'm downloading it.

Edit: as far as I tested the starter edition does not contains the sources, so it will be very hard to make bgrabitmap without reading how the graphics code of Delphi works (I think), you can rely only in the online documentation. Well at least it has autocomplete to get the public methods.
Title: Re: New version of BGRABitmap
Post by: circular on November 17, 2016, 01:27:33 pm
Oh that's interesting.  ::)
Title: Re: New version of BGRABitmap
Post by: jb007 on November 18, 2016, 09:45:16 am
Hi,

found this BGRABitmap also on google.

Question ( no details needed );

Can I extract the coulor of a pixel by using the x,y-position of a pixel?
Can I change the colour of pixels?

The picture should stay within Lazarus, once it is loaded!

Thanks in advance.
Title: Re: New version of BGRABitmap
Post by: lainz on November 18, 2016, 02:14:35 pm
Code: Pascal  [Select][+][-]
  1. Can I extract the coulor of a pixel by using the x,y-position of a pixel?
yes
Code: Pascal  [Select][+][-]
  1. Can I change the colour of pixels?
yes

Code: Pascal  [Select][+][-]
  1. var
  2.   c: TColor;
  3. begin
  4.   Bitmap.SetPixel(x, y, clRed);
  5.   c := Bitmap.GetPixel(x, y);
Title: Re: New version of BGRABitmap
Post by: jb007 on November 18, 2016, 05:37:01 pm
Thanks a lot!

For the moment, I know enough.

BGRAbitmap will be for a while later.
Looking forward to 'programm' in/with/on a bitmap.

Purpose is later to do picture-extracting: find objects etc...

Have done lot's of graphs/math in TurboPascal 7.0 ( no bitmaps, just 'on screen'  ).
The hardest thing for me is to get a picture taken by a cam, to get that in lazarus during running.
That''s for later.

For now, will continue with the RS232.

RS232 topic:
http://forum.lazarus.freepascal.org/index.php/topic,20481.180.html





Title: Re: New version of BGRABitmap
Post by: circular on November 22, 2016, 10:34:49 pm
Hello people!

Just to notify that bgrabitmap has been removed from "bgrabitmap/lazpaint" repository and is now only in "bgrabitmap/bgrabitmap" repository:
https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: lainz on November 22, 2016, 10:45:48 pm
Thanks for this  8)
Title: Re: New version of BGRABitmap
Post by: Lulu on December 02, 2016, 08:26:58 am
Hi,
thanks you for all BGRABitmap stuff !

@Circular : I have a question : why did you not keep ElapsedMs parameter in "TBGLCustomSpriteEngine.OnTimer" and "TBGLCustomSprite.OnTimer" ? Perhaps, it will be more convenient to move sprites according to time ?
(excuse me, english is not my mother tongue...^^)
Title: Re: New version of BGRABitmap
Post by: circular on December 02, 2016, 11:32:34 am
You're welcome  :)

Originally I made the sprite engine compatible with ZenGL that relies on a timer to move things around. So OnTimer is in principle for one timer interval like one tick.

However, it is possible to add an Elapse procedure to the sprite engine and to sprite classes that would be similar to OnTimer but would have an ElapsedMs parameter. Would that be useful for you?
Title: Re: New version of BGRABitmap
Post by: Lulu on December 02, 2016, 03:02:14 pm
Before to do any change in your library, could you tell me, for example, how to move a bird sprite along the diagonal of the screen in 5 seconds keeping calculation in TBGLCustomSprite.OnTimer without knowing the elapsed time ?

Thanks for yours answers
Title: Re: New version of BGRABitmap
Post by: circular on December 02, 2016, 03:45:29 pm
If you are calling OnTimer based on a timer component, then you need to know the time interval of the timer.

Otherwise, if you are using OnElapse event, then you can compute the number of intervals and call OnTimer for each interval. See for example TGameContext class in "test\test4lcl_opengl\tux_game":
Code: Pascal  [Select][+][-]
  1. procedure TGameContext.Elapse(ctx: TBGLContext; ms: single);
  2. begin
  3.   ...
  4.   elapsedMs += ms;
  5.   while elapsedMs > FrameDurationMs do
  6.   begin
  7.     ctx.Sprites.OnTimer;
  8.     elapsedMs -= FrameDurationMs;
  9.   end;
  10. end;
The variable "elapsedMs" is an accumulator of elapsed milliseconds. It is then subtracted with the time interval for each frame.

In both cases, for each OnTimer, consider that the time interval has elapsed.

Let's suppose the time interval is 15 ms. And let dist=1000 be the distance to go in pixels. And let time=5000 be the total time in milliseconds.

The speed of the sprite is dist/time = 1000/5000 = 1/5 pixels/ms

For one time interval, the distance to go is speed*interval = 1/5 * 15 = 3 pixels.

Note that this is a discretisation of time, that is handy for example to save replays and to do network games. But it does not provide really smooth animations.

To have really smooth animations, you would need to do the following:
- set the SmoothedElapse property of TBGLVirtualScreen
- have a somewhat constant framerate, i.e. a somewhat constant complexity of what you are rendering
- to move the sprite in the OnElapse event of TBGLVirtualScreen. You would then indeed need to transmit the elapsed milliseconds to the sprite.

Hence I was thinking about adding an OnElapse event for sprites as well. You could then use it instead of OnTimer to move the sprites accordingly. Then the code of the event would be:
Code: Pascal  [Select][+][-]
  1. procedure TGameContext.Elapse(ctx: TBGLContext; ms: single);
  2. begin
  3.   ...
  4.   ctx.Sprites.OnElapse(ms);
  5. end;

Of course, you would need to override the OnElapse function of the sprite instead of the OnTimer function.
Title: Re: New version of BGRABitmap
Post by: Lulu on December 02, 2016, 04:20:44 pm
Thanks for adding an OnElapse event for sprites.

Now, it will be easier for me to adapt my tools to your library.

Regards

 :)
Title: Re: New version of BGRABitmap
Post by: circular on December 02, 2016, 05:58:18 pm
Ok. That's done in "dev-bgrabitmap" branch.
Title: Re: New version of BGRABitmap
Post by: Lulu on December 02, 2016, 08:39:09 pm
Thanks very much you for the quality of your work and your quick answers !  :)
Title: Re: New version of BGRABitmap
Post by: circular on December 02, 2016, 09:27:40 pm
My pleasure.  :)
Title: Re: New version of BGRABitmap
Post by: circular on December 04, 2016, 08:48:48 am
New version 9.3 with:
- added support for multifile resources (BGRAWinResource for RES files, BGRALazResource for LRS files)
- added support for smooth elapsed time for sprites (OnElapse override)
- fixing compilation when SSE is not available

https://github.com/bgrabitmap/bgrabitmap/releases

Here is an example on how to use multifile resources:
Code: Pascal  [Select][+][-]
  1. uses Classes, BGRABitmapTypes, BGRAWinResource;
  2. var
  3.   res: TMultiFileContainer;
  4.   filestream: TStream;
  5. begin
  6.   res := TWinResourceContainer.Create('container.res'); //load the content of an existing RES file
  7.   res.Delete('MAINICON','ico'); //delete current MAINICON entry
  8.   filestream := TFileStream.Create('someicon.ico',fmOpenRead);
  9.   res.Add('MAINICON','ico', filestream); //replace it with another icon
  10.   filestream := TFileStream.Create('somecursor.cur', fmOpenRead);
  11.   res.Add('SOMECURSOR','cur', filestream); //add a cursor entry called SOMECURSOR
  12.   res.SaveToFile('container.res');
  13.   res.Free;  
  14. end;

Available file extensions natively supported for RES files are: ico, cur, bmp, dat (RCDATA), html, manifest, ani. Additionnally all image extensions supported by BGRABitmap are supported as well. They are stored as unformatted data (RCDATA) and the extension is detected automatically when reading existing files.

Available file extensions for LRS files: all extensions. LFM files are stored using binary format (FORMDATA) and extracted as text format.

Note: this allows in development version of LazPaint to read/write files inside resource files.
Title: Re: New version of BGRABitmap
Post by: lainz on December 04, 2016, 03:05:14 pm
I've tested it with dev-lazpaint and works very well opening and saving into existing .lrs

For example if I need to make an icon for a new lazarus component, I must create an empty .lrs and then save the bitmap into it?
Title: Re: New version of BGRABitmap
Post by: circular on December 04, 2016, 09:30:03 pm
Yes, you can do that as the icons for the components can be in PNG format.

I would also suggest to make one LRS file with all the icons.

Of course we are not talking ICO/CUR files for now, but I am working on it. Already I have added that the reader saves the hotspot and the xor mask. However LazPaint does not save into these formats yet. I hope to add that soon, so that all resource stuff could be done with LazPaint.
Title: Re: New version of BGRABitmap
Post by: lainz on December 04, 2016, 09:54:51 pm
That's good, well maybe we can store all the icons from the packages in a single one.
Title: Re: New version of BGRABitmap
Post by: Lulu on December 07, 2016, 02:24:32 pm
Hello all !

I have noticed there are some memory leak on tux-game demo. I put a break point on first line of procedure TBGLCustomTexture.FreeMemory , and it never been called. May be, textures are also not freed in video card memory ?

There is a mistake in the comment for the fonction "REPLACE" in "BGRABitmap" unit, line 135 ?
Code: Pascal  [Select][+][-]
  1. {    ...
  2.     BGRAReplace(temp, someBmp.Filter... );
  3.     ... }
  4.  

It should not be
Code: Pascal  [Select][+][-]
  1. {    ...
  2.     BGRAReplace(someBmp, someBmp.Filter... );
  3.     ... }
  4.  

Regards
Title: Re: New version of BGRABitmap
Post by: circular on December 09, 2016, 11:47:55 pm
VRAM is freed when the process ends but it would better to free it explicitely. Does it help to add in TGameContext.UnloadTextures(ctx: TBGLContext) the following?
Code: Pascal  [Select][+][-]
  1. texWalking := nil;
  2. texGround := nil;
  3. font := nil;
  4. bubbleFont := nil;

Correct. It is indeed
Code: Pascal  [Select][+][-]
  1. BGRAReplace(someBmp, someBmp.Filter... );
Title: Re: New version of BGRABitmap
Post by: Lulu on December 10, 2016, 11:30:21 am
no,it is the same. Heaptrc unit give 60 unfreed memory blocks at the end of program
Title: Re: New version of BGRABitmap
Post by: Lulu on December 10, 2016, 11:35:14 am
There is no memory leak if you put in brackets (comment) line 240 to 265 in procedure TGameContext.Render(ctx: TBGLContext).
Title: Re: New version of BGRABitmap
Post by: Lulu on December 10, 2016, 12:29:23 pm
it seem to come from the procedure TBGLRenderedFont.DoTextRect(X, Y, Width, Height: Single  in BGRAFontGL unit.

More there are lines in text to render, more there are memory block unfreed.

I don't do more than that because your code is too complex for me  :D
Title: Re: New version of BGRABitmap
Post by: circular on December 11, 2016, 10:20:24 pm
Thanks. I will have a look.
Title: Re: New version of BGRABitmap
Post by: DonAlfredo on December 19, 2016, 03:59:35 pm
Hi,

Small bug perhaps ...
On my system, with Lazarus trunk, this is needed to get things running:

Inside BGRAText.pas
change
uses GraphType, Math, BGRABlend, BGRAUTF8;
into
uses GraphType, Math, BGRABlend, BGRAUTF8, LCLPlatformDef;

to prevent an error on:
if WidgetSet.LCLPlatform = lpNoGUI then

Or do I have an old/wrong version of bgrabitmap ?
Title: Re: New version of BGRABitmap
Post by: lainz on December 20, 2016, 03:07:58 am
This is recent, and only happens with Lazarus trunk, seems that they're moving 'something' that breaks 'something else' as always.

If you have BGRABitmap 9.3 you have the latest.
Title: Re: New version of BGRABitmap
Post by: circular on January 16, 2017, 12:37:00 pm
Patch for LCLPlatformDef has been applied on Git (master and dev).

Regards
Title: Re: New version of BGRABitmap
Post by: Josh on January 16, 2017, 11:30:39 pm
Hi Circular,

Hope you can help; a while ago now I had a problem with error
"Scanline: out of bounds"
http://forum.lazarus.freepascal.org/index.php/topic,34228.msg224075.html#msg224075
This was fixed in an SVN update; however After downloading latest SVN 53956; it has returned.

I thought I would try the latest BGRABITMAP; but this has not helped.

The error is only showing on MAC using carbon widgetset.

The same project running on Windows with exactly the same revision number and same version of all components works fine.

Any thoughts ideas appreciated.

Title: Re: New version of BGRABitmap
Post by: lainz on January 16, 2017, 11:40:52 pm
There's no svn anymore, is now hosted on GitHub.
Title: Re: New version of BGRABitmap
Post by: Josh on January 17, 2017, 12:34:12 am
Hi Lainz

The SVN version is the Lazarus SVN Version

Bgrabitmap is 9.3  ( If I remember the number correctly).

Downloaded about 3hrs ago from
https://github.com/bgrabitmap/bgrabitmap

Odd thin Lazarus report BGRABITMAP as 9.3
Description on web page show 9.2.2

Title: Re: New version of BGRABitmap
Post by: lainz on January 17, 2017, 12:38:58 am
Oh I see, I mixed the stuff. So is a problem of a change in lazarus that breaks bgrabitmap right?

It's OK is 9.3, that description is about a commit about 2 months ago, not the actual release number.
Title: Re: New version of BGRABitmap
Post by: Josh on January 17, 2017, 02:26:15 am
Hi Lainz,

Yes that appears to be the problem; the change in lazarus svn has killed my application on osx carbon; and also killed lazarus; as once I get the error on opening project; lazarus becomes very odd; I cannot click any component on form; I cannot get lazarus about box Lazarus generates Violation error and exits.

Bug report is 31239.

I listed my previous post; which corrected after I downloaded a later SVN version this was back in October though; I have updated the SVN version many times since then; but now it has come back again....   But only on Carbon like before.

Odd one; so not an easy one to track down I suppose.

Title: Re: New version of BGRABitmap
Post by: circular on April 30, 2017, 06:06:18 pm
Hello people. It's been some time since last release.

So here is a new version of BGRABitmap (9.5)

Support for ICO and CUR formats :

added BGRAIconCursor unit to read, modify and create files with different icon sizes
handling XOR mask (loaded in the XorMask property of TBGRABitmap)
improved thumbnails to display Xor mask and cursor hotspot

Compilation fix for Lazarus 1.7

OpenGL :
fixes for GL shading language
added framebuffers (TBGLFrameBuffer class and BGLCanvas.ActiveFrameBuffer property)
added GetImage to retrieve bitmap from OpenGL surface
added FilterBlurRadial and FilterBlurMotion to OpenGL textures

SVG : memory leak and crash fix


https://github.com/bgrabitmap/bgrabitmap/releases/tag/v9.5
Title: Re: New version of BGRABitmap
Post by: Phoenix on April 30, 2017, 08:58:03 pm
Thanks a lot for your work !!!  :D
Title: Re: New version of BGRABitmap
Post by: circular on April 30, 2017, 09:14:54 pm
My pleasure. I am happy to have some time to do so.  :)
Title: Re: New version of BGRABitmap
Post by: CrazyDron on May 08, 2017, 08:01:53 pm
Good day!

Which versions of BGRABitmap and BGRAControls should I download to use with Lazarus 1.4.4 (fpc 2.x.x)?
And if BGRA{branch} supports arm/ce compiler?

Thanks.

UPD: Tried it with latest 1.6.4 Lazarus - controls works with OpenGL. So WinCE is going out...
Title: Re: New version of BGRABitmap
Post by: Awesome Programmer on May 09, 2017, 03:11:11 pm
Okay, I know this is an old post, but I need help. I am trying to install pascalSCADA and having trouble with it. I keep getting bunch of functions missing in BGRAUTF8 file like FileOpenUTF8. These functions are suppose to be located in the file LazFileUtils but they are not in there. So, has this issue been fixed? if so, where can downloaded the latest pascalSCADA or BGRA component. Thank you in advance.
Title: Re: New version of BGRABitmap
Post by: circular on May 09, 2017, 07:51:51 pm
Hello CrazyDron,

I try to keep BGRABitmap as much compatible as possible with previous versions. Do you get an error while compiling with the latest version BGRABitmap on Lazarus 1.4.4? Have you considered upgrading your copy of Lazarus?

Hello Awesome Programmer,

The problem may come from a backward incompatibility. Which version of Lazarus are you using? Note that you can try to patch BGRABitmap library by inserting {$UNDEF BGRABITMAP_USE_LCL} on the line before "interface" in BGRAUTF8 to avoid using Lazarus functions.
Title: Re: New version of BGRABitmap
Post by: Handoko on May 09, 2017, 08:04:18 pm
Sorry to interrupt. In Awesome Programmer's previous post, I suggested him (or maybe her) to update his Lazarus. But he didn't even try. His issue may not be an issue if he try to use the newer version of Lazarus. He was using a 4 years ago version of Lazarus.
Title: Re: New version of BGRABitmap
Post by: CrazyDron on May 09, 2017, 11:41:04 pm
Good day, circular.
Yes, I've got many errors in BGRAFreeType.pas:
    procedure TextOutAngle({%H-}ADest: TBGRACustomBitmap; {%H-}x, {%H-}y: single; {%H-}orientation: integer; {%H-}s: string; {%H-}c: TBGRAPixel; {%H-}align: TAlignment); override;
    procedure TextOutAngle({%H-}ADest: TBGRACustomBitmap; {%H-}x, {%H-}y: single; {%H-}orientation: integer; {%H-}s: string; {%H-}texture: IBGRAScanner; {%H-}align: TAlignment); override;
"no override" or some similar.
When I delete all error-overrides, somewhere (I don't remember) in this file I've got something like "idents no member".

Upgading to fpc3 in plans, but I don't know when.

I write specific project on WinCE, so trying fpc3 gots a many problem, especially with Cyrillic symbols.

And WinCE haven't consists OpenGL, so using BGRAControls is not possible...
Title: Re: New version of BGRABitmap
Post by: Awesome Programmer on May 10, 2017, 05:10:09 pm
Sorry to interrupt. In Awesome Programmer's previous post, I suggested him (or maybe her) to update his Lazarus. But he didn't even try. His issue may not be an issue if he try to use the newer version of Lazarus. He was using a 4 years ago version of Lazarus.

Hi Handoko
Sorry I didn't read your reply to my other post. Maybe your are right. I need to upgrade my Lazarus to the latest and the greatest. The only thing is I am running Lazarus on Linux and Lazarus was installed from the Operating System's repository. Lazarus in the repository is old and I am guessing they only update their repository whenever they release a upgraded version of their OS. I think, I will have to download Lazarus and try to install it on my own. Thank you for your reply on my other post.
Title: Re: New version of BGRABitmap
Post by: Handoko on May 10, 2017, 05:35:28 pm
Sorry I didn't read your reply to my other post.

No problem.

I guess you're using Ubuntu or its variant. Lazarus from their repository isn't up to date, it has been complained several times. You need to manually download and install from Lazarus official page:
http://www.lazarus-ide.org/index.php?page=downloads

If you're a Debian or Ubuntu user, you should download the deb release and install all the 3 deb files following the suggested order.

Some people has problem installing Lazarus on Ubuntu. Hope you won't be the unlucky one. But if you have problem, here are some info that may help:
http://forum.lazarus.freepascal.org/index.php/topic,34682.msg228051.html
http://forum.lazarus.freepascal.org/index.php/topic,36211.msg241045.html
http://forum.lazarus.freepascal.org/index.php/topic,36265.0.html
Title: Re: New version of BGRABitmap
Post by: Carver413 on May 11, 2017, 12:37:42 am
Sorry to interrupt. In Awesome Programmer's previous post, I suggested him (or maybe her) to update his Lazarus. But he didn't even try. His issue may not be an issue if he try to use the newer version of Lazarus. He was using a 4 years ago version of Lazarus.

Hi Handoko
Sorry I didn't read your reply to my other post. Maybe your are right. I need to upgrade my Lazarus to the latest and the greatest. The only thing is I am running Lazarus on Linux and Lazarus was installed from the Operating System's repository. Lazarus in the repository is old and I am guessing they only update their repository whenever they release a upgraded version of their OS. I think, I will have to download Lazarus and try to install it on my own. Thank you for your reply on my other post.
use fpcupdeluxe https://github.com/newpascal/fpcupdeluxe/releases/tag/v1.2.0a
Title: Re: New version of BGRABitmap
Post by: circular on May 12, 2017, 10:44:50 pm
"no override" or some similar.
Hmmm, override is not a new keyword. Does it say that there is nothing to override? In the case, it would not link this code with the more abstract class?
Title: Re: New version of BGRABitmap
Post by: circular on January 20, 2018, 02:57:44 pm
New version of BGRABitmap (9.6)

https://github.com/bgrabitmap/bgrabitmap/releases

Many thanks to phoenixfenix and lainz for their help.

Phoenixfenix did the class structure to implement gradients in SVG files.
In the BGRAControls package, Lainz made a component TBCSVGViewer to display an SVG file.
In BGRAControls, you will find a test program in the directory "test/svg_viewer".

If you want to display an SVG file by code, you can still refer to BGRABitmap "test/testcanvas2d" folder. It is as simple as:
Code: Delphi  [Select][+][-]
  1. uses BGRASVG;
  2. var bmp: TBGRABitmap;
  3. ...
  4.   svg := TBGRASVG.Create;
  5.   svg.LoadFromFile('Amsterdammertje-icoon.svg');
  6.   svg.StretchDraw(bmp.Canvas2D, taCenter,tlCenter, 0,0,bmp.Width,bmp.Height);
  7.   svg.Free;

Radial gradients are now implemented in Canvas2D property:

Code: Delphi  [Select][+][-]
  1.     function createRadialGradient(x0,y0,r0,x1,y1,r1: single; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;
  2.     function createRadialGradient(p0: TPointF; r0: single; p1: TPointF; r1: single; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;
  3.     function createRadialGradient(x0,y0,r0,x1,y1,r1: single; Colors: TBGRACustomGradient; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;
  4.     function createRadialGradient(p0: TPointF; r0: single; p1: TPointF; r1: single; Colors: TBGRACustomGradient; flipGradient: boolean=false): IBGRACanvasGradient2D; overload;

You can of course use TBGRAGradientScanner that was improved as well:
Code: Delphi  [Select][+][-]
  1. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  2. var
  3.   c1,c2: TPointF;
  4.   r1,r2: single;
  5.   scan: TBGRAGradientScanner;
  6. begin
  7.   //using screen center for first circle
  8.   c1.x := Bitmap.Width/2;
  9.   c1.y := Bitmap.Height/2;
  10.   r1 := min(Bitmap.Width,Bitmap.Height)/2;
  11.  
  12.   //using mouse position for second circle
  13.   c2.x := mx;
  14.   c2.y := my;
  15.   r2 := r1/4;
  16.  
  17.   scan := TBGRAGradientScanner.Create(c1, r1, c2, r2);
  18.   scan.SetGradient(CSSYellow, CSSGray);
  19.   Bitmap.Fill(scan, dmDrawWithTransparency);
  20.   scan.Free;
  21. end;  
Title: Re: New version of BGRABitmap
Post by: Phoenix on January 20, 2018, 04:52:24 pm
Thanks for this new release !!!  :D
Title: Re: New version of BGRABitmap
Post by: circular on January 20, 2018, 04:55:22 pm
Thank you for you help  :)
Title: Re: New version of BGRABitmap
Post by: balazsszekely on January 20, 2018, 04:57:47 pm
Hi Guys,

What is the fastest way to compare two BGRABitmaps? All I want to know if they are the same or not.

Thanks.
Title: Re: New version of BGRABitmap
Post by: circular on January 20, 2018, 05:02:14 pm
Hmm check if they have the same width and height, then CompareMem their data. Or use the Equals function of TBGRABitmap.
Title: Re: New version of BGRABitmap
Post by: circular on February 07, 2018, 08:48:07 pm
New version of BGRABitmap 9.6.1:
- Memory leak fix for SVG
- Polygon rendering fixes
- Gradient rendering fixes

Upgrade recommended if you're using polygons/shapes or SVG.

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: lainz on February 08, 2018, 02:05:34 am
Thanks!!!  :D
Title: Re: New version of BGRABitmap
Post by: circular on April 24, 2018, 01:45:06 pm
New version of BGRABitmap 9.6.2:

https://github.com/bgrabitmap/bgrabitmap/releases

Upgrade recommended if you're using BGRAIconCursor or text on Canvas2D.
Title: Re: New version of BGRABitmap
Post by: lainz on April 24, 2018, 02:00:57 pm
Thankyou!

Now we're all using OPM
https://forum.lazarus.freepascal.org/index.php/topic,34297.0.html

So you can tell @GetMem of the new version, so he can add it. (In OPM thread)

Also this website
https://packages.lazarus-ide.org/
Title: Re: New version of BGRABitmap
Post by: circular on April 24, 2018, 05:17:26 pm
Ok. I've posted a message on OPM thread.

I am not sure how I can notify lazarus-ide.org about the new version of the package?
Title: Re: New version of BGRABitmap
Post by: lainz on April 24, 2018, 05:38:01 pm
Ok. I've posted a message on OPM thread.

Thanks.

I am not sure how I can notify lazarus-ide.org about the new version of the package?

And is not necessary, because it uses the same data as OPM, so if it's updated in one place, it's updated in the other.
Title: Re: New version of BGRABitmap
Post by: circular on April 24, 2018, 06:55:36 pm
Ok cool
Title: Re: New version of BGRABitmap
Post by: lainz on April 25, 2018, 12:41:47 am
Ok cool

Yes, is really nice. Of course in the PC you develop BGRABitmap it has no sense to install it like that, but for all users is really simple to install with OPM.
Title: Re: New version of BGRABitmap
Post by: circular on April 25, 2018, 07:58:15 pm
Of course. So users don't have to check this thread
Title: Re: New version of BGRABitmap
Post by: lainz on April 25, 2018, 08:03:17 pm
Well, that depends, I think it depends on the interest of the user.

If you want to know what are the new features and bugfixes, you will check this thread. If not, you will simply update.

I think the same happens with Lazarus, I'm just paying attention to these features / bugs I reported or I want.
Title: Re: New version of BGRABitmap
Post by: circular on April 26, 2018, 06:47:39 pm
True.
Title: Re: New version of BGRABitmap
Post by: circular on May 17, 2018, 08:29:10 pm
New version of BGRABitmap 9.7 :

    added TextFitInfo that returns the number of char within a certain width
    added Bidi support i.e. right-to-left writing and a mix of LTR and RTL : the property FontBidiMode specifies how to handle base direction and it can be overriden by RightToLeft parameters
    added support for remaining TTextStyle options : ShowPrefix, EndEllipsis, RightToLeft
    fixed a bug with clipping and TextRect
    improvements on GIF editing, support for loop count
    faster loading of flat ORA and GIF
    added support for layered LZP
    improvement on TIFF reader (faster, support more files)
    fixed color for BMP 32 bit on Linux
    fix for gradients having one end being fully transparent

added text measurement functions for wordwrap:
Code: Delphi  [Select][+][-]
  1.     function TextSize(sUTF8: string; AMaxWidth: integer): TSize; override;
  2.     function TextSize(sUTF8: string; AMaxWidth: integer; ARightToLeft: boolean): TSize; override;
  3.     function TextFitInfo(sUTF8: string; AMaxWidth: integer): integer; override;  

https://github.com/bgrabitmap/bgrabitmap/releases

Here is a test program to check bidi support.

Upgrade note: before, the Linux version guess text orientation and Windows version assumed left-to-right. The new version by default guess text orientation but you can change it by setting TBGRABitmap.FontBidiMode to fbmLeftToRight to have the same result on Windows as before. Also you can add a parameter RightToLeft to text functions to override FontBidiMode for a specific call.

Other note: Bidi support works only for the LCL text renderer (the one used by default). It does not apply to TBGRAFreeTypeFontRenderer (used with NoGUI) nor TBGRAVectorizedFontRenderer (used with Canvas2d).

Regards
Title: Re: New version of BGRABitmap
Post by: circular on May 18, 2018, 07:19:44 pm
Sorry but I forgot to merge the dev branch into the master branch. Now its done.

Correct version is 9.7.2.
Title: Re: New version of BGRABitmap
Post by: lainz on May 18, 2018, 11:46:45 pm
Thanks. The other day I released about 5 versions of the same app, all fixing the previous. Is a hard thing to learn, releasing..., and do it alone, or with a small team...
Title: Re: New version of BGRABitmap
Post by: circular on May 19, 2018, 10:33:21 am
Indeed. It is a bit embarrassing. But the best way to avoid mistakes is to stop doing things.

But we are improving the release process. Thanks to online package manager, the problem of forgetting to merge the branch will not happen again as I can simply check the version number on it. If I change the JSON file at the same time as the package version, if it is merged it will be updated on OPM otherwise it will not.

Now for bugs, compiling issues, etc. the only way is testing and it takes as much time to test than to code. So it is a difficult choice: do we make our users wait longer for new features or do we make more releases?

As you mention we are working alone most of the time.
Title: Re: New version of BGRABitmap
Post by: circular on May 19, 2018, 10:45:09 am
By the way, Gilles Vasseur has made a component for image transition thats looks cool:
https://www.youtube.com/watch?v=bJeGVjZtHKk

Here is his blog (in French): https://www.developpez.net/forums/blogs/600183-gvasseur58/

 8-)
Title: Re: New version of BGRABitmap
Post by: gillou58 on May 19, 2018, 11:49:04 am
Thanks circular for your great job   ;)

As you have reported, I have made a component with your BGRABitmap library to show pictures with transitions and special effects. The link you mentioned is for my blog but it is in French. I suggest to people that are interested in this work to read tutorials : there are in French too but you have a button for the Microsoft Translator in the upper left corner of each tutorial.
Only the first one in on line. The following ones will come as soon as possible...

The source code of the component will be soon released too.

Link to the first tutorial :
https://gilles-vasseur.developpez.com/tutoriels/transitions/bgra1/ (https://gilles-vasseur.developpez.com/tutoriels/transitions/bgra1/)

Link to a video on Youtube to see the component in action :
https://www.youtube.com/watch?v=bJeGVjZtHKk&lc=z22tv5cxykfcifimyacdp435bjytzoio3cxzznk0bl1w03c010c (https://www.youtube.com/watch?v=bJeGVjZtHKk&lc=z22tv5cxykfcifimyacdp435bjytzoio3cxzznk0bl1w03c010c)

Gilles
Title: Re: New version of BGRABitmap
Post by: lainz on May 19, 2018, 04:30:21 pm
Beautiful component  :)
Title: Re: New version of BGRABitmap
Post by: Lulu on May 19, 2018, 09:44:03 pm
Hello,
Thanks Circular for your BGRABitmap library ! I learned pascal language in the 80s, only procedural programming. Then a long break ... I discovered object-oriented programming by discovering the nice Lazarus project, 7 years ago.
Quickly I came across your library and I was surprised to see everything I could do so easily with BGRABitmap !
So I looked at your code a bit and learned a lot about the concept of 'framework'. I still have a lot to learn !
I appreciate because the code is robust, reliable and always easy to use.
Thanks for your work !  :)
Title: Re: New version of BGRABitmap
Post by: circular on May 19, 2018, 11:31:11 pm
Lulu, I am pleased to learn about your journey with Pascal and that I somehow contributed to it. I remember when I learned this language by looking at existing programs. I am happy to achieve my aim to provide something easy to use.  :)
Title: Re: New version of BGRABitmap
Post by: Lulu on May 20, 2018, 10:17:27 pm
Hello,
It seems that TBGRATextEffectFontRenderer no longer draws the outline of the text. The issue appears after BGRABitmap update to 9.7.2.0 with OPM.
Below is a small project that reproduces the problem.
Title: Re: New version of BGRABitmap
Post by: circular on May 21, 2018, 10:47:34 am
Oh I see. Thanks for reporting. I have fixed it in version 9.7.3:

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: Lulu on May 21, 2018, 08:15:17 pm
after updated to 9.7.3 with OPM, I got compile error, see attachment below
Title: Re: New version of BGRABitmap
Post by: circular on May 21, 2018, 08:53:03 pm
Hmmm... something with overloads I suppose.

Does it help to add overload after the override keyword in the definition of TextOut in TBGRAVectorizedFontRenderer in BGRAVectorize:
Code: Delphi  [Select][+][-]
  1.     procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; s: string; texture: IBGRAScanner; align: TAlignment); override; overload;
  2.     procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; s: string; c: TBGRAPixel; align: TAlignment); override; overload;
  3.  

?
Title: Re: New version of BGRABitmap
Post by: Lulu on May 21, 2018, 09:01:48 pm
yes it work fine now !
Title: Re: New version of BGRABitmap
Post by: circular on May 21, 2018, 09:22:27 pm
Ok. That's fixed in version 9.7.4.

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: Josh on May 28, 2018, 01:59:33 am
Hi Circular,

Using BGRASVG. BCSVGAViewer

I seem to have a weird problem,
I am creating a control that has several states; like a button.

If I change the states using svg.loadfromfile Then the states changes.
So I thought I would load the svg into a text array, and use
svg.createfromstring; but this does not always change the state.
If I make my form update a label or control, then the createfromstring works.
i have also tried using AsUTF8String; and this does the same.
It's as though the drawing/rendering is not done when using these properties. Do I have to this manually after loading in the string?

Hope it makes sense


[SOLVED]
Forgot to call the BCSVGAViewer.RedrawBitmap   :-X
Title: Re: New version of BGRABitmap
Post by: circular on May 28, 2018, 02:03:08 pm
That may help  :D

Anyway, happy to see the component useful  :)
Title: Re: New version of BGRABitmap
Post by: lainz on May 29, 2018, 01:58:11 pm
@josh, you will share your component?

And a suggestion, maybe load all SVG into memory, and switch between them, because loading from disk is slower.. I don't think these use too much memory.


Edit: I readed it better, you're loading from string, good =)
Title: Re: New version of BGRABitmap
Post by: Josh on May 30, 2018, 04:20:30 am
Hi

My current 'component' Is not really geared towards a standard component, as it get changed via various triggers. I use the component purely for its events.

So I have been working on a version that I could use for a svg button using svgviewer as a template, the problem I have at the moment is that text property in object inspector appears to be limited to 1024 chars, I thought I could have 3 text properties normal,hover,down but need to think of another approach that does not have this limitation.

Maybe If I could utilize the text caption that statictext uses, but have not investigates to see how it creates the 'memo' popup dialog yet.

Title: Re: New version of BGRABitmap
Post by: lainz on May 30, 2018, 02:00:57 pm
You can use TStringList TStrings, like is used in TMemo and similar components.
Title: Re: New version of BGRABitmap
Post by: Josh on May 31, 2018, 01:04:08 pm
Hi Lainz,

Well progressing, slow mainly due to time constraints. And the fact that I do not normally create general components.

I have come across a couple of issues you may be able to help with.

1) How to get a component to draw itself when created, I think the issue is that the svg data is held in tstrings, and at what point do these values get populated on the creation a component, it seems that they are populated after the image has been rendered for the first time, I could be wrong though here.

2) I would like to group the extra properties in a 'Group' property to keep them clear of the normal properties, I created a Tpersistant class, but run into an issue as to how the properties in this class can access class variables in the main class. Not something I normally have to do, so any pointers would be appreciated.

I have googled and searched but I suspect i am searching for the wrong terminology, also only having an hour spare during working days does not help.. ;)
Title: Re: New version of BGRABitmap
Post by: lainz on May 31, 2018, 02:03:24 pm
1) Good question. Well, it will be easier to see the code. I did a component some time ago called TBGRAImageButton, that was using a resource image stored with the object inspector. And I did it work, so it must be the same, because you're creating from a resource.

https://sourceforge.net/p/bgracontrols/svn/1/tree/custombgraimagebutton.inc

Code: Pascal  [Select][+][-]
  1. procedure TCustomBGRAImageButton.SetFBmp(const AValue: TBitmap);
  2. begin
  3.   if FBmp = AValue then
  4.     exit;
  5.   FBmp.Assign(AValue);
  6.  
  7.   InvalidatePreferredSize;
  8.   AdjustSize;
  9.   Changed;
  10.  
  11.   Invalidate;
  12. end;

I see that in the setter of the Bitmap property, I call Invalidate that calls Paint event.

2) Create a group into a TPersistent

Code: Pascal  [Select][+][-]
  1.   TColorState = class(TPersistent)
  2.   private
  3.     FOwner: TControl;
  4.     FBorderColor: TColor;
  5.     FBorderWidth: integer;
  6.     FColor: TColor;
  7.     procedure SetFBorderColor(AValue: TColor);
  8.     procedure SetFBorderWidth(AValue: integer);
  9.     procedure SetFColor(AValue: TColor);
  10.   public
  11.     constructor Create(AOwner: TControl);
  12.   published
  13.     property Color: TColor read FColor write SetFColor;
  14.     property BorderColor: TColor read FBorderColor write SetFBorderColor;
  15.     property BorderWidth: integer read FBorderWidth write SetFBorderWidth;
  16.   end;  

Notice that you can't publish all things in "published" section, for example you can't publish TBGRAPixel.
Title: Re: New version of BGRABitmap
Post by: Josh on June 01, 2018, 04:54:33 am
Hi Lainz.

Attached In Progress package; which contains a simple demo.

It is not finished yet, but thought If I upload it you can have a look see.. ;)

IMPORTANT
ps You will need to move FSVG: TBGRASVG from protected to public in BCSVGViewer

attachment updated 2nd June 2018
Title: Re: New version of BGRABitmap
Post by: circular on June 01, 2018, 04:30:02 pm
Hi josh.

the following code:
Code: Delphi  [Select][+][-]
  1. if fsvgnormal = AValue then
compares the pointer values, but I suppose you want to compare the actual content.

It is not necessary to move FSVG from protected to public. As you derive the class, it has access to its ancestors protected fields. That's why there is such thing as "protected". It is better to avoid making it public because we don't want users to access it directly.
Title: Re: New version of BGRABitmap
Post by: Josh on June 01, 2018, 06:21:41 pm
Hi Circular,

Thanks for spotting that, if a change with fsvgnormal.text=avalue.text that should correct.

Sorry my mistake with FSVG in the SVGVIEWER it is in the PRIVATE section, not protected.
If I move it to the Protected Section then all OK.
Title: Re: New version of BGRABitmap
Post by: lainz on June 01, 2018, 09:46:23 pm
Hi, yes, that kind of problems are always easy to fix (private to protected). At least when these are not inside the LCL or something that we can't change at all...

I will try your component tomorrow, and see how it's going.
Title: Re: New version of BGRABitmap
Post by: Josh on June 02, 2018, 02:46:06 am
Hi Circular and Lainz.

I have upated the zip with the fixes and some extra properties, previous post has the updated zip. above

FileNameDown,FileNameHover,FileNameNormal. with these you enter the full path name to the svg file, the contents are then transferred to the svgstrings, and the property is then cleared.

Also a new test project and a folder containing the svg images used in the demo, these are not needed in the compiled app of course, just for convenience.
The demo contains 4 buttons covering the form, expanding/stretching the form to re-scale.

ps still need to move the FSVG from private to protetected.

pps should this really be in a new thread or something?
Title: Re: New version of BGRABitmap
Post by: Lulu on June 02, 2018, 04:30:39 pm
Hello,
When it is used TBGRATextEffectFontRenderer associated with TBGRABitmap.TextOut(), what is the good way to do text measurment ?
Does TBGRABitmap.TextSize () take into account the outline width and text shadows ?

Edit: I've just see that TBGRATextEffectFontRenderer have a TextSize method. I have to call this instead TBGRABitmap.TextSize ?
Title: Re: New version of BGRABitmap
Post by: circular on June 02, 2018, 05:08:57 pm
It is the same, TBGRABitmap.TextSize call the font renderer TextSize.

I suppose it is a bug in my library. But I don't understand why it's not working.  :'(

I will have a look again and see if I get it.
Title: Re: New version of BGRABitmap
Post by: lainz on June 02, 2018, 06:51:50 pm
Hi, it works really well on macOS =)

I will test it on Windows later. And I've changed FSVG to published in dev-bgracontrols branch.
Title: Re: New version of BGRABitmap
Post by: circular on June 02, 2018, 07:45:46 pm
You mean to protected?

On MacOS, the OpenGL stuff works well? That's cool
Title: Re: New version of BGRABitmap
Post by: lainz on June 02, 2018, 07:50:44 pm
You mean to protected?

On MacOS, the OpenGL stuff works well? That's cool

Yes, to protected.

And I've not tested OpenGL yet. I will try, I'm installing a lot of stuff and that takes time =)
Title: Re: New version of BGRABitmap
Post by: Lulu on June 02, 2018, 08:53:17 pm
I've made a small program to test TextSize associated with text outline and shadow.
The idea is  - create an TBGRABitmap with width and height equal to 1, and set the font name, height and style
                   - create an TBGRATextEffectFontRenderer, fill its parameter and assign to the previous bitmap
                   - resize the TBGRABitmap with the value returned by its own method TextSize('Hello !')
                   - then draw the decorated text on the bitmap at coordinates (0,0)
On Windows, the shadow and (large) outline are clipped.
Title: Re: New version of BGRABitmap
Post by: lainz on June 02, 2018, 09:57:18 pm
Hi, @circular, I did a small tests, and the test projects seems to work, except that some has invalid paths for images. I don't know yet how to fix that.. I'm like a newby with a new tool.

I can't install OpenGL package, maybe it requires a library or something I don't have.
Title: Re: New version of BGRABitmap
Post by: circular on June 03, 2018, 05:39:11 pm
Thanks Lulu for the test program. I found the source of the problem : the TextExtent function returns a height that is different from the full height specified for the font. I can scale the font but I need to investigate a bit more on this font size in order to make the same appearance on Windows and on Linux.
Title: Re: New version of BGRABitmap
Post by: lainz on June 03, 2018, 07:16:27 pm
I've tested more. I will add more build modes to test projects in all repositories, and screenshots as in the demo repository.

Working fine and fast. The problem was I was targeting Qt. Instead of Cocoa 64.

Not sure yet about opengl.
Title: Re: New version of BGRABitmap
Post by: circular on June 03, 2018, 07:25:10 pm
Thanks Lainz. It doesn't seem like you've push the changes yet.

So with Qt on MacOS, the colors are not correct?

I have applied a fix that tweaks the font height sent to the LCL Font (not on Windows though as it is already good). It's in the dev branch.

It seems now fine on Linux.

Yes Lulu, outline and shadows are clipped as they are not included in the font size. I guess it is normal that shadows would not be included, but I have a doubt about outlines. I can see why it would make sense to include outlines, as the font is somewhat bolder. However i does not really change the width/height of the text. It is more like an effect around the text. I will leave it like that because that's how it works now, but I agree it could be different.
Title: Re: New version of BGRABitmap
Post by: lainz on June 03, 2018, 07:48:33 pm
Hi, yes, I'm starting to do it now.

And yes, there are problems with colors with Qt. But let me add the build modes to be sure of what I'm compiling is what I expect =)

I noticed that material design works really good, animations are smooth too.

Well, let's start the thing!
Title: Re: New version of BGRABitmap
Post by: Lulu on June 03, 2018, 08:36:10 pm
Yes Lulu, outline and shadows are clipped as they are not included in the font size. I guess it is normal that shadows would not be included, but I have a doubt about outlines. I can see why it would make sense to include outlines, as the font is somewhat bolder. However i does not really change the width/height of the text. It is more like an effect around the text. I will leave it like that because that's how it works now, but I agree it could be different.
I understand and  that's fine like that !
I managed to work around this problem from the result given by TextSize () and taking into account the outline width, the shadow offsets and the value of ShadowRadius. That works well. See attachment.
Thanks you for your reply :)

I noticed that material design works really good, animations are smooth too.

Well, let's start the thing!
that's good ! :)
Title: Re: New version of BGRABitmap
Post by: lainz on June 03, 2018, 08:56:12 pm
Hi, I've started to add the 'macOS 64 cocoa' build modes for bgracontrols projects and fixing path issues, I think for linux and Windows we can just use the Debug and Release, since there's no issue on these OS, because it works fine with the default settings. What do you think?

And here the screenshots. @circular, maybe you can add linux screenshots?
https://github.com/bgrabitmap/bgracontrols/blob/dev-bgracontrols/README.md#screenshots-macos-64-cocoa

And maybe I will rest a bit today  ::)

Next time goes for BGRABitmap test projects and all tests in other packages.

@circular, I forget, to fix path issues just append: Application.Location + 'filename.someext'
Title: Re: New version of BGRABitmap
Post by: circular on June 03, 2018, 09:18:03 pm
@lainz: yes it is ok to have a build mode for MacOS. I don't know much about this build modes so I don't know if there is any other way.

Ok I will do screenshots for Linux.

Yeah have some rest my friend.

Quote
@circular, I forget, to fix path issues just append: Application.Location + 'filename.someext'
Ok.

@lulu: indeed it works fine adding the outline width / 2 and shadow size
Title: Re: New version of BGRABitmap
Post by: circular on June 04, 2018, 06:35:07 pm
New version of BGRABitmap (9.8 )

https://github.com/bgrabitmap/bgrabitmap/releases

Text/font:
- when splitting text, adding unicode orientation characters only when necessary and avoid infinite loop due to zero-width characters
- fixed font antialiasing gamma correction on linux
- fixed font full height on Linux

Bitmap/Canvas:
- added overload of PutImage to accept TBitmap parameter
- fixing alpha correction for Linux and MacOS (when drawing using LCL Canvas)
- optimized DrawPart (useful on Linux to update portion of virtual screen)

Miscellaneous:
- explicit overload for GetPixelCycle
- avoid some compiler bugs
- optimized blending functions (overall rendering speed on TBGRABitmap should be better)
- fixed SSE code for 64bit CPU
- fixed SVG rendering when Canvas2D has a transform
- other minor changes

Layers: started an class hierarchy for adding custom classes to the layer system (work in progress).
Title: Re: New version of BGRABitmap
Post by: lainz on June 04, 2018, 06:59:57 pm
Hi, I'm having problems to compile BGRABitmap and BGRAControls in trunk. I've added 2 bug reports, I will try to solve the BGRAControls one.
Title: Re: New version of BGRABitmap
Post by: circular on June 05, 2018, 12:17:28 am
I answered to one issue. I don't see another.
Title: Re: New version of BGRABitmap
Post by: lainz on June 05, 2018, 12:18:01 am
I answered to one issue. I don't see another.

Hi, the other was in BGRAControls, but I solved it reverting one change.
Title: Re: New version of BGRABitmap
Post by: circular on June 05, 2018, 12:27:59 am
Oh ok.

I am waiting for you confirmation it compiles well on your side to do another release.
Title: Re: New version of BGRABitmap
Post by: lainz on June 05, 2018, 12:38:34 am
Yes. It works fine now.
Title: Re: New version of BGRABitmap
Post by: circular on June 05, 2018, 12:43:58 am
Thank you.  :)

So here is a new release (9.8.1) that fixes compilation.
https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: lainz on June 05, 2018, 12:52:00 am
Thanks, let's play making cool stuff with it!! =)
Title: Re: New version of BGRABitmap
Post by: circular on June 05, 2018, 01:23:05 am
 :)

Oh I forgot to mention that from version 9.8, the font full height is fixed on Linux.

Before that, FontFullHeight and FontEmHeight had the same effect. Both where in fact the partial font height, or em font height.

If Linux applications were setting FontFullHeight (expecting to mean in fact the em height), now the font will be smaller, as it is on Windows.

So while this make Linux and Windows version consistant, it may give surprising results on Linux.

To fix a Linux application, replace FontFullHeight by FontEmHeight when setting the font size and you will get the same size as before.

Sorry for the inconvenience. The bug has just been spotted.

8-)
Title: Re: New version of BGRABitmap
Post by: lainz on June 05, 2018, 03:07:13 am
Thanks!

It's getting better every day.

Attached is what I say by making a WYSWYG component that can be duplicated or placed in several places by code.
Title: Re: New version of BGRABitmap
Post by: circular on June 05, 2018, 10:38:36 am
Oh I see, that's cool  :)
Title: Re: New version of BGRABitmap
Post by: lainz on June 05, 2018, 05:44:12 pm
Thanks! Well, I will see what can build with that..

About macOS and OpenGL, seems that it will be deprecated https://forum.lazarus.freepascal.org/index.php/topic,41492.msg287965.html#msg287965

And a fast read about it (now we must use Metal on macOS)
https://appleinsider.com/articles/18/06/04/opengl-opencl-deprecated-in-favor-of-metal-2-in-macos-1014-mojave

Or maybe Vulkan as well?

So there's no need to test that. At least I think that.
Title: Re: New version of BGRABitmap
Post by: circular on June 05, 2018, 11:45:14 pm
Alright. Maybe one day we can add support for Metal on MacOS.
Title: Re: New version of BGRABitmap
Post by: howardpc on June 06, 2018, 10:32:55 am
@lainz
Your dynamic_controls.zip includes several excellent techniques, but has a serious memory leak.
I attach a project adapted from your code, which is slightly simpler with fewer dependencies and no leaks.
Title: Re: New version of BGRABitmap
Post by: lainz on June 07, 2018, 11:09:17 pm
@lainz
Your dynamic_controls.zip includes several excellent techniques, but has a serious memory leak.
I attach a project adapted from your code, which is slightly simpler with fewer dependencies and no leaks.

Thankyou.
Title: Re: New version of BGRABitmap
Post by: lainz on June 16, 2018, 02:58:27 pm
Hi Lainz.

Attached In Progress package; which contains a simple demo.

It is not finished yet, but thought If I upload it you can have a look see.. ;)

IMPORTANT
ps You will need to move FSVG: TBGRASVG from protected to public in BCSVGViewer

attachment updated 2nd June 2018

I forget about this. You want this to be added to BGRAControls?
Title: Re: New version of BGRABitmap
Post by: Josh on June 16, 2018, 10:33:35 pm
Hi Lainz,

The component is being added to as I find more uses for it.

I have attached the current version which you can test and include if you wish.

Some of the properties.
SVGDownXML Brings up a memo to put in the svg code for your image.
FileNameDown path and filename of the image.

Position, Maximum : Integer value that I have used to allow it to be used with some of my other code, that are not components like a volume fader.
Information1 and 2 Text information stored within the control, I tend to control external devices and I use these to add an the actual command the control does, it just makes it easier for me, whether others may find it useful??



Title: Re: New version of BGRABitmap
Post by: Josh on June 16, 2018, 10:53:14 pm
quick vid showing the buttons in one scenario
Title: Re: New version of BGRABitmap
Post by: lainz on June 16, 2018, 10:55:53 pm
Hi, I will add it now to the package. Thanks for sharing it.
Title: Re: New version of BGRABitmap
Post by: circular on August 20, 2018, 06:43:25 pm
New version of BGRABitmap (9.9) with:

Unicode text

Full support for Unicode bidirectional text. The unit BGRAUnicode implements the bidirectional algorithm. You won't need to access it directly in most cases. The unit BGRAUTF8 contains new functions to use these features with UTF8. In particular:
- AnalyzeBidiUTF8 that returns an array with bidirectional analysis. You can specify if text is to be assumed RightToLeft or leave it as automatic.
- GetUTF8DisplayOrder will give you the display order of characters, supposing there is no line break (in this case it is a bit more complicated and there is a unit BGRATextBidi for that). For example, a text in hebrew will be displayed from right to left.
- UTF8OverrideDirection adds special unicode characters around the text to change it's direction. For example "hello" would be displayed as "olleh".
- UTF8EmbedDirection adds special unicode characters to make it a quote in a specific direction. For example you can add a quote in arabic that will be right to left inside a text in latin alphabet. This is useful for example if there is punctiation at the end of the quote, so that it will be displayed on the correct side.

The unit BGRATextBidi computes the layout of text. Basically you create the class TBidiTextLayout with a certain UTF8 string. It will analyse it and count paragraphs. You can then set paragraph alignement for each paragraph. There are also simple formatting options like the maximum width and the paragraph spacing. Tab characters are handled and you can set the size of tabs in number of corresponding spaces via TabSize property. This class can be used to compute the height of the text with its TotalTextHeight property.

It can render the text, caret and selection. There is a sample program in test\testbiditext2 that shows some minimalist text editor using this layout. Note that the paragraph alignment is lost when text is changed. To do a proper text editor one would need to create one TBidiTextLayout class for each paragraph and arrange them as you see fit. You can get the information about where paragraphs start and end from the bidi text analysis or by looking at the paragraph separators (cf function IsUnicodeParagraphSeparator of BGRAUnicode).

TBGRABitmap provides new text function TextMultiline to use this layout. So you can display bidirectional text with paragraph spacing. It supports FontOrientation whereas TextRect always displays text horizontally. Note that there is a new alignment type called TBidiTextAlignment that adds btaNatural and btaOpposite alignements. Natural means that LeftToRight text will be left-aligned and RightToLeft text will be right-aligned. Opposite means it will be the other way around. btaNatural is to be used by default when there is no particular formatting.

On Linux, text measurement is slow, so if you want speed, better use TextOut or TextRect when possible. Note that if text contains bidirectional formatting, it will fallback to TBidiTextLayout class anyway. However, TextRect will not fare well with multiple paragraphs because each paragraph may have a different text direction but TextRect cannot handle that.

Colorspaces

BGRABitmap supports more colorspaces and color conversions. Special thanks to Okoba for providing color conversions and code generation.

The directory test\colorspace contains two sample projects. ColorsDemo shows color values for all colorspaces and their conversion in real-time. HorseShoe shows a gradient in each colorspace and their gamut on the xy horseshoe diagramm.

For now, a TBGRABitmap is only in sRGB colorspace (TBGRAPixel). It is possible however to convert from an array in memory from any colorspace to any other colorspace. So you can store an image in any colorspace, and quickly display it by calling the adequate conversion. This process is used in the Horseshoe program to display a gradient in any colorspace.

Available colorspaces are:
- StdRGB also called sRGB. That's the colorspace used by most file formats.
- AdobeRGB which is an approximation of Adobe RGB colorspace.
- StdHSL and StdHSVA are HSL and HSV colorspace based on sRGB. That's the cylindrical representation hue/saturation/lightness or value. Those are the values you will find on the web when describing a color.
- StdCMYK is a theoretical Cyan-Magenta-Yellow-Black colorspace based on sRGB. It is not accurate for describing real printing colorspaces, but it is an interesting representation that is sometimes used. In fact, there is no formula to compute real CMYK values, one need conversion tables that are provided by color profiles, not handled yet by BGRABitmap.
- LinearRGB is the RGB colorspace but with gamma correction. RGB values varies proportionaly to the percieved brightness of the color.
- HSLAPixel is the HSL colorspace but based on linear RGB. Values will differ from values found on the web but they are more representative of color perception.
- GSBAPixel is yet another improvement on HSLAPixel so that the lightness is replaced by the actual brightness of the color. Indeed, depending on the hue, the fully saturated color will be darker or brighter. Blue is dark and yellow is bright. This colorspace that it into account, so that if you do a hue shift, the image will keep the same brightness. Low resolution JPEG can be thus manipulated without having artifacts due to the loss of precision.
- XYZ is the colorspace that includes all possible colors. It is a linear transformation of linear RGB, so that in theory one could also store all colors in linear RGB, though by using negative values. XYZA is used as a neutral colorspace to convert to any colorspace.
- Lab is a colorspace that encompasses most colors and that reflects human perception: L for lightness, a for red/green contrast and b for yellow/blue contrast. That's how the eye perceive colors by computing contrasts. Note that Lab has a "reference white" which is the color that is perceived as white in XYZ colorspace. The reason is that depending an the ambiant lighting, the perceived color will change.
- LCh is kind of an equivalent of HSV colorspace but based on Lab.

Layer system

In order to go in the direction of vectorial graphics, the TBGRALayeredBitmap can have its layers generated by an "original" that can be an image, an SVG, or anything that can generate an image. The original is transformed according to an affine transformation. Originals are stored in the serialized file and also in LazPaint format. Note that LazPaint format is now available within BGRABitmap by using unit BGRALazPaint. The class TBGRALazPaintImage contains the layer system and the originals and can load/save files used in LazPaint. Though LazPaint does not handle the originals yet, so even if it will load the images with originals, when saving the originals would be lost.

You can also create your own originals by deriving the class TBGRALayerCustomOriginal from the unit BGRALayerOriginal. You can look at the originals provided in BGRALayerOriginal, BGRAGradientOriginal and BGRASVGOriginal units to see examples, and as well in the demo repository in the Superformula program made by Lainz. By the way special thanks to him for testing BGRABitmap on Windows and on MacOS.
https://github.com/bgrabitmap/demo/tree/master/superformula_ui

There is also a test project in the folder test/layeroriginal that shows how to use an SVG file.

Polygon filling

There are two modes to fill polygons, winding and alternate. While most of the time winding is good enough, sometimes you want alternate. Problem is that polylines do not render well with alternate. Now when you specify alternate fill mode to draw a shape, it will be filled with alternate fill mode, but the stroke around it will be using winding fill mode. So that you can have both of the best worlds.

This goes with an improvement of TBGRAMultishapeFiller of unit BGRAPolygon. Now adding a shape return an index to it, and you can override its fill mode by calling OverrideFillMode. So you can mix fill modes.

Miscellaneous

- FreeType: added a patch to render text with angle with FreeType. Useful with NoGUI.
- TColor: when converting using ColorToBGRA, system colors are now automatically converted into RGB.
- Old Lazarus: added helpers so that you can compile projects with Lazarus 1.6 that make use of TRect.Width and the like.
- Cubic Bézier: optimization of the computation of the curve (thanks to PFradin)

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: circular on August 20, 2018, 06:59:56 pm
I forgot the screenshots. Here they are.
Title: Re: New version of BGRABitmap
Post by: lainz on August 20, 2018, 08:32:17 pm
Thanks.
Title: Re: New version of BGRABitmap
Post by: circular on August 20, 2018, 09:16:15 pm
 :) Colorspace and unicode have been waiting for a long time. I am happy to finally publish that.

I hope there is no bug.
Title: Re: New version of BGRABitmap
Post by: lainz on August 20, 2018, 09:39:17 pm
I like bugs, seems that I'm a 'Tero' (Vanellus chilensis).
Title: Re: New version of BGRABitmap
Post by: circular on August 20, 2018, 10:22:48 pm
 :D

Beautiful bird
Title: Re: New version of BGRABitmap
Post by: lainz on August 21, 2018, 08:12:01 pm
I like more the winged serpent, but that is just an untold history...
Title: Re: New version of BGRABitmap
Post by: circular on August 21, 2018, 08:32:08 pm
This one?  :)
Title: Re: New version of BGRABitmap
Post by: Phoenix on August 21, 2018, 10:02:35 pm
Release very impressive.
Thanks so much!!!  :D
Title: Re: New version of BGRABitmap
Post by: lainz on August 21, 2018, 10:23:38 pm
Thanks for the point of view, mythology seems more difficult from that is in reality.

Again thanks for your help.
Title: Re: New version of BGRABitmap
Post by: circular on August 22, 2018, 09:40:53 am
Release very impressive.
Thanks so much!!!  :D
Glad you like it. That was a lot of work.  :)

Again thanks for your help.
Well you help me as well.  8-)
Title: Re: New version of BGRABitmap
Post by: Lulu on August 29, 2018, 10:45:21 pm
Awesome  release !
However, I have a compilation error (win10, 64b, Laz 1.8.0)
Quote
Compiler le paquet BGRABitmapPack 9.9 : Code de sortie 1 - Erreurs : 1 - Conseils : 2
bgracustombitmap.inc(1096,24) Error: Identifier not found "GetFirstStrongBidiClass"
generatedcolorspace.inc(4072,34) Hint: Mixing signed expressions and longwords gives a 64bit result
generatedcolorspace.inc(4075,34) Hint: Mixing signed expressions and longwords gives a 64bit result
Title: Re: New version of BGRABitmap
Post by: circular on August 30, 2018, 02:43:14 pm
Hmmm, I don't understand because I don't see GetFirstStrongBidiClass identifier in the code. Can you copy and paste what you have in bgracustombitmap.inc on line 1096 and around it?
Title: Re: New version of BGRABitmap
Post by: Lulu on August 30, 2018, 03:49:50 pm
Code: Pascal  [Select][+][-]
  1. function TBGRACustomBitmap.GetTextureGL: IUnknown;
  2. begin
  3.   result := nil;
  4. end;
  5.  
  6. function TBGRACustomBitmap.GetFontRightToLeftFor(AText: string): boolean;
  7. begin
  8.   case FontBidiMode of
  9.     fbmAuto: result := GetFirstStrongBidiClass(AText) in[ubcRightToLeft,ubcArabicLetter];
  10.     fbmRightToLeft: result := true;
  11.   else
  12.     {fbmLeftToRight}
  13.     result := false;
  14.   end;
  15. end;
  16.  
  17. procedure TBGRACustomBitmap.InternalArc(cx, cy, rx, ry: single;
  18.   const StartPoint, EndPoint: TPointF; ABorderColor: TBGRAPixel; w: single; AFillColor: TBGRAPixel; AOptions: TArcOptions;
  19.   ADrawChord: boolean; ATexture: IBGRAScanner);
  20. var angle1,angle2: single;
  21. begin
  22.   if (rx = 0) or (ry = 0) then exit;
  23.   angle1 := arctan2(-(StartPoint.y-cy)/ry,(StartPoint.x-cx)/rx);
  24.   angle2 := arctan2(-(EndPoint.y-cy)/ry,(EndPoint.x-cx)/rx);
  25.   if angle1 = angle2 then angle2 := angle1+2*Pi;
  26.   InternalArc(cx,cy,rx,ry, angle1,angle2,
  27.               ABorderColor,w,AFillColor, AOptions, ADrawChord, ATexture);
  28. end;
  29.  

GetFirstStrongBidiClass is used in function TBGRACustomBitmap.GetFontRightToLeftFor.
this issue appear when I have updated BGRABitmap library with OPM
Title: Re: New version of BGRABitmap
Post by: circular on August 30, 2018, 04:11:25 pm
Strange. That seems to be version 9.8.1 of this file. I would suggest to compare with current release or master branch:
https://github.com/bgrabitmap/bgrabitmap/archive/v9.9.zip

Are there other files that are not up-to-date?
Title: Re: New version of BGRABitmap
Post by: Lulu on August 30, 2018, 04:40:15 pm
Yesterday, I updated only BGRABitmap with OPM and not BGRAControl and BGRAControlFX, and today, I have updated the 3 ones and now all works fine.  :)
Title: Re: New version of BGRABitmap
Post by: Lulu on August 30, 2018, 04:58:58 pm
Biditest, Biditest2, LayerOriginal, all color space demo works fine !
you did a good job again !
Title: Re: New version of BGRABitmap
Post by: circular on August 30, 2018, 06:13:44 pm
Cool.  :)

Thanks for the feedback. Good to know it works for you as well  8-)
Title: Re: New version of BGRABitmap
Post by: circular on October 25, 2018, 07:28:10 am
New version 9.9.1 :

Bezier curves/ellipses
- optimization of quadratic Bézier curve
- drawing/computing ellipses with non orthogonal axes
- aliased ellipse with pen width
- added TRationalBezierCurve (see test/rationalbezier)
- added TEasyBezierCurve and ssEasyBezier spline style (see test/bgraaggtest/bspline and toggle EasyBezier)

Improvements on layer originals
- fixes for bounds, editor bounds functions
- partial rendering of original
- added storage of subobjects and for float arrays
- more events in editor
- alternate color for right-button points

Affine boxes
- added TAffineBox.GetRectBoundsF
- added TAffineBox.GetSurface
- fixed TAffineBox.Contains when box is not orthogonal
- affine matrix from vectors

Compatibility for old Lazarus
- equal "=" operator for TRect
- functions for TRectF

Miscellaneous
- fixed bug with multishape without polygon order
- in Canvas2d, use fillmode to determine if point is in polygon
- patch for TRectF.Union
- fixed compilation for fpGUI
- fixed compilation for Linux

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: circular on November 11, 2018, 09:01:33 am
New version of BGRABitmap v9.9.2.

Miscellaneous:
- fixed bug with strecthed PutImage on Gtk
- fixed bug with zero-size stream in TMemDirectory
- opacity scanner can own its subscanner
- added one case for aliased RoundRect

Layer originals:
- fixed runtime errors due to undefined values
- fixed storage of gradient repetition
- saving original as well when there is one layer only
- reducing a bit clickable areas of points
- improved gradient editor
- Duplicate function
- orientation of size cursor
- finer bounds of shapes and arrows

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: Phoenix on December 09, 2018, 05:03:11 pm
I'm a little late  :-[ but thanks for these welcome improvements to the library  :D!!
Title: Re: New version of BGRABitmap
Post by: Josh on December 11, 2018, 01:29:04 pm
Hi Circular,

Something has happened in either bgrabitmap,bgracontrols, or latest trunk of carbon widgetset.

If I place a TBGRAShape ona  form, it is not drawn on ide or when compiled, it has no corners, border coloring does not work, and background coloring does not work.
Doing same on windows and cocoa on mac is working.

I am not sure if its latest trunk, bgrabitmap or bgracontrols.

Apologies for being vague.

Also it does the same with BCRadialProgressBar.

i386-darwin-carbon  fpc 3.3.1  svn 59789.


Update---
I have an older laz installation rev 59686; which works fine on carbon.
So I think its a Laz Issue.


Also tried cross compiling from cocoa 64 to carbon 32 and get the same problem
Title: Re: New version of BGRABitmap
Post by: circular on December 14, 2018, 05:06:30 pm
Hi josh. Does it help to go in the package and to a clean build?
Title: Re: New version of BGRABitmap
Post by: Josh on December 14, 2018, 05:59:31 pm
Hi Circular,

It does not make a difference, I have even deleted the package lib folder to remove all compiled code, and forced a clean rebuild.
Note this on Trunk version. ( same on updating my existing trunk install, and on a fresh trunk install).
My internet speed is not great, so I will attempt another FRESH Carbon Trunk install over the weekend.

I have tested RC2, and 1.8.5 of carbon i386 and these work fine, latest carbon trunk exhibits the problem, latest cocoa trunk is fine compiling for cocoa, but cross compiling back to carbon the problem is there, the shape is not drawn.

I am pretty sure its a trunk issue, and as the upcoming rc3 is due soon, I am concerned that the issue will move into RC3.

NOte used BGRABITMAP 9.8.2 and the latest, as well as 4.6.2 of bgracontrols and the latest 6 version, all are doing the same. and all work fine on rc2 and 1.8.5
Title: Re: New version of BGRABitmap
Post by: lainz on December 16, 2018, 03:07:42 pm
I'm not sure, because can be lazarus or can be FPC trunk as well.
Title: Re: New version of BGRABitmap
Post by: Windsurfer on December 17, 2018, 09:48:14 pm
I have just started looking at BGRABitmap. I used fpcupdeluxe to download and install it. Bgtools failed, with the error messages below. These may be relevant to the problems above.

/home/mike/Laz_Fixes/ccr/bgragames/./sound/src/uos.pas(1364,1) Warning: (5059) Function result variable does not seem to initialized
/home/mike/Laz_Fixes/ccr/bgragames/./sound/src/uos_flat.pas(851,1) Warning: (5059) Function result variable does not seem to initialized
/home/mike/Laz_Fixes/ccr/bgragames/./sound/src/uos_flat.pas(913,2) Warning: (5059) Function result variable does not seem to initialized
/home/mike/Laz_Fixes/ccr/bgragames/./sound/src/uos_flat.pas(1095,1) Warning: (5059) Function result variable does not seem to initialized
/home/mike/Laz_Fixes/ccr/bgragames/./sound/src/uos_flat.pas(1214,1) Warning: (5059) Function result variable does not seem to initialized
/home/mike/Laz_Fixes/ccr/bgragames/bgtools.pas(260,8) Error: (5000) Identifier not found "MulDiv"
/home/mike/Laz_Fixes/ccr/bgragames/bgtools.pas(261,8) Error: (5000) Identifier not found "MulDiv"
/home/mike/Laz_Fixes/ccr/bgragames/bgtools.pas(262,8) Error: (5000) Identifier not found "MulDiv"
/home/mike/Laz_Fixes/ccr/bgragames/bgtools.pas(263,8) Error: (5000) Identifier not found "MulDiv"
bgtools.pas(359) Fatal: (10026) There were 4 errors compiling module, stopping
Fatal: (1018) Compilation aborted

I then looked in the packages and noticed and tried to install BGLControls and bgragames. Bgtools failed with the same errors.

Have I missed something?
Title: Re: New version of BGRABitmap
Post by: circular on December 18, 2018, 10:45:17 am
@josh:
What about posting a test program in the bugtracker?

@Windsurfer:
The MulDiv function may not be available but it is possible to write a replacement.
Title: Re: New version of BGRABitmap
Post by: Josh on December 18, 2018, 12:44:14 pm
Hi

Over the weekend I installed a fresh Trunk for carbon i386 59831.

This exhibit the same.

All you need to do is create a new application and place a TBGRASHAPE component on it.
You get a Blank Square, rather than a Black Lined Diamond shape.

TShape works fine.

I had thought about posting on bugtracker, do you post issue on bugtracker for lazarus whuch are 3rd party related?

Title: Re: New version of BGRABitmap
Post by: Windsurfer on December 18, 2018, 09:48:35 pm
I copied the MathRound and MulDiv functions from bgraGraphics into bgTools. bgraGames package now compiles and installs. bgTools appears to need another item in the uses clause, but I am not sure which.

For reference and to save a lot of grepping, should anyone want a quick fix drop the following into bgTools, and add them to the interface section.
Code: Pascal  [Select][+][-]
  1. function MathRound(AValue: ValReal): Int64; inline;
  2. begin
  3.   if AValue >= 0 then
  4.     Result := Trunc(AValue + 0.5)
  5.   else
  6.     Result := Trunc(AValue - 0.5);
  7. end;
  8.  
  9. function MulDiv(nNumber, nNumerator, nDenominator: Integer): Integer;
  10. begin
  11.   if nDenominator = 0 then
  12.     Result := -1
  13.   else
  14.     Result := MathRound(int64(nNumber) * int64(nNumerator) / nDenominator);
  15. end;
  16.  
Title: Re: New version of BGRABitmap
Post by: circular on December 19, 2018, 01:31:07 pm
All you need to do is create a new application and place a TBGRASHAPE component on it.
You get a Blank Square, rather than a Black Lined Diamond shape.

TShape works fine.

I had thought about posting on bugtracker, do you post issue on bugtracker for lazarus whuch are 3rd party related?
Hmm maybe we can try to narrow down a bit the issue. It seems to be related to transparency. What if you put in the OnPaint event of the form something like:
Code: [Select]
uses BGRABitmap, BGRABitmapTypes;

{ TForm1 }

procedure TForm1.FormPaint(Sender: TObject);
var
  bmp: TBGRABitmap;
  w: single;
begin
  bmp := TBGRAbitmap.Create(ClientWidth,ClientHeight);
  w := ClientWidth/10;
  bmp.EllipseAntialias(ClientWidth/2-0.5,ClientHeight/2-0.5,ClientWidth/2-w/2,ClientHeight/2-w/2,CSSBlack,w,CSSRed);
  bmp.Draw(Canvas,0,0,False);
  bmp.Free;
end;
?

@Windsurfer: On which repository is it? Maybe it can be updated
Title: Re: New version of BGRABitmap
Post by: Josh on December 20, 2018, 01:36:36 am
Hi Circular,

Changed the css color codes to cl color codes. and the form shows the painted eclipses.

The BGRAShae is still not drawn.

It is to do with the TBGRASHAPE component, as there components like tbcbutton render fine.

Hope that helps.
Title: Re: New version of BGRABitmap
Post by: circular on December 20, 2018, 06:14:25 pm
Hmm so that would not be related to the drawing on the Canvas but on the code that generates the image of the shape.

What if you replace in BGRAShape unit in TBGRAShape.Paint the line:
Code: [Select]
  FBGRA.FillTransparent;by
Code: [Select]
  FBGRA.Fill(clRed);?
Title: Re: New version of BGRABitmap
Post by: Josh on December 21, 2018, 12:31:29 am
Hi Circular,

If I change the code then It draws a Red Rectangle.

I have done some further tests, It does not draw the border or fill the color, if I create the cradient and set the option to draw the border and fill with fradient then it renders.

Some pics, I have tried differing Opacity values all have no effect.

The first one you cant see where the tbgrashape is on the form, setting the gradient otion it then renders.

Hope that helps track it down, please note that the same bgrabitmap and bgracontrols work fine on RC2 and 1.8.5, it the trunk version that is having the problem, in the IDE and in Compiled code.
Title: Re: New version of BGRABitmap
Post by: Josh on December 25, 2018, 12:32:57 pm
Hi

Just an update.

Problem is still in RC3 and latest trunk as of 25-12-18.

Tried latest BGRABITMAP and BGRACONTROLS, as well as previous versions I have that work fine in 1.8.5.

I also have issue with StringGrid not showing Border, whether this is related or not I do not know, i have created a Bug Report for the String Grid Issue 34761
Title: Re: New version of BGRABitmap
Post by: circular on December 26, 2018, 01:42:40 pm
If I change the code then It draws a Red Rectangle.

I have done some further tests, It does not draw the border or fill the color, if I create the cradient and set the option to draw the border and fill with fradient then it renders.
That suggests that the problem would be with the Canvas2d thing, maybe in case of solid color.

What do you get with the test/testcanvas2d program?
Title: Re: New version of BGRABitmap
Post by: circular on January 19, 2019, 06:10:30 pm
New version of BGRABitmap 9.9.3
https://github.com/bgrabitmap/bgrabitmap/releases

Added support for resources.

You can load bitmaps and other objects like SVG using the LoadFromResource function. It takes a filename as a parameter. Example:
Code: Delphi  [Select][+][-]
  1. var
  2.   FBmp, FPng, FIco: TBGRABitmap;  
  3. begin
  4.   FBmp := TBGRABitmap.Create;
  5.   FBmp.LoadFromResource('CIRCLE1.BMP');
  6.   FPng := TBGRABitmap.Create;
  7.   FPng.LoadFromResource('MYCIRCLE2.PNG');
  8.   FIco := TBGRABitmap.Create;
  9.   FIco.LoadFromResource('MYICON.ICO');
  10.   ...
Both Lazarus resources and Windows resources are checked. Note that if it is a Windows resource, the extension of anything other than BMP, ICO, CUR and HTML will be equivalent to DAT (RCDATA). So the following will do the same (on Windows resources) :
Code: Delphi  [Select][+][-]
  1.   FPng.LoadFromResource('MYCIRCLE2.PNG');
  2.   FPng.LoadFromResource('MYCIRCLE2.DAT');
  3.   FPng.LoadFromResource('MYCIRCLE2');
  4.  
I suggest to use the actual extension if it is known (here PNG) because this will be compatible with Lazarus resources and it will help determine the proper image reader.

Note that you can replace the BGRAResource instance with your own and get the resources from anywhere you like.

Note that for now loading ICO and CUR from Windows resources is only implemented with the LCL. They can be embedded though as DAT files.

Related to https://github.com/bgrabitmap/bgrabitmap/issues/51

Layered bitmaps

Can handle now unknown originals, i.e. originals which class is not registered in the application. This allows for example to modify an existing layered bitmap without loosing the information of the existing originals. For example, one can flip the layers, thus changing the matrix transform for the original even if the original itself cannot be interpreted.

- Some bug fixes
- the "=" operator for TGuid is now public.
- LayoutRect parameter added to original editor (Render and GetRenderBounds functions)
- added editor snap to grid
- added click event and cursor for editor points
- added key events

Stretching and co

Added StretchPutImageProportionally. Just supply the bounding rectangle and the image will be stretched while keeping its aspect ratio.

CrossFade has been slightly optimised.

Image loading

New image format added ifSvg for SVG files. You need to add unit BGRASVG in the uses clause to define the image reader. SVG are rendered at 96 DPI by default though you can change it in the reader properties.

Thumbnail code has been a bit refactored so that SVG can also be rendered as thumbnails.

Text rendering

- Fixed memory leak in TextMultiline function.
- Fixed last paragraph bounds in TBGRATextBidi.

In BGRACanvas2d:
- take into account horizontal font alignment
- raster text replacement when not using vectorized text renderer

So it is not necessary anymore to use TBGRAVectorizedFontRenderer for Canvas2d text, though using regular text renderer is slower and won't handle drawing the text outline (using stroke instead of fill).

Polygon filling

- Fixed a bug when joining densities of polygon (there could be a seam)
- Added angular gradient gtAngular (see screenshot)
- Fixed solid color case for aliased RoundRect

Misc

- Compilation fix for fpGui
- opaque draw fix for Qt on Mac
Title: Re: New version of BGRABitmap
Post by: lainz on January 19, 2019, 06:14:08 pm
Congratulations that looks great, and will help the loading from resources, I was using it already in some bgracontrols but now we can move on and use directly from bgrabitmap with no extra coding :)

That angular gradient fill looks good.
Title: Re: New version of BGRABitmap
Post by: circular on January 19, 2019, 08:56:29 pm
Thanks.  :)

I am progressing on LazPaint and VectorEdit. Some changes in the layered bitmaps will allow LazPaint to open an image with unknown layer originals, but preserve them, as long as there isn't any additional drawing on the layer of course.
Title: Re: New version of BGRABitmap
Post by: bills on January 24, 2019, 03:52:32 am
Great Work.
Title: Re: New version of BGRABitmap
Post by: circular on January 25, 2019, 12:49:49 am
Thanks. The challenge is stimulating.  :)
Title: Re: New version of BGRABitmap
Post by: Phoenix on January 27, 2019, 11:10:37 am
Many thanks!!  :D
Title: Re: New version of BGRABitmap
Post by: circular on May 16, 2019, 09:54:39 pm
New version of BGRABitmap 9.9.4
https://github.com/bgrabitmap/bgrabitmap/releases

- added constant BGRABitmapVersion and function BGRABitmapVersionStr
- added "releaser" program. It can automatically update the version of a project, package and JSON file.
See: https://forum.lazarus.freepascal.org/index.php/topic,45146.0.html

Font rendering:
- fixed bidi text for TextOutAngle function
- underline fix for some Linux fonts
- better handling of font quality/extent on Linux
- bidi support for vectorized font (so RTL text is handled but without ligature)

SVG:
- added good text support : spaces, spans, tref, positionning, gradients, bidi text, alignment, relative font size
- fixing style/attribute precedence
- using more typed values for attributes
- more generic linking system

Bidi text layout:
- keep paragraph alignment when modifying text using provided functions
- added untransformed functions
- refactoring into separate BGRAUnicodeText unit
- fix layout update when changing font bidi mode
- various fixes with empty text and end of lines

Layered bitmap:
- added A-Z special keys
- added LayerOriginalClass property
- fix editor focus

Miscellaneous:
- improved vectorize algorithm (better diagonals, parameter for diagonal width)
- PutImageAffine option to not use pixel-centered coords
- patch for TextFitInfo on old LCL
- fix SSE code for 64 bit
- added 3d test for software only
- using more inc/dec/include/exclude and Offset function to increase compatibility with Delphi
- fixing static functions
Title: Re: New version of BGRABitmap
Post by: circular on June 30, 2019, 03:10:02 pm
New version of BGRABitmap 10.1
https://github.com/bgrabitmap/bgrabitmap/releases

Colorspaces
Colorspaces were added some time ago, though you could not really use it to draw something, as anyway sRGB 8 bit was used. This release, introduces universal bitmaps and brushes. The types TCustomUniversalBitmap and TUniversalBrush can be used in principle with any colorspace. The following bitmap types are available:
- TBGRABitmap: sRGB, 8 bit per channel
- TGrayscaleBitmap: linear 8 bit grayscale. It now has drawing functions, so you can prepare a mask in 8 bit per pixel, avoiding to consume memory
- TExpandedBitmap: linear RGB, 16 bit per channel. It has more precision than TBGRABitmap and is linear, so that dmLinearBlend and dmDrawWithTransparency are equivalent.
- TLinearRGBABitmap: linear RGB, 32 bit per channel (single precision float). It has even more precision. Not really recommended though as it uses a lot of memory.
- TWordXYZABitmap: XYZ, 16 bit per channel. Can store any real and reflect color with great precision (see below for remarks about XYZ).
- TXYZABitmap: XYZ, 32 bit per channel (single precision float). It has even more precision and also a wider range, so that it can store fluorescent colors and light sources that would otherwise saturate.

XYZ is a colorspace that stores the actual stimulation of the average eye, relative to a max luminance (Y=1) considered as white. Fluorescent colors or light sources may have greater values for X/Y/Z so in this case you would rather use TXYZA floating-point format to avoid saturation. Otherwise, for most use cases, when the image represents an object reflecting daylight, TWordXYZA is sufficient.

The reference white is the color of an object that reflects all light, it depends on the illuminant. ICC recommends to use D50 as reference, which is a kind of natural daylight. While the reference white is always at Y = 1, its hue changes (X and Z values). So white is not necessary the simple value (1,1,1). This is only the case with the theoretical equal-energy illuminant (E).

So if you are not working with a specific illuminant, you would rather avoid defining colors as XYZ values. If they are in the RGB range, you can use automatic conversion and provide color constants as usual. Otherwise a convenient way is to use L*a*b* colors. For example those colors are outside of the RGB scope:
- TLabA.New(60,-145,45) is a deep mint color (greenish cyan)
- TLabA.New(90,0,140) is a deep golden yellow

While L*a*b* is convenient to specify colors, it is not so to merge colors and draw, so there isn't any bitmap that stores Lab values. Also it is worth noting that L*a*b* values do not have the exact same appearance depending on the illuminant. So I would rather use D50 to have the same values as ICC profiles.

If you want to change the reference white anyway, you can use SetReferenceWhite function. ReferenceWhite2E, ReferenceWhite2D50 and ReferenceWhite2D65 are provided as global variables.

It is also worth noting that in order to have the same values as most programs, the gamma value is now set to 2.2. This may give some gradients a different appearence, so you may want to switch back to the old 1.7 value or use your own with BGRASetGamma function.

When saving an image in XYZ colorspace, usual formats like PNG or BMP will result in colors being clipped or distorted. You need to use TIF format so that it will be saved in Lab colorspace. This format though is limited to -128..127 values for a and b, so unfortunately not all colors can be saved. If someone has an idea for a format, please let me know. You can use the Serialize/Deserialize function, though this would be readable by most programs and you need to take into account the endianness.

List of the changes
Universal bitmap:
- now TBGRACustomBitmap derives from TCustomUniversalBitmap
- TGrayscaleMask as well so it has drawing features
- brush can be customized as TUniversalBrush
- added bitmap types: TExpandedBitmap, TLinearRGBABitmap, TWordXYZABitmap, TXYZABitmap
- 16 bit/float colorspaces are saved by default as 16 bit when using PNG and TIFF format

Colorspaces:
- fixed color conversions by using gamma 2.2, D50 white point and chromatic adaptation
- bridged conversion via TExpandedPixel to reduced generated conversion code
- replace HasReferenceWhite function by GetFlags, fixed reference white point logic
- TIFF reader can handle L*a*b* colorspace
- added SpectrumRangeReflectToXYZA to get XYZ from spectrum range
- add check function for real colors in XYZABitmap unit
- can preserve hue when converting XYZ to RGB

Vectorized text:
- mirrored glyph when RTL context
- fix TexFitInfo, GetCharIndexAt
- ff ligatures

Layered bitmap:
- add render storage per layer for originals

SVG:
- handle xml:id alias to id
- container dimension applies to ComputedWidth/Height and Width/HeightAsPixels/Cm
Title: Re: New version of BGRABitmap
Post by: lainz on June 30, 2019, 05:55:16 pm
Amazing. The most complete library I've seen.
Title: Re: New version of BGRABitmap
Post by: circular on June 30, 2019, 05:59:59 pm
Thanks  :)
Title: Re: New version of BGRABitmap
Post by: Phoenix on July 02, 2019, 10:30:31 pm
There is a lot of work behind.
Thanks for this release  :) !!
Title: Re: New version of BGRABitmap
Post by: circular on July 04, 2019, 07:18:24 pm
Indeed a lot of work and a lot of love as well  :)

Here are some fixes (version 10.2):
- fix for lines with integer coordinates out of bounds
- fix TMemDirectory Rename and TLayeredBitmap Assign functions (LazPaint format related)
- raise exception when using empty scanner instead of infinite loop
- fix constant TBGRAGradientScanner when used with constant color
- fix scanner offset for dithering filter
- add PenStyleToBGRA function

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: circular on July 07, 2019, 09:19:04 pm
Quick fixes version 10.3
https://github.com/bgrabitmap/bgrabitmap/releases

- fix SVG format detection
- fix 3D matrix error
- fix BGLFont vertical swap
- fix compilation for FPC 3.0.0
Title: Re: New version of BGRABitmap
Post by: VTwin on July 08, 2019, 02:26:08 am
Many thanks for your excellent work circular!
Title: Re: New version of BGRABitmap
Post by: circular on July 08, 2019, 09:22:16 am
You're welcome.

Latest version of BGRABitmap need FPC 3.0.0 so Lazarus 1.6.0 minimum.

Can you help test LazPaint? Clicking around a bit?
Title: Re: New version of BGRABitmap
Post by: c-sanchez on July 08, 2019, 09:48:13 pm
Hi circular, I would like try the new beta of lazpaint, by now I can use just Porteus (slackware based distro), so can you make an XZM module for this? 32bits, if not problem.
Title: Re: New version of BGRABitmap
Post by: circular on July 08, 2019, 11:05:06 pm
Hmm I have no idea about XZM.

Well I suppose you can test it without installing it.

I have added the plain binaries in the release (see Assets and then no_install archives):
https://github.com/bgrabitmap/lazpaint/releases/tag/v7.0.1
Title: Re: New version of BGRABitmap
Post by: fcu on July 08, 2019, 11:57:50 pm
@circular thank you for this great library
i just tested lazpaint 7.0.1 on windows 32bits , but seems moving the canvas (picture) with right mouse button is not working !!
can you check ?
Title: Re: New version of BGRABitmap
Post by: circular on July 09, 2019, 03:59:42 pm
@fcu: My pleasure  :)

Are you trying to move the picture using the hand tool?

In principle the right button would work, though it is not really intended for. The left button is the normal button. Otherwise, you can use the middle button to move the canvas from any tool.
Title: Re: New version of BGRABitmap
Post by: fcu on July 09, 2019, 08:01:00 pm
ops my fault , i mean left button
zooming in/out works ok with mouse wheel , but moving the canvas is not working
also middle button doesn't work
Title: Re: New version of BGRABitmap
Post by: fcu on July 09, 2019, 08:05:00 pm
image
Title: Re: New version of BGRABitmap
Post by: circular on July 09, 2019, 09:47:02 pm
Strange. I don't have this bug on Linux 64. @Lainz, do you have this as well?
Title: Re: New version of BGRABitmap
Post by: c-sanchez on July 09, 2019, 10:47:13 pm
Hmm I have no idea about XZM.

Well I suppose you can test it without installing it.

I have added the plain binaries in the release (see Assets and then no_install archives):
https://github.com/bgrabitmap/lazpaint/releases/tag/v7.0.1
Many many thanks for that circular, that no_install works  :D

So here my thoughs
The toolbar icons are newer right or is my idea?
Thanks by add the 'disable anti aliasing' option :) I'm sure this was so much requested hehe
Thanks by the ratio option too :)

I wonder, will be possible edit vectorized images later?
Or for that is "Vectot Edit" program?

The method to dock colors and layers is same ugly haha, anyway I know this was a quick solution :P
Indeed, minimizing lazpaint keep the layers windows visible anyway hahaha
also the layers window have a fixed size in docked mode
(https://i.ibb.co/59VSSYG/docked.png)

Is all for now, I guess I will comment more things later :)
Thanks for all the hard work.
Title: Re: New version of BGRABitmap
Post by: lainz on July 09, 2019, 10:57:45 pm
Strange. I don't have this bug on Linux 64. @Lainz, do you have this as well?

Yes I noticed this before, but didn't remember how it was working on v6 of LazPaint so I did not report. Now I downloaded LazPaint 6 and there it works fine, with left or right mouse button it moves the canvas. But on LazPaint 7 on Windows it doesn't move. Tested with Lazarus 2.0.2 and Trunk is the same problem.

Edit: I'm using Windows 10.

Edit 2: on MacOS it works somewhat strange too.

Edit 3: downloaded an old Lazarus 1.6.4 to check if there is for some change on the LCL but doesn't works as well.
Title: Re: New version of BGRABitmap
Post by: circular on July 10, 2019, 11:45:49 am
Many many thanks for that circular, that no_install works  :D
:)

Quote
The toolbar icons are newer right or is my idea?
Not really, upscaled a bit. New icons are only in Vector Edit.

Quote
I wonder, will be possible edit vectorized images later?
That's planned for next version.

Quote
Or for that is "Vectot Edit" program?
Well Vector Edit is not released officially though you can indeed edit vectorial things with it and open it with LazPaint.

Quote
The method to dock colors and layers is same ugly haha, anyway I know this was a quick solution :P
I reckon. :-[ But that's not working well, so I need to do the real thing.
Title: Re: New version of BGRABitmap
Post by: circular on July 10, 2019, 01:47:39 pm
@Lainz @fcu
I fixed the problem on dev branch (i.e. not released) and tested on Wine.

Lainz, can you try on Windows/MacOS?  :-*
Title: Re: New version of BGRABitmap
Post by: lainz on July 10, 2019, 07:40:48 pm
On Windows works fine. On macOS I can't compile due to ppu error, not in LazPaint but on the lazarus installation I have.

I will try to fix my Lazarus installation to try again on macOS.

Edit: on macOS always grab the canvas from the point 0,0. So I can move it only from top left.
Title: Re: New version of BGRABitmap
Post by: lainz on July 10, 2019, 11:16:21 pm
Please you can check this bug?
https://github.com/bgrabitmap/bgrabitmap/issues/66

Now there is a proper demo that shows the sigsegv.
In the project I work I found more exceptions like this when for example just clicking a tbcbutton. It shows doalphacorrection as described in the bug report.
Title: Re: New version of BGRABitmap
Post by: circular on July 11, 2019, 02:49:30 pm
I fixed the issue 66 (SIGSEGV).

So on MacOS, scrolling does not work. Hmm
Title: Re: New version of BGRABitmap
Post by: circular on July 11, 2019, 09:06:39 pm
New version of BGRABitmap (10.4).
https://github.com/bgrabitmap/bgrabitmap/releases

Highly recommended fix for Windows users with version 10.1 to 10.3

- Fix bug with Windows bitmap handle and alpha channel correction
- Fix dithering of transparent pixels
- added TakeLayerBitmap to layered bitmap
- adjust coordinates of aliased polygons
- allow padding and folding of linear texture mapping
Title: Re: New version of BGRABitmap
Post by: lainz on July 12, 2019, 01:01:50 am
Thanks for fixing the bug. Now the application works fine again =)
Title: Re: New version of BGRABitmap
Post by: circular on July 27, 2019, 03:04:16 pm
New version of BGRABitmap (10.5)
https://github.com/bgrabitmap/bgrabitmap/releases

It contains polygon fill fix and optimization for complex polygons (very much faster).
Also now vectorized font supports ligature, so you can write in arabic using vectorized font.

SVG: added FindElementById function
Layered bitmap: original with custom Guid, render one layer
Polygon: optimized complex polygon filling, fix bug with horizontal edges, fix U-turn round join
Vectorized font: update quadratic option, floating point size, handle ligatures (RTL and LTR) and multichar
Unicode: handle ligatures, multichar flag, fix error with empty paragraph
Phong: floating point light position
Title: Re: New version of BGRABitmap
Post by: circular on August 17, 2019, 12:25:28 pm
New version of BGRABItmap 10.6
https://github.com/bgrabitmap/bgrabitmap/releases

    VectorizeMonochrome can take bounds parameter
    speed up gradient original draft rendering with lower quality
    allow mask scanner to use scanners instead of bitmap
    ParallelFloodFill can take offset parameter
    SVG XML memory leak fix
    update original when loading content
    undo/redo possible for originals using diff
    avoid accessing deleted original
    fix resample layer offset
    fix line order when serializing images with TBGRACompressableBitmap
    releaser: added text and copy instructions

Title: Re: New version of BGRABitmap
Post by: nouzi on August 17, 2019, 01:33:38 pm
Nice working
كعكة is good   :D
Title: Re: New version of BGRABitmap
Post by: circular on August 17, 2019, 01:36:19 pm
Thanks.

Indeed كعكة is delicious.  :D
Title: Re: New version of BGRABitmap
Post by: nouzi on August 17, 2019, 01:40:09 pm
yes men good food :D  :D   :D
Title: Re: New version of BGRABitmap
Post by: lainz on August 18, 2019, 01:46:04 am
Thanks for the new release, I like editing the vectors  :)
Title: Re: New version of BGRABitmap
Post by: circular on August 18, 2019, 08:23:37 pm
New version 10.6.2 with tiny fix for ellipse of size zero
Title: Re: New version of BGRABitmap
Post by: circular on October 14, 2019, 01:28:05 pm
New version 10.6.3 with minor fixes

https://github.com/bgrabitmap/bgrabitmap/releases

Layers
    optimize: avoid storing/loading originals if not necessary
    function to unload originals
    added TBGRALayerImageOriginal.GetImageCopy
    raise click point event if points is clicked but not moved
    AddPointAlternateMove: alternate handler if other mouse button was used
    RawString storage: avoid string conversion with newer version of FPC
    copy additional info of MemDirectory when assigning
    update layer MemDirectory when changing unique id

SVG
    fix gradient for userSpaceOnUse coordinates

Releaser
    add handler for MacOS bundle

Title: Re: New version of BGRABitmap
Post by: circular on November 05, 2019, 11:46:10 am
New version 10.6.4
https://github.com/bgrabitmap/bgrabitmap/releases

Image formats:
    optimize reading common tiff formats
    basic support for portable any map (PBM, PGM, PPM)
    skip non-essential corrupted chunks in PNG
    fix GIF reader/writer for low bit depth (when color count <= 2)
    fix SVG functions returning size in pixels

Miscellaneous:
    fix right click in original event
    fix compilation for fpGUI
    fix runtime error in blur
    fix sign issue in Emboss filter
    added array of string constants for special key enum
Title: Re: New version of BGRABitmap
Post by: Thaddy on November 05, 2019, 11:54:18 am
Has the arm incompatibility received any attention?
I can send you a Raspberry Pi for free if that regression can be fixed (A RPi 3+, the 4's are for me)
You know how to reach me.
Title: Re: New version of BGRABitmap
Post by: circular on November 05, 2019, 03:04:10 pm
Nope. I suppose a first start would be to add an issue on GitHub so that it would not be lost in the forum. Are there some error messages?

You're mentioning a regression. From which version did the issue happen?

It would be great to make it work on Raspberry Pi. Personally I've never used one and I don't intend to have one. I would prefer to sort this issue in a dialogue with a Raspberry user.

Quote
You know how to reach me.
I don't see what you are referring to.
Title: Re: New version of BGRABitmap
Post by: lainz on November 05, 2019, 03:11:48 pm
I think he means you can PM him to contact him in the forum.
Title: Re: New version of BGRABitmap
Post by: Segator on November 05, 2019, 03:40:26 pm
Great job, its posible to support .webp file format?
Title: Re: New version of BGRABitmap
Post by: circular on November 05, 2019, 04:09:55 pm
To support webp format, one would need a reader or writer for it. Writing it in Pascal seem quite a big task. Has it already been done?
Title: Re: New version of BGRABitmap
Post by: Segator on November 05, 2019, 04:35:19 pm
I read about a delphi biding to webp library, but not pure pascal implementation.
Title: Re: New version of BGRABitmap
Post by: lainz on November 05, 2019, 04:37:50 pm
I think using the library will be ok, no need to reinvent the wheel...
https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html
Title: Re: New version of BGRABitmap
Post by: Thaddy on November 05, 2019, 04:43:04 pm
I don't see what you are referring to.
A free Raspberry Pi  :D Anyway, everybody should have a Raspbery Pi anyway.... :D

But I keep this one - with your permission - to help someone else if you refuse it...
Just a little incentive to get things working on Raspbian.
Title: Re: New version of BGRABitmap
Post by: circular on November 05, 2019, 05:43:29 pm
I think he means you can PM him to contact him in the forum.
I was also guessing that. Though I prefer if it's clarified.

A free Raspberry Pi  :D Anyway, everybody should have a Raspbery Pi anyway.... :D
I hear you would like to share your love of the Raspberry.  :D

Well as you have a Raspberry, maybe you can find a way to fix the library?
Title: Re: New version of BGRABitmap
Post by: circular on November 05, 2019, 05:48:48 pm
I think using the library will be ok, no need to reinvent the wheel...
https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html
Indeed. Not sure though how to plug that.
Title: Re: New version of BGRABitmap
Post by: lainz on November 05, 2019, 07:37:29 pm
I think using the library will be ok, no need to reinvent the wheel...
https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html
Indeed. Not sure though how to plug that.

I have the dll for Windows 32 and 64 bits ( I compiled these with visual studio right now). Also the Pascal header made by someone else… so you can access the methods of the dll from Pascal.

I was trying to do it to save to webp but I don't know too much about data manipulation with pointers like pbyte, that's the input and output format used by the library...
Title: Re: New version of BGRABitmap
Post by: lainz on November 05, 2019, 07:57:47 pm
Hi, well I've saved a BGRABitmap to WebP right now
https://github.com/bgrabitmap/webp

But the image is flipped, maybe you that have more experience know why and can fix?  :)

Is in the bgrabitmap organization at github, so you can already modify it.
Title: Re: New version of BGRABitmap
Post by: Fred vS on November 05, 2019, 10:09:56 pm
> Has the arm incompatibility received any attention?

BGRABitmap + fpGUI works perfectly on arm Rpi.
You may try the Rpi release of Eschecs here:

https://github.com/rchastain/eschecs/releases

Fre;D
Title: Re: New version of BGRABitmap
Post by: del on November 06, 2019, 12:40:40 am
Very impressive image processing suite. Maybe some of you old timers remember that guy who had all those image algorithms on his website. Delphi stuff IIRC. For some reason I'm thinking of "Elf"? His name was like "Elf" or something. Don't laugh but I used to have a Delphi telecommute job and I did a lot of that stuff so it was pretty cool to discover his site.
Title: Re: New version of BGRABitmap
Post by: winni on November 06, 2019, 01:08:53 am
Hi!

I think you mean efg ! He is still at work but his continuous growing website needs to be reorganized. Thats what he is doing  now. But he's is still at work since over 20 years. Yes, he was very early with cool sniplets for graphic algorithms for Delphi.

Here: http://www.efg2.com/ (http://www.efg2.com/)

Winni
Title: Re: New version of BGRABitmap
Post by: lainz on November 06, 2019, 02:52:17 am
I get it working, now is possible to load webP into BGRABitmap and save to webP from BGRABitmap on Win32, Win64
https://github.com/bgrabitmap/webp

Is missing testing it on linux and mac, but I don't know how to compile the .so files for these systems...
Title: Re: New version of BGRABitmap
Post by: del on November 06, 2019, 06:13:55 am
Hi!

I think you mean efg ! He is still at work but his continuous growing website needs to be reorganized. Thats what he is doing  now. But he's is still at work since over 20 years. Yes, he was very early with cool sniplets for graphic algorithms for Delphi.

Here: http://www.efg2.com/ (http://www.efg2.com/)

Winni
That's the guy! Holy Cow have the years flown by.  :D
Title: Re: New version of BGRABitmap
Post by: circular on November 06, 2019, 02:55:04 pm
I get it working, now is possible to load webP into BGRABitmap and save to webP from BGRABitmap on Win32, Win64
https://github.com/bgrabitmap/webp
Cool. I fixed a few things. I couldn't try to add the Free memory call as I can't run it on Linux. I guess on Windows, you can find a Free function for global allocation (that's not the FreeMem of Lazarus). In some places I saw they use WebPFree, though this function is not declared. Maybe it is in the Dll?

Quote
Is missing testing it on linux and mac, but I don't know how to compile the .so files for these systems...
Yes, that's a bit different. Also there is a package for webp on Linux (at least in my distro as far as I can see) so that you don't need to provide the library. But then the name of the shared library binary file may change.  %)
Title: Re: New version of BGRABitmap
Post by: lainz on November 06, 2019, 03:08:41 pm
Under Ubuntu they have the version 0.6. For good the library name is duplicated, so you can put in the name libwebp.so, libwebp.so.6 and libwebp.so.6.0.2.

But it does not work... linking problem.
Title: Re: New version of BGRABitmap
Post by: lainz on November 06, 2019, 03:14:57 pm
Quote
Compile Project, Mode: Debug, Target: bgrawebptest: Exit code 1, Errors: 1, Hints: 3
Hint: Start of reading config file /etc/fpc.cfg
Hint: End of reading config file /etc/fpc.cfg
Verbose: Free Pascal Compiler version 3.0.4 [2018/10/29] for x86_64
Verbose: Copyright (c) 1993-2017 by Florian Klaempfl and others
Verbose: Target OS: Linux for x86-64
Verbose: Compiling bgrawebptest.lpr
Verbose: Compiling bgrawebp.pas
bgrawebp.pas(75,3) Note: Local variable "i" not used
bgrawebptest.lpr(10,17) Unit "bgrawebp" not used in bgrawebptest
Compiling resource /home/lainz/webp/bgrawebp/lib/x86_64-linux/bgrawebptest.or
Linking /home/lainz/webp/bgrawebp/bgrawebptest
linker: /usr/bin/ld: aviso: /home/lainz/webp/bgrawebp/link.res contiene secciones de salida. ¿Olvidó -T?
linker: /usr/bin/ld: /home/lainz/webp/bgrawebp/lib/x86_64-linux/libwebp.o: en la función `VP8INITIO':
/home/lainz/webp/bgrawebp//libwebp.pas:532: referencia a `VP8InitIoInternal' sin definir

bgrawebptest.lpr(21,1) Error: Error while linking
bgrawebptest.lpr(21,1) Verbose: There were 1 errors compiling module, stopping
Verbose: Compilation aborted
Verbose: /usr/bin/ppcx64 returned an error exitcode

I'm asking in a separate thread, so others can see too
https://forum.lazarus.freepascal.org/index.php/topic,47329.0.html
Title: Re: New version of BGRABitmap
Post by: Segator on November 06, 2019, 03:25:00 pm
the Double Commander project can read .webp files on windows and linux, is a lazarus and fpc project
Title: Re: New version of BGRABitmap
Post by: circular on November 06, 2019, 03:50:11 pm
Hi!

I've compiled it on Linux. And it works fine!

I removed the VP8 declaration because we don't use them anyway. They do not seem to be available but that doesn't matter.

In fact you need to have libwebp-dev package installed to have the so file without version, but it is not necessary at runtime.  %)

- Fixed other few things like BGRA/RGBA order.
- Also enable it for MacOS as I suppose it works the same. Maybe you can give it a try?
Title: Re: New version of BGRABitmap
Post by: circular on November 06, 2019, 03:52:09 pm
Hi!

I think you mean efg ! He is still at work but his continuous growing website needs to be reorganized. Thats what he is doing  now. But he's is still at work since over 20 years. Yes, he was very early with cool sniplets for graphic algorithms for Delphi.

Here: http://www.efg2.com/ (http://www.efg2.com/)

Winni
That's the guy! Holy Cow have the years flown by.  :D
Oh, there seem to be interesting stuff about polygon clipping.
Title: Re: New version of BGRABitmap
Post by: lainz on November 06, 2019, 03:52:51 pm
Hi. What are the steps to run it on mac os?
I need to fix my installation, just the other day updated to trunk and it stopped working...
Title: Re: New version of BGRABitmap
Post by: circular on November 06, 2019, 03:56:16 pm
I thought one just needed to install libwebp-dev package, though that may not work the same on MacOS:
https://developers.google.com/speed/webp/docs/precompiled

Here they say they have statically linked the library. So maybe you just need to put the library in the same folder like on Windows.
Title: Re: New version of BGRABitmap
Post by: circular on November 06, 2019, 04:01:24 pm
By the way, what happens if the Dll is not present when you run the application?

Also on Linux, it bothers me that one need to have the libwebp-dev package installed. I don't want users to need to download that to compile BGRABitmap.
Title: Re: New version of BGRABitmap
Post by: lainz on November 06, 2019, 04:16:24 pm
You can keep it on a helper on a separate package, so people can choose to use it or not.

I will try what happens if the DLL is not in the folder, just im not at the PC right now.

Ive downloaded the library from
https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html

In the lib folder there is an .a file, not a .so file.
On windows happens the same, it comes with a .lib file not a .dll file, for that I needed to compile it with visual studio...

Edit> Anyways I can not build lazarus with fpcupdeluxe, it gives me an error, so for now I dont have lazarus on mac...
Title: Re: New version of BGRABitmap
Post by: lainz on November 06, 2019, 04:21:52 pm
Also seems that there is a library for each Mac version too. I have 10.13 but the latest is for 10.14
Title: Re: New version of BGRABitmap
Post by: circular on November 06, 2019, 04:32:28 pm
You can keep it on a helper on a separate package, so people can choose to use it or not.
Hmm yep, like the BGRAWebP unit would not be included be default.

I will rather to do a reader/writer, so that if you declare the unit, then you can load/save it using usual functions.

That can help regarding linking to the library, but that would solve the compiling thing.

I think we need to explicitely load the library with LoadLibrary to avoid linking problems at compile time.

In fact that would solve the dependency issue as well, because we can check if the library loads correctly.
Title: Re: New version of BGRABitmap
Post by: lainz on November 06, 2019, 04:48:12 pm
Ok sounds good. When you're done just delete that repository so it doesn't have duplicate content.

My knowledge stops there I can't help more  ::)
Title: Re: New version of BGRABitmap
Post by: circular on November 06, 2019, 05:51:04 pm
Hmm I think you can help a bit more. Let me explain and tell me if you are interested in the adventure.

When doing LoadLibrary (of unit dynlibs), you get a handle. Then with GetProcedureAddress you get a procedure address. So instead of declaring the procedure with an external keyword, you declare variable of procedure type, and assign them with the address you get from GetProcedureAddress.

Declaring the procedure type is like declaring an event procedure. Then you can declare a variable of this type.

https://wiki.freepascal.org/Lazarus/FPC_Libraries#Loadlibrary_-_dynamically_loading_a_dynamic_library

Regards
Title: Re: New version of BGRABitmap
Post by: winni on November 06, 2019, 06:12:02 pm

Oh, there seem to be interesting stuff about polygon clipping.

Hi!

There is a lot of graphic stuff and I think also about polygons.

About polygon clipping I cant help now, but I did a lot of research about [is]PointInPoly[gon] .

I worked on geo maps and the computers were slower -10 years ago.
Despite reducing the polygon points of the areas I tried to find out the quickest algos.
I did 2 days testing  for 5 different kinds of PointInPoly.

The quickest one is this:

Code: Pascal  [Select][+][-]
  1. function PointInPoly(p : TPointF; const poly :  array of TPointF) : Boolean; inline;
  2. var i,k : integer;
  3.  
  4. Begin
  5.  result := false;
  6.  k := High(poly);
  7.  For i := Low(poly) to High(poly) do begin
  8.   if  (
  9.      ( ((poly[i].y <= p.y) and (p.y < poly[k].y)) or ((poly[k].y <= p.y) and (p.y < poly[i].y)) )
  10.       and
  11.         (p.x < ((poly[k].x - poly[i].x) * (p.y - poly[i].y) / (poly[k].y - poly[i].y) + poly[i].x) )
  12.      )
  13.         then result := not result;
  14.   k := i;
  15.  end;
  16. end;

It is quicker the the "default" function that is flying around in the net as C code and is used in
lazregions. pas in the LCL.

In the moment the above inline is obsolet because the compiler does not support open arrays for inline -
as he yowls.

The above function can easily used for TPoint and Array of Tpoint - only the declaration has to be changed.

Winni


Title: Re: New version of BGRABitmap
Post by: winni on November 07, 2019, 01:13:59 am
Oh, there seem to be interesting stuff about polygon clipping.

Hi!

Did a walk through my bookmarks and found a good Geeks page about polygon clipping:

https://www.geeksforgeeks.org/polygon-clipping-sutherland-hodgman-algorithm-please-change-bmp-images-jpeg-png/ (https://www.geeksforgeeks.org/polygon-clipping-sutherland-hodgman-algorithm-please-change-bmp-images-jpeg-png/)

The code is in C but good readable.


For what reason do you need it?

Winni
Title: Re: New version of BGRABitmap
Post by: circular on November 07, 2019, 04:35:00 pm
I am thinking about using polygon clipping the LazPaint selection. For now, the whole selection is vectorized as one bitmap, but if I add vectorial selection, that would not work anymore.
Title: Re: New version of BGRABitmap
Post by: Segator on November 07, 2019, 04:38:20 pm
The .webp file support is done?
Title: Re: New version of BGRABitmap
Post by: circular on November 07, 2019, 05:33:12 pm
@Segator:
Nope.

Compile-time linking can be done using the code on the repository there:
https://github.com/bgrabitmap/webp/tree/master/bgrawebp

For now I have proposed Lainz to try to make late-loading of the library. He is probably busy on something else.
Title: Re: New version of BGRABitmap
Post by: winni on November 07, 2019, 07:16:55 pm
@circular

Hi!

There is Pascal code for intersecting polygons!

Angus Johnson is the man who wrote the Image32 library for Delphi.

He also wrote the "Clipper Library" on base of the Vatti algorithm, which is the most complete and does not separate the cases concav, convex and complex.

The source is in C++, C# and Delphi 7-10!

http://www.angusj.com/delphi/clipper.php (http://www.angusj.com/delphi/clipper.php)

Keep on BGRAing!

Winni
Title: Re: New version of BGRABitmap
Post by: circular on November 07, 2019, 08:11:11 pm
@winni:
Cool that looks like the library I need.  8-)

Quote
Keep on BGRAing!
:D Sure I think I will  :)
Title: Re: New version of BGRABitmap
Post by: lainz on November 07, 2019, 10:09:22 pm
Hi for sure I want to help to make the webp into bgrabitmap. The thing is that I'm with regular headaches these days since I'm diagnosed with sinusitis. When I recover I will help.
Title: Re: New version of BGRABitmap
Post by: winni on November 08, 2019, 02:00:14 am
@lainz

🤧

Get well soon!

Winni
Title: Re: New version of BGRABitmap
Post by: Segator on November 08, 2019, 05:21:18 pm
@lainz thanks

I hope you get well!
Title: Re: New version of BGRABitmap
Post by: circular on November 08, 2019, 07:23:29 pm
I think we did it. fredvs did the dynamic loading and I did the search for the library on linux. So basically, on Linux, it uses the installed library libwebp and on Windows and MacOS one need to supply the library. I haven't tested it on MacOS though.

But main thing, it doesn't require to install libwebp-dev, so if I add this to BGRABitmap, people won't have to install this package to compile.
Title: Re: New version of BGRABitmap
Post by: Segator on November 08, 2019, 07:35:02 pm
On Windows you can display .webp with out external library, check this Double Commander implementation:
Code: Pascal  [Select][+][-]
  1. {
  2.    Double Commander
  3.    -------------------------------------------------------------------------
  4.    Windows thumbnail provider
  5.  
  6.    Copyright (C) 2012-2013 Alexander Koblov (alexx2000@mail.ru)
  7.  
  8.    This library is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU Lesser General Public
  10.    License as published by the Free Software Foundation; either
  11.    version 2.1 of the License, or (at your option) any later version.
  12.  
  13.    This library is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    Lesser General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU Lesser General Public
  19.    License along with this library; if not, write to the Free Software
  20.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21. }
  22.  
  23. unit uThumbnailProvider;
  24.  
  25. {$mode delphi}
  26.  
  27. interface
  28.  
  29. uses
  30.   uThumbnails;
  31.  
  32. implementation
  33.  
  34. uses
  35.   SysUtils, Forms, Graphics, Windows, ActiveX, ShlObj;
  36.  
  37. const
  38.   SIIGBF_RESIZETOFIT   = $00000000;
  39.   SIIGBF_BIGGERSIZEOK  = $00000001;
  40.   SIIGBF_MEMORYONLY    = $00000002;
  41.   SIIGBF_ICONONLY      = $00000004;
  42.   SIIGBF_THUMBNAILONLY = $00000008;
  43.   SIIGBF_INCACHEONLY   = $00000010;
  44.  
  45. const
  46.   IID_IExtractImage: TGUID = '{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}';
  47.  
  48. type
  49.   SIIGBF = Integer;
  50.  
  51.   IShellItemImageFactory = interface(IUnknown)
  52.     ['{BCC18B79-BA16-442F-80C4-8A59C30C463B}']
  53.     function GetImage(size: TSize; flags: SIIGBF; out phbm: HBITMAP): HRESULT; stdcall;
  54.   end;
  55.  
  56.   IExtractImage = interface(IUnknown)
  57.     ['{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}']
  58.     function GetLocation(pszPathBuffer: LPWSTR; cchMax: DWORD; out pdwPriority: DWORD;
  59.       const prgSize: LPSIZE; dwRecClrDepth: DWORD; var pdwFlags: DWORD): HRESULT; stdcall;
  60.     function Extract(out phBmpImage: HBITMAP): HRESULT; stdcall;
  61.   end;
  62.  
  63. var
  64.   SHCreateItemFromParsingName: function(pszPath: LPCWSTR; const pbc: IBindCtx;
  65.                                         const riid: TIID; out ppv): HRESULT; stdcall;
  66.  
  67. function GetThumbnailOld(const aFileName: String; aSize: TSize; out Bitmap: HBITMAP): HRESULT;
  68. var
  69.   Folder,
  70.   DesktopFolder: IShellFolder;
  71.   Pidl,
  72.   ParentPidl: PItemIDList;
  73.   Image: IExtractImage;
  74.   pchEaten: ULONG;
  75.   wsTemp: WideString;
  76.   dwPriority: DWORD;
  77.   Status: HRESULT;
  78.   dwRecClrDepth: DWORD;
  79.   dwAttributes: ULONG = 0;
  80.   dwFlags: DWORD = IEIFLAG_SCREEN or IEIFLAG_QUALITY or IEIFLAG_ORIGSIZE;
  81. begin
  82.   Result:= E_FAIL;
  83.  
  84.   if SHGetDesktopFolder(DesktopFolder) = S_OK then
  85.   begin
  86.     wsTemp:= UTF8Decode(ExtractFilePath(aFileName));
  87.     if DesktopFolder.ParseDisplayName(0, nil, PWideChar(wsTemp), pchEaten, ParentPidl, dwAttributes) = S_OK then
  88.     begin
  89.       if DesktopFolder.BindToObject(ParentPidl, nil, IID_IShellFolder, Folder) = S_OK then
  90.       begin
  91.         wsTemp:= UTF8Decode(ExtractFileName(aFileName));
  92.         if Folder.ParseDisplayName(0, nil, PWideChar(wsTemp), pchEaten, Pidl, dwAttributes) = S_OK then
  93.         begin
  94.           if Succeeded(Folder.GetUIObjectOf(0, 1, Pidl, IID_IExtractImage, nil, Image)) then
  95.           begin
  96.             SetLength(wsTemp, MAX_PATH * SizeOf(WideChar));
  97.             dwRecClrDepth:= GetDeviceCaps(Application.MainForm.Canvas.Handle, BITSPIXEL);
  98.             Status:= Image.GetLocation(PWideChar(wsTemp), Length(wsTemp), dwPriority, @aSize, dwRecClrDepth, dwFlags);
  99.             if (Status = NOERROR) or (Status = E_PENDING) then
  100.             begin
  101.               Result:= Image.Extract(Bitmap);
  102.             end;
  103.           end;
  104.           CoTaskMemFree(Pidl);
  105.         end;
  106.         Folder:= nil;
  107.       end;
  108.       CoTaskMemFree(ParentPidl);
  109.     end;
  110.     DesktopFolder:= nil;
  111.   end; // SHGetDesktopFolder
  112. end;
  113.  
  114. function GetThumbnailNew(const aFileName: String; aSize: TSize; out Bitmap: HBITMAP): HRESULT;
  115. var
  116.   ShellItemImage: IShellItemImageFactory;
  117. begin
  118.   Result:= SHCreateItemFromParsingName(PWideChar(UTF8Decode(aFileName)), nil,
  119.                                        IShellItemImageFactory, ShellItemImage);
  120.   if Succeeded(Result) then
  121.   begin
  122.     Result:= ShellItemImage.GetImage(aSize, SIIGBF_THUMBNAILONLY, Bitmap);
  123.   end;
  124. end;
  125.  
  126. function GetThumbnail(const aFileName: String; aSize: TSize): Graphics.TBitmap;
  127. var
  128.   Bitmap: HBITMAP;
  129.   Status: HRESULT = E_FAIL;
  130. begin
  131.   Result:= nil;
  132.  
  133.   if (Win32MajorVersion > 5) then
  134.   begin
  135.     Status:= GetThumbnailNew(aFileName, aSize, Bitmap);
  136.   end;
  137.  
  138.   if Failed(Status) then
  139.   begin
  140.     Status:= GetThumbnailOld(aFileName, aSize, Bitmap);
  141.   end;
  142.  
  143.   if Succeeded(Status) then
  144.   begin
  145.     Result:= Graphics.TBitmap.Create;
  146.     Result.Handle:= Bitmap;
  147.   end;
  148. end;
  149.  
  150. initialization
  151.   SHCreateItemFromParsingName:= GetProcAddress(GetModuleHandle('shell32.dll'),
  152.                                                'SHCreateItemFromParsingName');
  153.   TThumbnailManager.RegisterProvider(@GetThumbnail);
  154.  
  155. end.

i modified it to use with out doublecmd depennd and share functions:

Code: Pascal  [Select][+][-]
  1. {
  2.    Double Commander
  3.    -------------------------------------------------------------------------
  4.    Windows thumbnail provider
  5.  
  6.    Copyright (C) 2012-2013 Alexander Koblov (alexx2000@mail.ru)
  7.  
  8.    This library is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU Lesser General Public
  10.    License as published by the Free Software Foundation; either
  11.    version 2.1 of the License, or (at your option) any later version.
  12.  
  13.    This library is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    Lesser General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU Lesser General Public
  19.    License along with this library; if not, write to the Free Software
  20.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21. }
  22.  
  23. unit uThumbnailProvider;
  24.  
  25. {$mode delphi}
  26.  
  27. interface
  28.  
  29.  
  30.  
  31.  
  32. uses
  33.   SysUtils, Forms, Graphics, Windows, ActiveX, ShlObj;
  34.  
  35. const
  36.   SIIGBF_RESIZETOFIT   = $00000000;
  37.   SIIGBF_BIGGERSIZEOK  = $00000001;
  38.   SIIGBF_MEMORYONLY    = $00000002;
  39.   SIIGBF_ICONONLY      = $00000004;
  40.   SIIGBF_THUMBNAILONLY = $00000008;
  41.   SIIGBF_INCACHEONLY   = $00000010;
  42.  
  43. const
  44.   IID_IExtractImage: TGUID = '{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}';
  45.  
  46. type
  47.   SIIGBF = Integer;
  48.  
  49.   IShellItemImageFactory = interface(IUnknown)
  50.     ['{BCC18B79-BA16-442F-80C4-8A59C30C463B}']
  51.     function GetImage(size: TSize; flags: SIIGBF; out phbm: HBITMAP): HRESULT; stdcall;
  52.   end;
  53.  
  54.   IExtractImage = interface(IUnknown)
  55.     ['{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}']
  56.     function GetLocation(pszPathBuffer: LPWSTR; cchMax: DWORD; out pdwPriority: DWORD;
  57.       const prgSize: LPSIZE; dwRecClrDepth: DWORD; var pdwFlags: DWORD): HRESULT; stdcall;
  58.     function Extract(out phBmpImage: HBITMAP): HRESULT; stdcall;
  59.   end;
  60.  
  61. var
  62.   SHCreateItemFromParsingName: function(pszPath: LPCWSTR; const pbc: IBindCtx;
  63.                                         const riid: TIID; out ppv): HRESULT; stdcall;
  64.   function GetThumbnail(const aFileName: String; aSize: TSize): Graphics.TBitmap;
  65.  
  66. implementation
  67.  
  68.  
  69. function GetThumbnailOld(const aFileName: String; aSize: TSize; out Bitmap: HBITMAP): HRESULT;
  70. var
  71.   Folder,
  72.   DesktopFolder: IShellFolder;
  73.   Pidl,
  74.   ParentPidl: PItemIDList;
  75.   Image: IExtractImage;
  76.   pchEaten: ULONG;
  77.   wsTemp: WideString;
  78.   dwPriority: DWORD;
  79.   Status: HRESULT;
  80.   dwRecClrDepth: DWORD;
  81.   dwAttributes: ULONG = 0;
  82.   dwFlags: DWORD = IEIFLAG_SCREEN or IEIFLAG_QUALITY or IEIFLAG_ORIGSIZE;
  83. begin
  84.   Result:= E_FAIL;
  85.  
  86.   if SHGetDesktopFolder(DesktopFolder) = S_OK then
  87.   begin
  88.     wsTemp:= UTF8Decode(ExtractFilePath(aFileName));
  89.     if DesktopFolder.ParseDisplayName(0, nil, PWideChar(wsTemp), pchEaten, ParentPidl, dwAttributes) = S_OK then
  90.     begin
  91.       if DesktopFolder.BindToObject(ParentPidl, nil, IID_IShellFolder, Folder) = S_OK then
  92.       begin
  93.         wsTemp:= UTF8Decode(ExtractFileName(aFileName));
  94.         if Folder.ParseDisplayName(0, nil, PWideChar(wsTemp), pchEaten, Pidl, dwAttributes) = S_OK then
  95.         begin
  96.           if Succeeded(Folder.GetUIObjectOf(0, 1, Pidl, IID_IExtractImage, nil, Image)) then
  97.           begin
  98.             SetLength(wsTemp, MAX_PATH * SizeOf(WideChar));
  99.             dwRecClrDepth:= GetDeviceCaps(Application.MainForm.Canvas.Handle, BITSPIXEL);
  100.             Status:= Image.GetLocation(PWideChar(wsTemp), Length(wsTemp), dwPriority, @aSize, dwRecClrDepth, dwFlags);
  101.             if (Status = NOERROR) or (Status = E_PENDING) then
  102.             begin
  103.               Result:= Image.Extract(Bitmap);
  104.             end;
  105.           end;
  106.           CoTaskMemFree(Pidl);
  107.         end;
  108.         Folder:= nil;
  109.       end;
  110.       CoTaskMemFree(ParentPidl);
  111.     end;
  112.     DesktopFolder:= nil;
  113.   end; // SHGetDesktopFolder
  114. end;
  115.  
  116. function GetThumbnailNew(const aFileName: String; aSize: TSize; out Bitmap: HBITMAP): HRESULT;
  117. var
  118.   ShellItemImage: IShellItemImageFactory;
  119. begin
  120.   Result:= SHCreateItemFromParsingName(PWideChar(UTF8Decode(aFileName)), nil,
  121.                                        IShellItemImageFactory, ShellItemImage);
  122.   if Succeeded(Result) then
  123.   begin
  124.     Result:= ShellItemImage.GetImage(aSize, SIIGBF_THUMBNAILONLY, Bitmap);
  125.   end;
  126. end;
  127.  
  128. function GetThumbnail(const aFileName: String; aSize: TSize): Graphics.TBitmap;
  129. var
  130.   Bitmap: HBITMAP;
  131.   Status: HRESULT = E_FAIL;
  132. begin
  133.   Result:= nil;
  134.  
  135.   if (Win32MajorVersion > 5) then
  136.   begin
  137.     Status:= GetThumbnailNew(aFileName, aSize, Bitmap);
  138.   end;
  139.  
  140.   if Failed(Status) then
  141.   begin
  142.     Status:= GetThumbnailOld(aFileName, aSize, Bitmap);
  143.   end;
  144.  
  145.   if Succeeded(Status) then
  146.   begin
  147.     Result:= Graphics.TBitmap.Create;
  148.     Result.Handle:= Bitmap;
  149.   end;
  150. end;
  151.  
  152. initialization
  153.   SHCreateItemFromParsingName:= GetProcAddress(GetModuleHandle('shell32.dll'),
  154.                                                'SHCreateItemFromParsingName');
  155.  
  156. end.
  157.  
  158.  
Title: Re: New version of BGRABitmap
Post by: Segator on November 08, 2019, 07:37:02 pm
but its just to display, you can't save to .webp
Title: Re: New version of BGRABitmap
Post by: Segator on November 08, 2019, 07:38:01 pm
I think we did it. fredvs did the dynamic loading and I did the search for the library on linux. So basically, on Linux, it uses the installed library libwebp and on Windows and MacOS one need to supply the library. I haven't tested it on MacOS though.

But main thing, it doesn't require to install libwebp-dev, so if I add this to BGRABitmap, people won't have to install this package to compile.

that is great, very good job
Title: Re: New version of BGRABitmap
Post by: circular on November 08, 2019, 07:41:05 pm
Quote
On Windows you can display .webp with out external library, check this Double Commander implementation:
That's interesting. I wonder though from which version it is available and the resolution, as it is returned by a thumbnail function?

Quote
but its just to display, you can't save to .webp
Ah indeed, that's a bit limited. Though as a fallback, it could be better than nothing.
Title: Re: New version of BGRABitmap
Post by: Segator on November 08, 2019, 07:48:08 pm
Quote
That's interesting. I wonder though from which version it is available and the resolution, as it is returned by a thumbnail function?
Yes and the resolution you must to set it, can not get it  :( , but maybe with some search in the winapi function ?
Quote
Ah indeed, that's a bit limited. Though as a fallback, it could be better than nothing.
yeap
Title: Re: New version of BGRABitmap
Post by: circular on November 08, 2019, 08:07:02 pm
What if you use SIIGBF_BIGGERSIZEOK flag?
Title: Re: New version of BGRABitmap
Post by: Segator on November 08, 2019, 08:16:26 pm
Testing...
Title: Re: New version of BGRABitmap
Post by: circular on November 09, 2019, 11:59:16 am
I've added WebP support in BGRABitmap on dev branch. On Windows you need to copy along your app the adequate Dll which is provided in bgrabitmap/libwebp.

Any news about the thumbnail?
Title: Re: New version of BGRABitmap
Post by: lainz on November 09, 2019, 01:54:37 pm
Hi, I suppose that the thumbnail will work only if the version of Windows supports WebP, on Windows 10 the WebP support has been added with Webp Image Extensions https://www.microsoft.com/en-us/p/webp-image-extensions/9pg2dk419drg?activetab=pivot:overviewtab

I can see WebP images directly in the file explorer.

But what about Windows 7 that is still being used? Seems that for older versions of Windows Google provides a codec
https://techdows.com/2011/04/viewing-webp-images-on-windows.html

So maybe people will need the codec on older Windows to generate that thumbnails...  :)
Title: Re: New version of BGRABitmap
Post by: circular on November 09, 2019, 02:43:57 pm
Indeed. It's not guaranteed to be there.
Title: Re: New version of BGRABitmap
Post by: circular on February 04, 2020, 09:28:28 am
New version of BGRABitmap 10.6.5
https://github.com/bgrabitmap/bgrabitmap/releases

Miscellaneous
- Fix compilation for Qt on MacOS
- Fix compilation for NoGUI
- Fix compilation of ellipse functions with range check enabled
- Avoid range error with 1-point polygon
- Update CSS color link

Drawing
- Texture property for BGRACanvas brush
- Fix horizontal text align of typewriter
- Phong and shadow effect with vectorial text effect renderer
- Fix empty text case
- Added IdleBrush
- FloodFill with universal brush
- Handle EmptyPointF in Compute*Spline functions
- Fix transparent case for gradient fill
- Optional alpha parameter for BGRAToStr function

Layered bitmap
- Better handling of layer ids
- Smaller invisible margin for points
- Improve gradient original (geometry, set colors and apply opacity)

Image format
- Support for WebP format (requires adapted libwebp*.dll on Windows, see libwebp folder)
- Added BGRABitDepthIconCursor function to get minimum depth necessary for icon image
- Added multifile and icon Assign function
Title: Re: New version of BGRABitmap
Post by: circular on March 02, 2020, 07:06:41 pm
New version of BGRABitmap 10.6.6
https://github.com/bgrabitmap/bgrabitmap/releases

Rendering
- handling complex unicode in TextOutCurved
- optimize draft rendering of gradients (using new BGRAGradientScanner.TBGRABufferedGradient)
- BGRACanvas: added Pen.Mode property (pmNot etc.)

Layered images
- loading/saving progress callback for all layered images (BGRALayers.Unregister/RegisterLoadingHandler, Unregister/RegisterSavingHandler)
- action progress callback (TBGRALayeredBitmap.OnActionProgress/OnActionDone)
- added Mask and Saturation blend op (Mask applies a mask to layers underneath, Saturation applies standard HSL saturation)
- layer editor: IsMovingPoint property
- layer editor: can highlight points (PointHighlighted[] property)

Gif
- fix error when writing Gif with few colors

Utf8
- added DeleteFileUTF8

Geometry
- added TPointF.IsEmpty
Title: Re: New version of BGRABitmap
Post by: circular on April 01, 2020, 11:57:26 am
New version BGRABitmap 10.8
https://github.com/bgrabitmap/bgrabitmap/releases

File formats
- optimize writing PNG and LZP format
- fix reading TIFF format (rare predictor case)

Misc
- added TBGRAPixel.EqualsExactly (checks RGB channels even if alpha = 0
- optimize pixel interpolation
- TAffineBox.Center property
- fix line intersection precision (avoid bugs with pen stroker with certain shapes)
- fix ColorFToBGRA function

TBGRAOriginalEditor
- avoid bugs when editor content changes

TBGRALayerGradientOriginal
- fix comparison with alpha = 0
- added Equals and IsOpaque functions

Title: Re: New version of BGRABitmap
Post by: fcu on April 01, 2020, 02:59:24 pm
nice

i've install this version , then i tried to rebuild lazarus with optimized ide profile , then it stoped whith this error message :  bgrawritepng.pas not found .
also note that bgracontrols could not be installed as well .

i am using fpc 3.0.4 & lazarus 2.0.6 , on windows 7 32bits 
Title: Re: New version of BGRABitmap
Post by: circular on April 01, 2020, 11:13:20 pm
Thanx for the feedback.

Do you have bgrawritepng.pas in the folder along with the package?
Title: Re: New version of BGRABitmap
Post by: fcu on April 02, 2020, 02:34:29 pm
yes , its there .
btw , did you tried install the latest bgracontrols ?   

i'll try with fresh installation of both lazarus & bgrabitmap , i'll tel you
Title: Re: New version of BGRABitmap
Post by: circular on April 02, 2020, 09:21:03 pm
Maybe you just need to do a clean build
Title: Re: New version of BGRABitmap
Post by: fcu on April 03, 2020, 01:26:29 pm
unfortunately i still get the same error when trying to install bglcontrols.lpk
Title: Re: New version of BGRABitmap
Post by: circular on April 03, 2020, 01:42:49 pm
Ok I found the problem. It was a circular reference of units.

That's fixed in version 10.8.1:
https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: fcu on April 03, 2020, 02:07:40 pm
thats cool :) , thanks
Title: Re: New version of BGRABitmap
Post by: lainz on April 04, 2020, 02:24:21 pm
Thanks now it works again in FPC trunk and Lazarus trunk
Title: Re: New version of BGRABitmap
Post by: linnemann on April 04, 2020, 08:29:06 pm
Hi

Is it possible to animate SVG using BGRABitmap, could not find any info here or on the interweebs?

Like https://css-tricks.com/guide-svg-animations-smil/

Thanks for an awesome library btw.
Title: Re: New version of BGRABitmap
Post by: circular on April 04, 2020, 10:19:27 pm
Hi,

Glad you like the library.

For now BGRABitmap does not handle SVG animation.

Regards
Title: Re: New version of BGRABitmap
Post by: circular on April 24, 2020, 11:49:08 am
New version of BGRABitmap (10.9)
https://github.com/bgrabitmap/bgrabitmap/releases

Compatibility:
- BGRABitmap can now be used be MSEgui
- improve Delphi portability by avoiding += and using more consistent integer types
- add UTF8toUTF16 and UTF16toUTF8 to BGRAUTF8 unit
- add DeleteFileUTF8 to BGRAUTF8 unit for non-LCL context

Vectors:
- vectorized font: add kerning (putting closer letters that fits like AV)
- vectorized font: add OutlineJoin property
- FreeType: fix TextFitInfo for unicode chars
- text layout: add UsedWidth to TBidiTextLayout
- text layout: add TextSizeMultiline to TBGRABitmap
- avoid crash when layer editor matrix is not inversible

Refactoring:
- added BGRAClasses unit with used classes (instead of Classes and Types)
- using Avl_Tree FPC unit instead of Lazarus AvgLvlTree
- TColor byte order depends on global directive TCOLOR_BLUE_IN_LOW_BYTE
Title: Re: New version of BGRABitmap
Post by: circular on May 14, 2020, 11:05:47 am
BGRABitmap v11

https://github.com/bgrabitmap/bgrabitmap/releases

- functions that used to return TBGRACustomBitmap now return the type of the current class. So no need to write for example "Resample(...) as TBGRABitmap".

- optimize TFillShapeInfo.IsPointInside by not allocating the intersection array each time.

- basic support for Unicode in BGRAFreeType. This includes Arabic and alpha-syllabic scripts, though there are some limitations. For example, multiple marks in Hindi placement is not adjusted and specific glyph substitutions are not handled. This would require to read the GSUB and GPOS table of the font.

- added DrawPixelF, ErasePixelF, AlphaPixelF

- added fqFineClearType global function, to get the RGB/BGR order used by the system

- fix PNG reader for 24-bit RGB with transparent entry
Title: Re: New version of BGRABitmap
Post by: lainz on May 14, 2020, 04:26:34 pm
Hi, can't compile in FPC / Lazarus trunk

bgrafreetype.pas(900,18) Error: Identifier idents no member "CharKerning"

Code: Pascal  [Select][+][-]
  1. function TFreeTypeTypeWriter.ComputeKerning(AIdLeft, AIdRight: string): single;
  2. {$IFDEF LAZFREETYPE_PROVIDE_KERNING}
  3. var
  4.   uLeft, uRight: LongWord;
  5. begin
  6.   if (AIdLeft = '') or (AIdRight = '') then exit(0);
  7.   uLeft := UTF8CodepointToUnicode(@AIdLeft[1], UTF8CharacterLength(@AIdLeft[1]));
  8.   uRight := UTF8CodepointToUnicode(@AIdRight[1], UTF8CharacterLength(@AIdRight[1]));
  9.   Result:= FFont.CharKerning[uLeft, uRight].Kerning.x; <------------------------------------------------------
  10. end;
  11. {$ELSE}
  12. begin
  13.   result := 0;
  14. end;{$ENDIF}
Title: Re: New version of BGRABitmap
Post by: circular on May 14, 2020, 05:57:37 pm
If you look in the definition of TFreeTypeFont in EasyLazFreeType, can you actually find the CharKerning property?

If you can, then maybe you need to rebuild the IDE for it to know about it. Otherwise, if it is not there, then the file may not be updated.
Title: Re: New version of BGRABitmap
Post by: lainz on May 14, 2020, 10:56:19 pm
I have EasyLazFreeType from lazarus\components\lazutils\easylazfreetype.pas

And in that file nowhere is included CharKerning.

So maybe is another problem with trunk, the property was removed or replaced with something else..

Edit 2: I've commented that lines and the BGRABitmap library compiles fine, any side effects?

Edit: Another problem is that the new version does not compile with MSEide.

bgrafreetype.pas(31,57) Fatal: Can't find unit EasyLazFreeType used by BGRAFreeType
Fatal: Compilation aborted

This time I did not copy the bgrabitmap folder into lib\common but added a reference with a global macro to the path, and added in project options the macros. I must define something else?
Title: Re: New version of BGRABitmap
Post by: Fred vS on May 15, 2020, 03:17:23 am
Edit: Another problem is that the new version does not compile with MSEide.

bgrafreetype.pas(31,57) Fatal: Can't find unit EasyLazFreeType used by BGRAFreeType
Fatal: Compilation aborted

Please create a global macro LAZUTILSDIR that point to /the/directoryof/lazarus/components/lazutils/

And use that macro in Project - Options - Make - Directories
Title: Re: New version of BGRABitmap
Post by: lainz on May 15, 2020, 03:38:42 am
Edit: Another problem is that the new version does not compile with MSEide.

bgrafreetype.pas(31,57) Fatal: Can't find unit EasyLazFreeType used by BGRAFreeType
Fatal: Compilation aborted

Please create a global macro LAZUTILSDIR that point to /the/directoryof/lazarus/components/lazutils/

And use that macro in Project - Options - Make - Directories

The problem was I forget to add the define -dBGRABITMAP_USE_MSEGUI
Title: Re: New version of BGRABitmap
Post by: Fred vS on May 15, 2020, 03:40:08 am
Hello Lainz.

OK, I will try your new commits now.

Write you later on BGRAgui Github.

Fre;D
Title: Re: New version of BGRABitmap
Post by: lainz on May 15, 2020, 03:42:40 am
Hello Lainz.

OK, I will try your new commits now.

Write you later on BGRAgui Github.

Fre;D

Thanks, yes nothing new, only I fixed the readme and the compilation, moving only the paint procedure from protected to public, nothing more. But that makes it to compile.  :)
Title: Re: New version of BGRABitmap
Post by: lainz on May 15, 2020, 04:17:30 am
Another problem with MSEGUI

Code: Pascal  [Select][+][-]
  1. Free Pascal Compiler version 3.3.1-r43969 [2020/01/18] for i386
  2. Copyright (c) 1993-2019 by Florian Klaempfl and others
  3. Target OS: Win32 for i386
  4. Compiling button.pas
  5. Compiling C:\Users\Damian\Documents\GitHub\bgragui\bgraguicontrols\msegui\bgbutton.pas
  6. Compiling C:\Users\Damian\Documents\GitHub\bgrabitmap\bgrabitmap\bgrabitmap.pas
  7. Compiling C:\Users\Damian\Documents\GitHub\bgrabitmap\bgrabitmap\bgramseguibitmap.pas
  8. Compiling C:\Users\Damian\Documents\GitHub\bgrabitmap\bgrabitmap\bgratext.pas
  9. bgramsegui_text.inc(5,32) Error: Identifier idents no member "Font"
  10. bgramsegui_text.inc(6,18) Error: Identifier idents no member "DrawString"
  11. bgramsegui_text.inc(16,63) Error: Identifier idents no member "Font"
  12. bgramsegui_text.inc(18,35) Error: Identifier idents no member "GetStringWidth"
  13. bgramsegui_text.inc(19,35) Error: Identifier idents no member "Font"
  14. bgramsegui_text.inc(20,18) Error: Identifier idents no member "DrawString"
  15. bgramsegui_text.inc(30,60) Error: Identifier idents no member "GetStringWidth"
  16. bgramsegui_text.inc(31,68) Error: Identifier idents no member "GetStringWidth"
  17. bgramsegui_text.inc(34,55) Error: Identifier idents no member "Font"
  18. bgramsegui_text.inc(35,68) Error: Identifier idents no member "Font"
  19. bgramsegui_text.inc(37,32) Error: Identifier idents no member "Font"
  20. bgramsegui_text.inc(38,18) Error: Identifier idents no member "DrawString"
  21. bgramsegui_text.inc(45,33) Error: Identifier idents no member "GetStringWidth"
  22. bgramsegui_text.inc(45,72) Error: Identifier idents no member "Font"
  23. bgramsegui_text.inc(64,23) Error: Identifier idents no member "GetStringWidth"
  24. bgramsegui_text.inc(78,18) Error: Identifier idents no member "FillRect"
  25. bgratext.pas(272,15) Error: Identifier idents no member "Font"
  26. bgratext.pas(273,15) Error: Identifier idents no member "Font"
  27. bgratext.pas(274,15) Error: Identifier idents no member "Font"
  28. bgratext.pas(275,15) Error: Identifier idents no member "Font"
  29. bgratext.pas(495,3) Warning: Unreachable code
  30. bgratext.pas(505,20) Error: Identifier idents no member "Font"
  31. bgratext.pas(506,20) Error: Identifier idents no member "Font"
  32. bgratext.pas(507,20) Error: Identifier idents no member "Font"
  33. bgratext.pas(509,20) Error: Identifier idents no member "Font"
  34. bgratext.pas(545,19) Error: Identifier idents no member "Font"
  35. bgratext.pas(546,19) Error: Identifier idents no member "Font"
  36. bgratext.pas(547,19) Error: Identifier idents no member "Font"
  37. bgratext.pas(696,22) Error: Identifier idents no member "Font"
  38. bgratext.pas(699,24) Error: Identifier idents no member "Font"
  39. bgratext.pas(702,24) Error: Identifier idents no member "Font"
  40. bgratext.pas(708,24) Error: Identifier idents no member "Font"
  41. bgratext.pas(743,22) Error: Identifier idents no member "Font"
  42. bgratext.pas(746,24) Error: Identifier idents no member "Font"
  43. bgratext.pas(749,24) Error: Identifier idents no member "Font"
  44. bgratext.pas(1102,12) Error: Identifier idents no member "Font"
  45. bgratext.pas(1103,12) Error: Identifier idents no member "Font"
  46. bgratext.pas(1104,12) Error: Identifier idents no member "Font"
  47. bgratext.pas(1179,12) Error: Identifier idents no member "Font"
  48. bgratext.pas(1180,12) Error: Identifier idents no member "Font"
  49. bgratext.pas(1181,89) Error: Identifier idents no member "Font"
  50. bgratext.pas(1182,20) Error: Identifier idents no member "Font"
  51. bgratext.pas(1183,12) Error: Identifier idents no member "Font"
  52. bgratext.pas(1817) Fatal: There were 42 errors compiling module, stopping
  53. Fatal: Compilation aborted
  54.  

I did these steps to configure the IDE (Option 2 - Defines)
https://github.com/bgrabitmap/bgragui/tree/dev-bgragui#option-2---defines

First open 'mymseide' project that comes with mseide-msegui sources. Then add the options in the ide, and in the project options as well, and also in the include file.

Try compiling bgragui\examples\button with the IDE, I get these error messages.
Title: Re: New version of BGRABitmap
Post by: Fred vS on May 15, 2020, 06:04:01 am
> Try compiling bgragui\examples\button with the IDE, I get these error messages.

Please, take a look at BGRAgui Github messages, all is solved there.
Title: Re: New version of BGRABitmap
Post by: circular on May 15, 2020, 07:29:25 am
I have EasyLazFreeType from lazarus\components\lazutils\easylazfreetype.pas

And in that file nowhere is included CharKerning.
Then the file is not up-to-date. Compare to:
https://svn.freepascal.org/svn/lazarus/trunk/components/lazutils/
Title: Re: New version of BGRABitmap
Post by: lainz on May 16, 2020, 01:51:40 am
> Try compiling bgragui\examples\button with the IDE, I get these error messages.

Please, take a look at BGRAgui Github messages, all is solved there.

Thanks, I will commit the fix right now.

I have EasyLazFreeType from lazarus\components\lazutils\easylazfreetype.pas

And in that file nowhere is included CharKerning.
Then the file is not up-to-date. Compare to:
https://svn.freepascal.org/svn/lazarus/trunk/components/lazutils/

Ok, I see that. Seems that my trunk is older.  :)

Edit. I will try to download a new trunk to test, my current trunk is from January.
Title: Re: New version of BGRABitmap
Post by: circular on May 16, 2020, 06:39:07 am
The change was made very recently.

If you use svn on it you get can the update quickly.
Title: Re: New version of BGRABitmap
Post by: kinlion on June 13, 2020, 01:20:55 pm
hi, circular,

I just found a bug of the class TSVGGroup.
please look at https://forum.lazarus.freepascal.org/index.php/topic,50183.0.html (https://forum.lazarus.freepascal.org/index.php/topic,50183.0.html)

Thanks.

The change was made very recently.

If you use svn on it you get can the update quickly.
Title: Re: New version of BGRABitmap
Post by: circular on June 13, 2020, 03:48:39 pm
BGRABitmap v11.1
https://github.com/bgrabitmap/bgrabitmap/releases

- add licence headers in source code
- refactor code generation for Unicode and colorspace
- add Makefile
- fix version check of LazFreeType
- fix group tag in SVG
Title: Re: New version of BGRABitmap
Post by: lainz on June 13, 2020, 05:42:17 pm
Thanks,  8)
Title: Re: New version of BGRABitmap
Post by: process_1 on June 23, 2020, 03:25:34 pm
circular,

All this will be soon available through Online Package Manager?

The second BGRA package available there (BGRA Controls) cannot be compiled on Ubuntu.
Title: Re: New version of BGRABitmap
Post by: circular on June 23, 2020, 05:09:26 pm
I don't see why it would not be on OPM.
Title: Re: New version of BGRABitmap
Post by: MaartenJB on July 15, 2020, 09:42:58 am
Hi Circular,

OPM is not updated with the latest version (see attachment). I noticed it yesterday when I wanted to install bgrabitmap using OPM and got the freetype error.

Best regards

Maarten
Title: Re: New version of BGRABitmap
Post by: circular on July 19, 2020, 05:50:39 pm
That surprising because the json file seems up-to-date:
https://github.com/bgrabitmap/bgrabitmap/blob/master/update_BGRABitmap.json
Title: Re: New version of BGRABitmap
Post by: balazsszekely on July 19, 2020, 06:27:15 pm
Hi Maarten,

I updated BGRABitmap a few days ago, the current version in the central repository is 11.1.0.0 and is the same with the one on @circular's github page.
Title: Re: New version of BGRABitmap
Post by: lainz on July 19, 2020, 06:27:31 pm
The thing is that there are 2 sources for a package in OPM. The one stored at https://packages.lazarus-ide.org/ and the one stored at GitHub / SourceForge that's pointed with the JSON.

One can be more updated than the other, the OPM one is maintained by GetMem, he updates manually the packages zip files that are used by OPM. The other is pointed by 'external sources' (that's actually the official source, but external for OPM) that's in this case GitHub 'master' zip.
Title: Re: New version of BGRABitmap
Post by: circular on July 20, 2020, 04:09:18 am
New version of BGRABitmap 11.2
https://github.com/bgrabitmap/bgrabitmap/releases

- DrawPart can be stretched
- DrawCheckers for universal bitmap
- Optimize Unicode rendering by allowing partial drawing of text
- Add clip margin for vectorial Unicode rendering

Misc fixes
- BGRASVG: Fix SVG color format
- BGRAFreeType: use fixed glyph bounds in Lazarus 2.0.10

MacOS fixes
- Fix text bounds with space ending
- Fix RTL text embedding
- Handles retina in testbiditext2

EDIT: fixed OPM version
Title: Re: New version of BGRABitmap
Post by: bobby100 on July 28, 2020, 10:56:11 pm
Hi, I have a problem with BCSVGViewer and my svg file - the text is rendered in huge proportions.
The SVG file is created with Inkscape and it load fine in other programs. In problem.jpg (in attachment) you can see some black lines - it is part of letter W.
I just load the svg from a file, no processing is done.
Title: Re: New version of BGRABitmap
Post by: circular on July 28, 2020, 11:23:50 pm
I've added the issue:
https://github.com/bgrabitmap/bgrabitmap/issues/120
Title: Re: New version of BGRABitmap
Post by: circular on August 02, 2020, 10:21:29 am
New version of BGRABitmap v11.2.1 with quick fixes
https://github.com/bgrabitmap/bgrabitmap/releases

Compilation fixes
- fix resource path for tests on MacOS
- fix DrawPart overload (to compile BGRAControls on Linux)
- move BGLControls to separate directory to fix compilation on Lazarus 2.0.10

Runtime fix
- avoid undefined size when deserializing image from empty stream

Utility functions
- more utility functions for TBGRAMemOriginalStorage (Empty, EnumerateFiles, FileExists)
- add TAffineBox.Inflate
- gamma correction option for Contour filter
- more functions for TGrayscaleMask
- add TRectF.Include(TPointF)
Title: Re: New version of BGRABitmap
Post by: lainz on August 02, 2020, 10:40:35 pm
Thankyou  :) ;)
Title: Re: New version of BGRABitmap
Post by: circular on August 08, 2020, 04:55:15 pm
You're welcome. Yet another version with more fixes (including the bug in SVG mentioned by bobby100).

BGRABitmap v11.2.2
https://github.com/bgrabitmap/bgrabitmap/releases

New features
- add FillMask function for all image types
- add TBGRAMemoryStreamBitmap type to use memory stream as placeholder for pixel data (in BGRADefaultBitmap unit)
- add stream access in multifile types (if available)
- add RectF(TRect) function

Bug fixes
- TGrayscaleMask: add missing overload keyword
- TBidiTextLayout: fix overflowing paragraph bounds in text layout
- BGRAText: fix multithreading text errors by not reusing the same TBitmap instance in BGRAText
- Canvas2d: render only visible text when using non vectorial text renderer (avoids memory error with very big text)
- BGRASVG: fix bug in unit conversions
Title: Re: New version of BGRABitmap
Post by: lainz on August 08, 2020, 05:00:00 pm
Thanks =)

You had the opportunity to try it in android?
Title: Re: New version of BGRABitmap
Post by: circular on August 08, 2020, 05:10:45 pm
Not yet.  :'(

I am going to install it on MacOS and see what happens.
Title: Re: New version of BGRABitmap
Post by: lainz on August 09, 2020, 05:54:02 pm
Ok. I was looking that you're interested in the ZenGL thread, that's great too, it has or had Android support as well. As well iOS, so maybe you can try on iPhone as well.
Title: Re: New version of BGRABitmap
Post by: circular on August 09, 2020, 05:59:14 pm
Yeah that could be great. Though there seem to be some compatibility issue with 64 bits.
Title: Re: New version of BGRABitmap
Post by: lainz on August 09, 2020, 06:06:48 pm
Ok, yes the transition from 32 to 64. Did you live the transition from 16 to 32? I think I've used only 32 bit apps, and some 16 on Windows 95.
Title: Re: New version of BGRABitmap
Post by: circular on August 09, 2020, 10:00:46 pm
Yes, I've used PCs when they were 16-bits. The transition towards 32-bit did go rather easily as there was much compatibility. In fact, the computer booted in 16-bit and then programs could go to 32-bit if they wanted to. So I don't remember any transition issue personally.

I remember that when programming in Turbo Pascal in DOS, I was using the 16-bit mode. The main restriction for me was memory, either allocating memory or video memory. I remember rarely adding 32-bit assembler instructions by adding $66 byte before assembler instructions.

Code: [Select]
db $66; mov ax, bxwould in fact be
Code: [Select]
mov eax, ebx
That was without actually switching entirely to 32-bit mode. I did not know how to do that. Some games would do, generally using DOS4GW. You could see a few lines written in the DOS terminal when launching those games before they would switch to graphics mode:
Code: [Select]
DOS/4GW Protected Mode Run-time   Version 1.97
Copyright (c) Rational Systems, Inc. 1990-1994

Windows would also use 32-bit mode. So there was a 32-bit version of Pascal. Things were quite similar in fact, except that pointers would now be just one number. In 16-bit mode, you had two numbers: a segment and a 16-bit offset. The actual address was segment*16 + offset. So you needed sometimes to take that into consideration.

Programming under Windows was a bit frustrating to me in the beginning because it was not obvious to switch to fullscreen graphics and you had to write CreateWindows and similar calls to the API to make the interface. Things became better when Delphi arrived.

This 32-bit mode was "protected" as DOS4GW banner says. It means that you could not access any memory and so you would not crash your computer when you messed up with a pointer. Back then in 16-bit, you could have to press Ctrl-Alt-Del to reboot quite often until you got your pointers right. Or even turn off and on the computer manually.

So 32-bit was not just about bigger numbers, it made everything easier and safer. And at the same time, 16-bit programs would still run. Either in a console under Windows or by staying in the real DOS and running the game from there using the command line. In protected mode though, you can not change system memory if you want to.

The real incompatibilities for 16-bit came when Windows would replace completely DOS. Some DOS games would still work fine under Windows, but not all of them. It felt a bit awkward that even fullscreen games would need to be programmed for Windows in order to function properly, even though they would not use the GUI.
Title: Re: New version of BGRABitmap
Post by: lainz on August 10, 2020, 01:33:04 am
Interesting.

I remember just playing 16 bit games, with this console
https://en.wikipedia.org/wiki/Sega_Genesis#/media/File:Sega-Genesis-Mk2-6button.jpg

I remember my fingers getting damaged with that small controller.
Title: Re: New version of BGRABitmap
Post by: winni on August 10, 2020, 01:56:42 am
Hi!

I had the biggest problem with the missdesign of the Intel 386: The maximum data chunk was 64k. So you were allways working with pointer lists  to handle bigger amounts of data (pictures).

That was a big disadvantage compared to the Atari ST with Motorola 68000 where you could  allocate a picture in one go - if you had enough memory.

Great help was a guy from Finnland who wrote the unit HugeArray. With the help of it you could allocate as much memory as was available for Delphi16.

Yes, 32 bits were a big progress, but Win95 was awful slow on your old hardware. You had to buy some new.

Winni

Title: Re: New version of BGRABitmap
Post by: circular on August 10, 2020, 09:48:30 am
I had the biggest problem with the missdesign of the Intel 386: The maximum data chunk was 64k. So you were allways working with pointer lists  to handle bigger amounts of data (pictures).
I suppose you mean 8086. Indeed using the same segment you would have only 64k.

Quote
Yes, 32 bits were a big progress, but Win95 was awful slow on your old hardware. You had to buy some new.
Indeed, at the time of Win95, you needed to have some time before it would boot up. Or try to optimize the system by deactivating services.
Title: Re: New version of BGRABitmap
Post by: bobby100 on September 10, 2020, 05:11:42 pm
In Lazarus/Online Package Manager - it is still showing 11.2.1.0 as the latest version.
Title: Re: New version of BGRABitmap
Post by: winni on September 10, 2020, 05:52:03 pm
@circular

The 386 was widely used for Delphi 1 with 16 bit and Windows 3.1 / 3.11.
There you had the problem with the 64k  chunks.

For Windows 95 with 32 bit the 386 was to slow.
You had to buy a 486 [The last one without a fan]
Or a Pentium  I.

So my post was not exact enough.

Winni


Title: Re: New version of BGRABitmap
Post by: circular on September 11, 2020, 01:36:42 am
Yeah at the time of Win 3.1, I did not bother programming under Windows. Rather do the interface myself.  :D
Title: Re: New version of BGRABitmap
Post by: PascalDragon on September 11, 2020, 09:18:44 am
The 386 was widely used for Delphi 1 with 16 bit and Windows 3.1 / 3.11.
There you had the problem with the 64k  chunks.

That wasn't a problem of the 386 however, cause that already supported paging in contrast to the 286 that only supported segmented memory. The problem was that both Delphi 1 and Windows 3.1(1) did not support anything else than segmentation.
Title: Re: New version of BGRABitmap
Post by: circular on September 28, 2020, 10:28:58 am
New version 11.2.3 of BGRABitmap
https://github.com/bgrabitmap/bgrabitmap/releases

Layer originals
- Fixed reading undefined boolean value
- Catching loading error with OnOriginalLoadError event
- bigger pen size of editor points if points are big

Misc
- ParallelFloodFill can be done on universal bitmap
- added TRectF.Contains
- Thumbnail checkers have a scale property (scale 1 = 8 pixels)

Text
- Fix word break with line endings
- Handle unicode line endings
- added TextOut with letter spacing parameter
- added TGlyphCursorUTF8 in BGRAUTF8 to browse through multi chars
- save text baseline in Canvas2d state
Title: Re: New version of BGRABitmap
Post by: circular on October 04, 2020, 05:48:54 pm
New version 11.2.4 with minor changes:
- precision of multiply and divide blend modes
- compare values in originals with the stored level of precision
Title: Re: New version of BGRABitmap
Post by: circular on October 18, 2020, 06:12:01 pm
New version 11.2.5
https://github.com/bgrabitmap/bgrabitmap/releases

OpenRaster format:
- get thumbnail from merged image if the thumbnail is not provided
- ensure adequate temporary file is used when zipping (when saving as OpenRaster)

Geometry:
- Canvas2d: accept odd number of values in dash array
- TBGRABitmap: fix edge cases of arcs

Misc:
- StretchPutImage now accepts TBitmap
Title: Re: New version of BGRABitmap
Post by: circular on November 27, 2020, 12:15:34 pm
New version 11.3
https://github.com/bgrabitmap/bgrabitmap/releases

General
- support for Qt5
- compilation path include widgetset
- update LGPL license
- add FontExists function to text renderers

Layer blending
- add HSL and corrected HSL (GSB) blend modes
- add blend with solid color rectangle instead of bitmap
- possible to exclude channels from blending

OpenRaster
- read substacks
- more permissive image format
- support for SVG layers (compatible with MyPaint)
- remove obsolete PNG hack
- fix path of thumbnail on non-Windows platforms

SVG
- fix units (this may change the behavior but it was not consistent with spec, you may thus need to exchange pixel units and custom units and to scale the values according to view box)
- support for % coordinates
- add ConvertToUnit function
- add CropToViewbox function
- functions to get presentation matrix (transform to apply before drawing in view box units)
- more functions to append, move and remove elements
- more LCL-typed attributes (font style, line cap, line join)
- gradients: support for gradient on stroke, spreadMethod and color interpolation
- text: support for characters rotation and offset, font list fallback
- support for paint order
- support for A tag (anchor, similar to group)
- support for IMG tag (image with inline data)

Layered SVG
- support for layers (read/write, compatible with Inkscape)
- export from other originals (gradient, image)
- use vectorized font in original
- handles duplicate ids in different groups

To load/save as layered SVG, you need to use TBGRALayeredSVG class from BGRASVGOriginal unit. Then you can add/remove layers, either bitmap or SVG or any original that supports SVG export.
Title: Re: New version of BGRABitmap
Post by: lainz on November 28, 2020, 03:04:19 am
Thanks this release is so cool for SVG.
Title: Re: New version of BGRABitmap
Post by: circular on August 08, 2021, 12:17:12 pm
New version 11.4
https://github.com/bgrabitmap/bgrabitmap/releases

Important note : in the incoming version of Lazarus 2.2, in any BGRABitmap package, one will need to add a condition to use freetypelaz package. Indeed, FreeType support has been move from lazutils package to freetypelaz package.

Fixes and improvements for BGRAAnimatedGif

Compilation fixes for fpGUI, noGUI and mseGUI.

Added sample project for ideU in test/test4ideu
Title: Re: New version of BGRABitmap
Post by: Okoba on August 08, 2021, 02:31:50 pm
Nice job Circular!
Title: Re: New version of BGRABitmap
Post by: circular on August 08, 2021, 02:58:21 pm
Thanks. I had some time at last to take care and heal BGRABitmap little mishaps.
Title: Re: New version of BGRABitmap
Post by: Fred vS on August 08, 2021, 05:54:05 pm
New version 11.4
https://github.com/bgrabitmap/bgrabitmap/releases

Important note : in the incoming version of Lazarus 2.2, in any BGRABitmap package, one will need to add a condition to use freetypelaz package. Indeed, FreeType support has been move from lazutils package to freetypelaz package.

Fixes and improvements for BGRAAnimatedGif
  • display animated Gif in dialogs
  • handle Assign
  • OptimizeFrames function
  • compatibility on various systems

Compilation fixes for fpGUI, noGUI and mseGUI.

Added sample project for ideU in test/test4ideu

Magnifique!

Many thanks Circular.

Fre;D
Title: Re: New version of BGRABitmap
Post by: circular on August 09, 2021, 12:48:34 am
 :)
Title: Re: New version of BGRABitmap
Post by: mosquito on September 26, 2021, 04:53:22 pm
thx master !!
Title: Re: New version of BGRABitmap
Post by: Josh on October 11, 2021, 07:25:34 pm
Hi

Just loaded fresh fpc & Laz both trunk versions on MacOS, but getting error installing 11.4Compile package

BGRABitmapPack 11.4: Exit code 1, Errors: 3, Hints: 4
Hint: Start of reading config file /Users/josh/Documents/LazTrunkUse/fpc/bin/x86_64-darwin/fpc.cfg
Hint: End of reading config file /Users/josh/Documents/LazTrunkUse/fpc/bin/x86_64-darwin/fpc.cfg
Verbose: Free Pascal Compiler version 3.3.1-9412-g068f781c7a-dirty [2021/10/11] for x86_64
Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others
Verbose: Target OS: Darwin for x86_64
Verbose: Compiling bgrabitmappack.pas
Verbose: Compiling bgraanimatedgif.pas
Verbose: Compiling bgrabitmap.pas
Verbose: Compiling bgramacbitmap.pas
Verbose: Compiling bgralclbitmap.pas
Verbose: Compiling bgradefaultbitmap.pas
Verbose: Compiling bgracanvas.pas
Verbose: Compiling bgrapen.pas
Verbose: Compiling bgratransform.pas
bgratransform.pas(935,3) Note: Call to subroutine "procedure TBGRAAffineScannerTransform.ScanMoveToF(X:Single;Y:Single);" marked as inline is not inlined
bgratransform.pas(991,3) Note: Call to subroutine "procedure TBGRAQuadLinearScanner.GetTexColorAt(u:Single;v:Single;out AColor:TBGRAPixel;out AIsPadding:Boolean);" marked as inline is not inlined
bgratransform.pas(1071,1) Error: Compilation raised exception internally
Error: An unhandled exception occurred at $000000010B4B98E9:
Error: EAccessViolation: Access violation
Debug:   $000000010B4B98E9
Debug:
Verbose: Compilation aborted
Verbose: /Users/josh/Documents/LazTrunkUse/fpc/bin/x86_64-darwin/ppcx64 returned an error exitcode
Title: Re: New version of BGRABitmap
Post by: Fred vS on October 11, 2021, 07:48:47 pm
Hi

Just loaded fresh fpc & Laz both trunk versions on MacOS, but getting error installing 11.4Compile package

BGRABitmapPack 11.4: Exit code 1, Errors: 3, Hints: 4
Hint: Start of reading config file /Users/josh/Documents/LazTrunkUse/fpc/bin/x86_64-darwin/fpc.cfg
Hint: End of reading config file /Users/josh/Documents/LazTrunkUse/fpc/bin/x86_64-darwin/fpc.cfg
Verbose: Free Pascal Compiler version 3.3.1-9412-g068f781c7a-dirty [2021/10/11] for x86_64
Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others
Verbose: Target OS: Darwin for x86_64

Hello Josh.

Did you try with fpc 3.2.2 (or 3.2.0) with same result?

Fe;D
Title: Re: New version of BGRABitmap
Post by: Josh on October 15, 2021, 09:21:59 am
Hi

If I change debug options for BGRABitmap so that RangeCheck is enabled, it then compiles ok.

So once that succeded I attempted install of bgracontrols 7.3, this though generated an error comparemethod not found.
this is down to it being moved from lazutils to lazmethodlist, as the function is becoming deprecated.

If I add this unit into BCgamegrid uses section, this then compiles ok. Not an ideal solution, as is only valid for latest fpc/laz trunk.




Title: Re: New version of BGRABitmap
Post by: circular on October 16, 2021, 08:20:18 am
Maybe this can be done with a compiler directive.
Code: Pascal  [Select][+][-]
  1. uses ... {$IF FPC_FULLVERSION >= 30202}, lazmethodlist{$ENDIF}
Title: Re: New version of BGRABitmap
Post by: Josh on October 16, 2021, 10:51:34 am
Hi Circular

I think that approach could resolve the uses section.

However as the unit is part of lazarus, should the check be directed towards the lazarus version not FPC?

Using the laz version check it could also be used to use the replacement function SameMethod as defined in lazmethodlist in
BCGameGrid.

Any ideas as to why BGRABitmap only compiling on fpc trunk when I set the BGRABitmap package options to enable rangechecking.?
Title: Re: New version of BGRABitmap
Post by: lainz on October 16, 2021, 08:45:25 pm
Hi, please try again with dev bgracontrols. I've removed the dependency on comparemethod.
Title: Re: New version of BGRABitmap
Post by: Fred vS on October 16, 2021, 09:32:00 pm
Hi Circular

I think that approach could resolve the uses section.

However as the unit is part of lazarus, should the check be directed towards the lazarus version not FPC?

Using the laz version check it could also be used to use the replacement function SameMethod as defined in lazmethodlist in
BCGameGrid.

Any ideas as to why BGRABitmap only compiling on fpc trunk when I set the BGRABitmap package options to enable rangechecking.?

Hello.

Maybe add the Lazarus dependencies according to current BGRABitmap in source?
https://github.com/bgrabitmap/bgrabitmap/issues/139
Title: Re: New version of BGRABitmap
Post by: circular on October 17, 2021, 08:39:16 am
However as the unit is part of lazarus, should the check be directed towards the lazarus version not FPC?
Indeed.

Quote
Any ideas as to why BGRABitmap only compiling on fpc trunk when I set the BGRABitmap package options to enable rangechecking.?
Looks like a compiler bug to me.

Quote
Hi, please try again with dev bgracontrols. I've removed the dependency on comparemethod.
Yeah that's another way. Even better as the original function is deprecated.
Title: Re: New version of BGRABitmap
Post by: Lulu on June 01, 2022, 02:20:45 pm
Hi,
I try to port an application under Windows to Linux-gtk2 64b. The application use TBGLVirtualScreen and IBGLRenderedFont.
It work well under Windows, but when I compile and run it under Linux-gtk2-64bits an SIGSEGV exception occurs when accessing the font previously created.

I join a project to illustrate the problem. Please, can someone try it under GTK2 to know if there is also an sigsegv exception ?

Thanks you for your help.
Title: Re: New version of BGRABitmap
Post by: AlexTP on June 01, 2022, 04:25:57 pm
@Lulu
I run your project on Ubuntu x64 w/o problem, it shows welcome message over the gray area.
Title: Re: New version of BGRABitmap
Post by: winni on June 01, 2022, 07:44:53 pm
Hi!

Project runs with Linux without a crash, but the "Hello World" is hard squeezed - see screenshot.

fpc 3.2.2 laz 2.2.2
gtk-2
Lin64 Suse Tumbleweed

Winni
Title: Re: New version of BGRABitmap
Post by: circular on June 01, 2022, 08:22:38 pm
@Lulu: I suggest to provide a font name, at least "sans" for sans serif or "serif". Ideally a font name you know exists.
Title: Re: New version of BGRABitmap
Post by: Lulu on June 02, 2022, 09:07:44 am
AlexTP, Winni, thanks for testing
@Circular, yes it work better with a font name, without exception, thanks !
Title: Re: New version of BGRABitmap
Post by: circular on June 02, 2022, 07:25:56 pm
You're welcome  :)
Title: Re: New version of BGRABitmap
Post by: circular on June 03, 2022, 07:21:55 am
New version (11.5) of BGRABitmap:
- adapted dependency for fpGui and NoGui for latest Lazarus 2.2
- support for AVIF format (note that the AVIF library is experimental and may be incompatible in the future, latest supported version is 0.10.1)
- better dynamic linking (for libwebp and libavif on Linux and MacOS)
- automatic handling of transparent TBitmap and more explicit Assign function
- removed some DC leaks when taking screenshot
- support for 16bpp TRawImage
- added IsMostlyClockwise function to check for orientation of polygon (even if concave)
- avoid error with freed pointer in BGRAAnimatedGif

SVG :
- color global property of SVG (can be used with currentColor keyword)
- added IterateElements in main SVG class to customize manually
- fixed color to string, deleting style element
- support for multi class CSS
- fixed Canvas2d nested mask

https://github.com/bgrabitmap/bgrabitmap/releases

Title: Re: New version of BGRABitmap
Post by: circular on August 21, 2022, 12:28:02 pm
New version (11.5.2) of BGRABitmap
https://github.com/bgrabitmap/bgrabitmap/releases

In version 11.5.1:
- fix for text and compilation with mseGUI

In version 11.5.2:
- fix screenshot on MacOS
- detect click count on layer original
- detect text glyph click

Title: Re: New version of BGRABitmap
Post by: Phoenix on August 21, 2022, 02:27:11 pm
Thanks for the current version and also for the previous releases  :D!
Title: Re: New version of BGRABitmap
Post by: circular on August 21, 2022, 07:23:23 pm
You're very welcome  :)
Title: Re: New version of BGRABitmap
Post by: funlw65 on August 29, 2022, 11:30:10 am
New OS installed, Linux Debian 11 based. Lazarus 2.2.2., fpc 3.2.3 fixes.
I try to install BGRA from OPM, I get an error in the .inc auto generated files:

generatedcolorspace.inc:
Code: Pascal  [Select][+][-]
  1. class function TColorColorspace.GetChannel(AColor: Pointer; AIndex: integer): single;
  2. begin
  3.   case AIndex of
  4.   0: result := TColor(AColor^).red;

Error is:
generatedcolorspace.inc(2684,32) Error: Illegal qualifier
pointing to red (green and blue).
Title: Re: New version of BGRABitmap
Post by: circular on August 31, 2022, 07:38:55 pm
Seems that in dev version of FPC type helpers don’t work with scalar. Not sure if this is a bug or a feature.
Title: Re: New version of BGRABitmap
Post by: ginky on October 05, 2022, 04:34:28 pm
Hi

I found a bug but not sure.

Loading BMP image file with compresson method OS22XBITMAPHEADER: Huffman 1D (Offset 1E, Value 3) results in colors artifacts on drawed image.
With HEX editor I've changed Value to 0 (Compression method - none). After that the image drawed perfect.

Lools like BGRABitmap does not have support for older compression methods.

edit1. How I can fix that?

Thanks
Title: Re: New version of BGRABitmap
Post by: circular on October 05, 2022, 08:17:35 pm
Hi,

I am a bit confused. Are you saying that changing the number indicating the compression method shows the image perfectly? That would mean that in fact the bitmap is not compressed.

Can you provide the image as attachment?

It is possible to change the reader to handle new formats.

Regards
Title: Re: New version of BGRABitmap
Post by: ginky on October 05, 2022, 08:37:52 pm
Hi,

I am a bit confused. Are you saying that changing the number indicating the compression method shows the image perfectly? That would mean that in fact the bitmap is not compressed.

Can you provide the image as attachment?

It is possible to change the reader to handle new formats.

Regards

I don't know bmp format well enough but image viewers open my file without errors (before and after editing).

File too big so compressed (it's texture).

https://drive.google.com/file/d/1EvXnqMiJkYZ79Qw3BQaKcD6f-HdYA1pn/view?usp=sharing (https://drive.google.com/file/d/1EvXnqMiJkYZ79Qw3BQaKcD6f-HdYA1pn/view?usp=sharing)

Title: Re: New version of BGRABitmap
Post by: circular on October 06, 2022, 07:50:12 am
Ok so this is not a compressed image. Method 3 indicated at position 30 is BI_BITFIELDS which specifies where to get the red/green/blue components in each pixel data. But those bit fields (at position 138) are not set properly, they indicate RGB order whereas this file, as it is generally the case for BMP, is in BGR order. So when you load it you get those colors swapped.

In LazPaint, you can see that by swapping red and blue colors using "filter function". Or by code using SwapRedBlue function.

You can indeed fix the file either by setting 0 as compression method, or by changing the bit fields to 0000FF00 00FF0000 FF000000 instead of FF000000 00FF0000 0000FF00.
Title: Re: New version of BGRABitmap
Post by: ginky on October 06, 2022, 09:55:23 am
Hi,

Thanks for explanation.

I have no way to fix the file in production so is there any way to fix this by BGRABitmap?
Title: Re: New version of BGRABitmap
Post by: circular on October 06, 2022, 01:32:19 pm
Yes, as I mentioned, you can call bmp.SwapRedBlue after loading the file where bmp is your TBGRABitmap object.
Title: Re: New version of BGRABitmap
Post by: ginky on October 06, 2022, 02:27:31 pm
Yes, as I mentioned, you can call bmp.SwapRedBlue after loading the file where bmp is your TBGRABitmap object.

Hmm....but how I can detect wrong RGB order? :)

edit.1 Solved a problem. Before displaying the file, first I read it in memory and change the compression flag.
Title: Re: New version of BGRABitmap
Post by: circular on October 08, 2022, 11:02:14 am
Ok yeah that's one way to solve the problem as it seems anyway the data is always in the BGR order.
Title: Re: New version of BGRABitmap
Post by: Josh on November 08, 2022, 06:42:03 pm
Hi

Just tried to update my fpc and laz fixes to latest using fpcupdeluxe
andam getting

Code: Pascal  [Select][+][-]
  1. M:\LazarusFixes32\config_lazarus\onlinepackagemanager\packages\bgrabitmap-master\bgrabitmap\generatedcolorspace.inc(2684,32) Error: (3205) Illegal qualifier
  2. (3104) Compiling fpdbghardcodedfreepascalinfo.pas
  3. (3104) Compiling syncompletion.pas
  4. (3104) Compiling synedit.pp
  5. (3104) Compiling lazsynimmbase.pas
  6. (3104) Compiling lazsynimm.pas
  7. (3104) Compiling syntextdrawer.pp
  8. M:\LazarusFixes32\config_lazarus\onlinepackagemanager\packages\bgrabitmap-master\bgrabitmap\generatedcolorspace.inc(2685,32) Error: (3205) Illegal qualifier
  9. M:\LazarusFixes32\config_lazarus\onlinepackagemanager\packages\bgrabitmap-master\bgrabitmap\generatedcolorspace.inc(2686,32) Error: (3205) Illegal qualifier
  10. M:\LazarusFixes32\config_lazarus\onlinepackagemanager\packages\bgrabitmap-master\bgrabitmap\generatedcolorspace.inc(2694,22) Error: (3205) Illegal qualifier
  11. M:\LazarusFixes32\config_lazarus\onlinepackagemanager\packages\bgrabitmap-master\bgrabitmap\generatedcolorspace.inc(2695,22) Error: (3205) Illegal qualifier
  12. M:\LazarusFixes32\config_lazarus\onlinepackagemanager\packages\bgrabitmap-master\bgrabitmap\generatedcolorspace.inc(2696,22) Error: (3205) Illegal qualifier

Any fix for this
Title: Re: New version of BGRABitmap
Post by: circular on November 12, 2022, 07:16:53 am
Hello Josh,

This is a bug with development version of FPC:
https://gitlab.com/freepascal.org/fpc/source/-/issues/38678

You can avoid this problem by replacing the functions TColorColorspace.GetChannel and TColorColorspace.SetChannel by the following:
Code: Pascal  [Select][+][-]
  1. class function TColorColorspace.GetChannel(AColor: Pointer; AIndex: integer): single;
  2. begin
  3.   case AIndex of
  4.   0: result := {$IFDEF TCOLOR_BLUE_IN_LOW_BYTE}(TColor(AColor^) shr 16) and $ff{$ELSE}TColor(AColor^) and $ff{$ENDIF};
  5.   1: result := (TColor(AColor^) shr 8) and $ff;
  6.   2: result := {$IFDEF TCOLOR_BLUE_IN_LOW_BYTE}TColor(AColor^) and $ff{$ELSE}(TColor(AColor^) shr 16) and $ff{$ENDIF};
  7.   else raise ERangeError.Create('Index out of bounds');
  8.   end;
  9. end;
  10.  
  11. class procedure TColorColorspace.SetChannel(AColor: Pointer; AIndex: integer; AValue: single);
  12. var channelValue: byte;
  13. begin
  14.   channelValue := Round(Clamp(AValue,0,255));
  15.   case AIndex of
  16.   0: TColor(AColor^) := {$IFDEF TCOLOR_BLUE_IN_LOW_BYTE}(LongWord(AColor^) and $00ffff) or (channelValue shl 16){$ELSE}(LongWord(AColor^) and $ffff00) or channelValue{$ENDIF};
  17.   1: TColor(AColor^) := (LongWord(AColor^) and $ff00ff) or (channelValue shl 8);
  18.   2: TColor(AColor^) := {$IFDEF TCOLOR_BLUE_IN_LOW_BYTE}(LongWord(AColor^) and $ffff00) or channelValue{$ELSE}(LongWord(AColor^) and $00ffff) or (channelValue shl 16){$ENDIF};
  19.   else raise ERangeError.Create('Index out of bounds');
  20.   end;
  21. end;

I have patched temporarily the file on the dev branch:
https://github.com/bgrabitmap/bgrabitmap/commit/fe96b8371178cf9cd8c980ced92f3d2f4051e457
Title: Re: New version of BGRABitmap
Post by: circular on November 12, 2022, 07:19:05 am
New version of BGRABitmap (11.5.3) :
https://github.com/bgrabitmap/bgrabitmap/releases

It is an update to handle latest version of LibAvif. Thanks to DomingoGP for the pull request  :)
Title: Re: New version of BGRABitmap
Post by: funlw65 on November 12, 2022, 11:15:09 am
Thank you, it would have been a shame not to have this great package that can make a lot of difference regarding the look of your app.

Regarding it's gtk2 dependence, I would have thought that that would have been it's "foot of clay" but even today Slackware 15 delivers the first version (1.x) of gtk libraries alongside gtk2, 3 and 4. And as a tip, a pleasant way to use Slackware 15 is to install Salix (https://sourceforge.net/projects/salix/) 15 or Slackel (https://sourceforge.net/projects/slackel/) 7.5 distros... So, the future of gtk2 looks good!
Title: Re: New version of BGRABitmap
Post by: Fred vS on November 12, 2022, 03:00:57 pm
Congrats for the new release!  ;D
Tested with fpc-llvm 3.3.1. and works like charm ( WoW animations with -O4 on BGRABitmap/MSEgui apps).
Fre;D
Title: Re: New version of BGRABitmap
Post by: DomingoGP on November 12, 2022, 05:57:24 pm
Quote
Thanks to DomingoGP for the pull request  :)

You're welcome  :)
Title: Re: New version of BGRABitmap
Post by: circular on November 12, 2022, 07:37:33 pm
Regarding it's gtk2 dependence, I would have thought that that would have been it's "foot of clay" but even today Slackware 15 delivers the first version (1.x) of gtk libraries alongside gtk2, 3 and 4. And as a tip, a pleasant way to use Slackware 15 is to install Salix (https://sourceforge.net/projects/salix/) 15 or Slackel (https://sourceforge.net/projects/slackel/) 7.5 distros... So, the future of gtk2 looks good!
I am glad GTK2 is still on.  :)

Well maybe LCL will catch up at some point.

Congrats for the new release!  ;D
Tested with fpc-llvm 3.3.1. and works like charm ( WoW animations with -O4 on BGRABitmap/MSEgui apps).
Fre;D
Cool. Did you use the dev-bgrabitmap branch to overcome the compiler bug?

You're welcome  :)
I am glad to have some people contributing, I am less alone maintaining the package  :)
Title: Re: New version of BGRABitmap
Post by: Fred vS on November 12, 2022, 09:19:24 pm
Congrats for the new release!  ;D
Tested with fpc-llvm 3.3.1. and works like charm ( WoW animations with -O4 on BGRABitmap/MSEgui apps).
Fre;D
Cool. Did you use the dev-bgrabitmap branch...

I used the zip file from release: https://github.com/bgrabitmap/bgrabitmap/releases/tag/v11.5.3

Quote
... to overcome the compiler bug?

Huh, what compiler bug?  :-\
I did test compiling with fpc-llvm 3.3.1 (from main last week) using this to build it : https://forum.lazarus.freepascal.org/index.php/topic,61069.msg459333.html#msg459333
And no problems, all bgrabitmap anims + images are perfect.

Just tested now with fpc 3.2.2 and all ok too.

Ho, forgot to say that the tests where done on Debian 11, not yet on Windows.

[EDIT] OK, I see your patch for current bug in FPC with type helpers .
            Nice and thanks. (but I did not feel something wrong, maybe my code dont use it.)

Fre;D
Title: Re: New version of BGRABitmap
Post by: funlw65 on November 13, 2022, 10:25:00 am
bgrasvgimagelist unit (from dev-bgrabitmap) fails to compile with fpc-3.2.3...
The error messages are:
Quote
bgrasvgimagelist.pas(168,57) Error: Illegal qualifier
bgrasvgimagelist.pas(181,35) Error: Illegal qualifier
pointing to "i.ToString"


Code: Pascal  [Select][+][-]
  1. procedure TBGRASVGImageList.Load(const XMLConf: TXMLConfig);
  2. var
  3.   i, j, index: integer;
  4. begin
  5.   try
  6.     FItems.Clear;
  7.     j := XMLConf.GetValue('Count', 0);
  8.     for i := 0 to j - 1 do
  9.     begin
  10.       index := FItems.Add(TStringList.Create);
  11.       FItems[index].Text := XMLConf.GetValue('Item' + i.ToString + '/SVG', '');
  12.     end;
  13.   finally
  14.   end;
  15. end;
  16.  
  17. procedure TBGRASVGImageList.Save(const XMLConf: TXMLConfig);
  18. var
  19.   i: integer;
  20. begin
  21.   try
  22.     XMLConf.SetValue('Count', FItems.Count);
  23.     for i := 0 to FItems.Count - 1 do
  24.       XMLConf.SetValue('Item' + i.ToString + '/SVG', FItems[i].Text);
  25.   finally
  26.   end;
  27. end;
  28.  

Lazarus stopped compiling, don't know if there are more files affected... I looked at the repository and saw that only previously reported file has been patched... that means that the BGRABitmap has not been fully tested yet with 3.2.3 or 3.3.1 versions?
Title: Re: New version of BGRABitmap
Post by: circular on November 17, 2022, 07:53:45 am
bgrasvgimagelist.pas is rather in dev-bgracontrols.

The error is similar, a regression from the compiler regarding type helpers.

You can replace "i.ToString" by "IntToStr(i)". Does it fix the problem?

Not sure about BGRAControls, but personally I use stable FPC.

Using the development branch of FPC can cause some strange errors like this one.
Title: Re: New version of BGRABitmap
Post by: lainz on November 17, 2022, 01:30:42 pm
> Not sure about BGRAControls, but personally I use stable FPC.

When I do bgracontrols I use stable FPC too.
Title: Re: New version of BGRABitmap
Post by: funlw65 on November 18, 2022, 02:19:24 pm
bgrasvgimagelist.pas is rather in dev-bgracontrols.

The error is similar, a regression from the compiler regarding type helpers.

You can replace "i.ToString" by "IntToStr(i)". Does it fix the problem?

Not sure about BGRAControls, but personally I use stable FPC.

Using the development branch of FPC can cause some strange errors like this one.

So, these fixes will be unnecessary when  the development version will be fixed? Well, I'm not so much into 3.3.1 fpc as I am into 3.2.3-fixes... Still, don't want to have a Frankenstein BGRABitmap version, I'll stick with the stable version for now. Thank you!
Title: Re: New version of BGRABitmap
Post by: circular on May 26, 2023, 01:24:19 pm
New version of BGRABitmap v11.5.4:
- fix compilation with FPC
- improve text justification with TextOutCurved
- fix some text rendering issues
- use recommended way of raising memory exception
- fix interface for some test projects

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: KodeZwerg on May 26, 2023, 01:39:37 pm
I hope OPM will add it soon.
Title: Re: New version of BGRABitmap
Post by: DomingoGP on May 27, 2023, 09:45:29 am
Thanks for the new release!  ;D
Title: Re: New version of BGRABitmap
Post by: Okoba on May 27, 2023, 11:10:03 am
Well done @circular.
Title: Re: New version of BGRABitmap
Post by: circular on May 27, 2023, 01:59:44 pm
Thanks, that’s not much but the key is to maintain so that users have a continuous experience.  :)
Title: Re: New version of BGRABitmap
Post by: Okoba on May 28, 2023, 04:12:55 pm
Exactly. BGRABitmap was and is one of the best libraries I worked with.
Title: Re: New version of BGRABitmap
Post by: circular on May 28, 2023, 05:18:09 pm
Exactly. BGRABitmap was and is one of the best libraries I worked with.
I am very much touched by your kind words. <3
Title: Re: New version of BGRABitmap
Post by: circular on August 09, 2023, 07:41:04 pm
BGRABitmap v11.5.5

- pixel resolution support for BMP, TIFF, JPEG, PCX, PNG, PSD
- add YCbCr colorspace family based on sRGB
- compatibility with older/newer Lazarus
- BGRABitmap4NoLCL package completely independant from LCL

https://github.com/bgrabitmap/bgrabitmap/releases
Title: Re: New version of BGRABitmap
Post by: lainz on August 09, 2023, 10:31:49 pm
Thanks for the new version.

What are the main differences with BGRABitmap4nogui and BGRABitmap4nolcl? Who are the target applications for each one?
Title: Re: New version of BGRABitmap
Post by: circular on August 10, 2023, 01:19:14 am
BGRABitmap4nogui is in fact related to the LCL, but without graphic user interface (no GUI). So one can use for example LazFreeType with it.

BGRABitmap4nolcl is completely independant from the LCL. There is no more font rendering (neither system rendering nor from TrueType files). Though with another program that has the LCL, you could prepare a TBGRAVectorizedFont, compute necessary glyphs, save it to a file with SaveGlyphsToFile. Then in the program without LCL, load the file with LoadGlyphsFromFile.

Note that MSEgui provides system rendering of fonts, so this incorporated into an MSEgui program, you have the usual font rendering:
https://github.com/bgrabitmap/bgrabitmap/issues/139#issuecomment-1672184739
Title: Re: New version of BGRABitmap
Post by: qk on August 11, 2023, 08:28:58 pm
Thanks for the new version!
When will it be available on OPM?

Regards
Title: Re: New version of BGRABitmap
Post by: KodeZwerg on August 11, 2023, 09:39:08 pm
When I try to display Images, I just getting a black screen, what am I missing or do wrong?
Code: Pascal  [Select][+][-]
  1. procedure AssignBase64ToImage(const ABase64String: AnsiString; const AImage: TImage);
  2. var
  3.   bytes: TBytes;
  4.   graphic: TBGRABitmap;
  5.   stream: TStream;
  6.   bmp: TBitmap;
  7. begin
  8.   AImage.Picture.Clear;
  9.   bytes := Base64ToBytes(ABase64String);
  10.   if IsBRGACompatible(bytes) then
  11.     begin
  12.       graphic := TBGRABitmap.Create;
  13.       try
  14.         stream := TBytesStream.Create(bytes);
  15.         try
  16.           graphic.LoadFromStream(stream);
  17.           bmp := TBitmap.Create;
  18.           try
  19.             bmp.Assign(graphic.Bitmap);
  20.             AImage.Picture.Assign(bmp);
  21.           finally
  22.             bmp.Free;
  23.           end;
  24.         finally
  25.           stream.Free;
  26.         end;
  27.       finally
  28.         graphic.Free;
  29.       end;
  30.     end;
  31. end;
Title: Re: New version of BGRABitmap
Post by: phoenix27 on August 11, 2023, 10:50:55 pm
Circular, can BGRABitmap be used in Delphi?
Title: Re: New version of BGRABitmap
Post by: lainz on August 11, 2023, 11:56:37 pm
Circular, can BGRABitmap be used in Delphi?
Yes both bgrabitmap and bgracontrols

You need to use bgrabitmap 4 Delphi repository
Title: Re: New version of BGRABitmap
Post by: lainz on August 11, 2023, 11:58:00 pm
When I try to display Images, I just getting a black screen, what am I missing or do wrong?
Code: Pascal  [Select][+][-]
  1. procedure AssignBase64ToImage(const ABase64String: AnsiString; const AImage: TImage);
  2. var
  3.   bytes: TBytes;
  4.   graphic: TBGRABitmap;
  5.   stream: TStream;
  6.   bmp: TBitmap;
  7. begin
  8.   AImage.Picture.Clear;
  9.   bytes := Base64ToBytes(ABase64String);
  10.   if IsBRGACompatible(bytes) then
  11.     begin
  12.       graphic := TBGRABitmap.Create;
  13.       try
  14.         stream := TBytesStream.Create(bytes);
  15.         try
  16.           graphic.LoadFromStream(stream);
  17.           bmp := TBitmap.Create;
  18.           try
  19.             bmp.Assign(graphic.Bitmap);
  20.             AImage.Picture.Assign(bmp);
  21.           finally
  22.             bmp.Free;
  23.           end;
  24.         finally
  25.           stream.Free;
  26.         end;
  27.       finally
  28.         graphic.Free;
  29.       end;
  30.     end;
  31. end;

Create a tbgrabitmap and load from stream. Then assign to picture bitmap the bgrabitmap.bitmap, no need to use a temporary tbitmap. Also notice that you're freeing the bgrabitmap, that causes the tbitmap to don't be available anymore...

Or search the forums this was discussed already
Title: Re: New version of BGRABitmap
Post by: KodeZwerg on August 12, 2023, 12:17:04 am
Create a tbgrabitmap and load from stream. Then assign to picture bitmap the bgrabitmap.bitmap, no need to use a temporary tbitmap. Also notice that you're freeing the bgrabitmap, that causes the tbitmap to don't be available anymore...

Or search the forums this was discussed already
Same result. I try search forum okay.

I've overread your "free and it's gone", yes that is my problem, without free it display but thats somehow not what I wanted to have, a memoryleak.
I need to rethink ...
Title: Re: New version of BGRABitmap
Post by: lainz on August 12, 2023, 03:22:44 am
If I remember correctly there is a function called makeBitmapCopy that you can use to avoid this problem.
Title: Re: New version of BGRABitmap
Post by: KodeZwerg on August 12, 2023, 11:39:44 am
If I remember correctly there is a function called makeBitmapCopy that you can use to avoid this problem.
Thank you lainz, later I try to investigate it deeper.
ATM I am fine by doing it like this:
Code: Pascal  [Select][+][-]
  1.           graphic.LoadFromStream(stream);
  2.           bmp := TBitmap.Create;
  3.           try
  4.             bmp.PixelFormat := pf32bit;
  5.             bmp.Transparent := True;
  6.             bmp.SetSize(graphic.Width, graphic.Height);
  7.             bmp.Canvas.Lock;
  8.             try
  9.               bmp.Canvas.Draw(0, 0, graphic.Bitmap);
  10.             finally
  11.               bmp.Canvas.Unlock;
  12.             end;
  13.             AImage.Picture.Assign(bmp);
Regards, KodeZwerg
BGRABitmap rocks!
Title: Re: New version of BGRABitmap
Post by: paweld on August 12, 2023, 02:59:45 pm
@circular: Thank you very much.
Title: Re: New version of BGRABitmap
Post by: circular on August 12, 2023, 06:08:37 pm
You're welcome  :)

Hi KodeZwerg!

Indeed, what happens here is that the raster data of the bitmap is shared when assigning it.

In the end, it seems you've written something a bit similar to MakeBitmapCopy, except maybe with transparent background. It is probably not portable to other systems, but if that works for you that's all good.
Title: Re: New version of BGRABitmap
Post by: KodeZwerg on August 12, 2023, 08:55:43 pm
You're welcome  :)

Hi KodeZwerg!

Indeed, what happens here is that the raster data of the bitmap is shared when assigning it.

In the end, it seems you've written something a bit similar to MakeBitmapCopy, except maybe with transparent background. It is probably not portable to other systems, but if that works for you that's all good.
Yeah, I didnt knew it better to help myself.
Maby you having a solution for me by calling the MakeBitmapCopy() method correct?
Code: Pascal  [Select][+][-]
  1.             bmp.PixelFormat := graphic.Bitmap.PixelFormat;
  2.             bmp.Transparent := graphic.HasTransparentPixels;
This is how I currently do with my old way of doing but I having no idea about the arguments to put into MakeBitmapCopy() so it would work with whatever the transparency might be to work for all cases, like Icons or PNG's etc....
I am not that deep into graphics to find out on my own.
I've cloned current repo of your wonderful package but did not found any example usage for MakeBitmapCopy().
I guess in the end I just could "TImage.Picture.Bitmap := TBGRABitmap.MakeBitmapCopy(missing arguments...);"
Title: Re: New version of BGRABitmap
Post by: circular on August 12, 2023, 10:42:02 pm
MakeBitmapCopy does not handle really an alpha channel. It is intended to handle masked bitmap (either opaque or fully transparent pixels), as this is what's available in the LCL on all platforms. PixelFormat is buggy as far as I last tested it and is better not to use it.

With MakeBitmapCopy, you would still need to free the temporary TBitmap. In this case, the shared data is not linked to the TBGRABitmap so nothing bad happens.

Code: Pascal  [Select][+][-]
  1. var bmp: TBitmap;
  2. begin
  3.    ...
  4.    bmp := bgra.MakeBitmapCopy(clBtnFace);
  5.    AImage.Picture.Assign(bmp);
  6.    bmp.Free;
  7.    ...
  8. end;

Probably one of the simplest option if you want full transparency when available in the LCL is to store the image in a stream as PNG using TBGRABitmap.SaveToStreamAsPng and then load it into the TImage. Though that need some time to compress/decompress the PNG. It seems internally it uses Init_BPP32_B8G8R8A8_M1_BIO_TTB to define the RGBA format.
Code: Pascal  [Select][+][-]
  1. var stream: TMemoryStream;
  2. begin
  3.    ...
  4.    stream := TMemoryStream.Create;
  5.    bgra.SaveToStreamAsPng(stream);
  6.    stream.Position := 0;
  7.    AImage.Picture.PNG.LoadFromStream(stream);
  8.    stream.Free;
  9.    ...
  10. end;

What I would do is, instead of using a TImage for display, is to use a TBGRAVirtualScreen (opaque component) or TBGRAGraphicControl component of BGRAControls. This way, you can assign your image directly as BGRABitmap and always have alpha channel handling. If you need to prepare the image on form creation or that the area can be resized, then it is better to use the OnRedraw event and place/resize the image accordingly and put it on the Bitmap supplied as a parameter.

I have considered making a component that would be called TBCImage that would be like TImage but with a TBGRABitmap property.
Title: Re: New version of BGRABitmap
Post by: circular on September 19, 2023, 08:13:21 am
New version of BGRABitmap 11.5.6
https://github.com/bgrabitmap/bgrabitmap/releases/tag/v11.5.6

- AVIF format: support for libavif 1.0.0 (by DomingoGP)
- TIF format: support for BigTiff and YCbCr colorspace (by maxm74)
- Copy resolution when assigning image (by maxm74)
- Compilation fix for OpenBSD

Thanks to maxm74 and DomingoGP for the file formats update!
Title: Re: New version of BGRABitmap
Post by: alex208210 on October 21, 2023, 03:14:18 pm
Lazarus 2.2.6 FPC 3.2.2 BGRABitmap 11.5.6

not installed, requires fpgui_toolkit dependency

fpgui_toolkit is also not installed:
C:\lazarus\components\fpgui\src\corelib\gdi\fpg_oledragdrop.pas(113,23) Error: No matching implementation for interface method "SetData(const tagFORMATETC;var TagSTGMEDIUM;LongBool):LongInt; StdCall;" found
Title: Re: New version of BGRABitmap
Post by: circular on October 22, 2023, 04:15:24 pm
Hello Alex,

I am not sure to understand what you're saying. Can you explain?

Regards

EDIT: I suppose you've chosen bgrabitmappack4fpgui.lpk instead of bgrabitmappack.lpk
Title: Re: New version of BGRABitmap
Post by: alex208210 on October 29, 2023, 08:52:28 pm
Hello Alex,

I am not sure to understand what you're saying. Can you explain?

Regards

EDIT: I suppose you've chosen bgrabitmappack4fpgui.lpk instead of bgrabitmappack.lpk
Sorry, No Problem!)
Title: Re: New version of BGRABitmap
Post by: circular on October 30, 2023, 06:47:08 am
Ok, no problem. I am glad it works for you now.
Title: Re: New version of BGRABitmap
Post by: circular on November 27, 2023, 01:10:22 am
New version of BGRABitmap v11.5.7
https://github.com/bgrabitmap/bgrabitmap/releases

- added BGRAPapers unit (by maxm74)
- BGRABitmap package for Android
- compilation fix for assembler
- memory fix for SVG
- support for animated AVIF (by DomingoGP)
- support for animated PNG in TBGAAnimatedGif class
- added ResourceFile function (helpful for cross-platform with MacOS)
- data generation for GPT assistant

The package for Android bgrabitmappack4android.lpk avoids dependencies to OpenGL.

The ResourceFile function provided in BGRABitmapTypes finds a resource file near the binary (or in the parent folder on MacOS to make it more debugger friendly).
Title: Re: New version of BGRABitmap
Post by: nouzi on November 27, 2023, 11:05:52 am
New version of BGRABitmap v11.5.7
https://github.com/bgrabitmap/bgrabitmap/releases

- added BGRAPapers unit (by maxm74)
- BGRABitmap package for Android
- compilation fix for assembler
- memory fix for SVG
- support for animated AVIF (by DomingoGP)
- added ResourceFile function (helpful for cross-platform with MacOS)
- data generation for GPT assistant

The package for Android bgrabitmappack4android.lpk avoids dependencies to OpenGL.

The ResourceFile function provided in BGRABitmapTypes finds a resource file near the binary (or in the parent folder on MacOS to make it more debugger friendly).

very good
Title: Re: New version of BGRABitmap
Post by: Okoba on December 06, 2023, 11:22:51 am
Another good one. I like the BGRAPapers, thanks!
Title: Re: New version of BGRABitmap
Post by: lainz on December 06, 2023, 01:15:01 pm
Hi, In OPM I've asked to be available the previous version:
https://github.com/bgrabitmap/bgrabitmap/releases/tag/v11.5.6

Because this bug:
https://github.com/bgrabitmap/bgrabitmap/issues/224

When a new version is released fixing that bug, we can ask again to be updated.
Title: Re: New version of BGRABitmap
Post by: circular on December 08, 2023, 12:01:56 pm
Here is a quick release to fix significant issues with version 11.5.7.

Version 11.5.8:
- more paper sizes : DIN 476, Japanese, US, ANSI
- compilation fix for mseGUI (issue #225)
- runtime fix for LCL (issue #224)

https://github.com/bgrabitmap/bgrabitmap/releases

It introduces a class called TBGRAAnimatedPng that is in fact essentially the same as TBGRAAnimatedGif but has PNG format and 'apng' extension by default. This is needed to have distinct TGraphic class.

It is possible to show an animated PNG in a TImage, the only requirement is that the imported filename would be 'apng' so that it uses TBGRAAnimatedPng class instead of TPortableNetworkGraphic.

So TImage can be used now to display GIF and PNG animations.  :)
Title: Re: New version of BGRABitmap
Post by: circular on December 08, 2023, 12:05:38 pm
Another good one. I like the BGRAPapers, thanks!
Hi Okoba,

It is great to see you around. I hope all is well in your projects.

And long life to beloved pixels!  :)
Title: Re: New version of BGRABitmap
Post by: lainz on December 12, 2023, 02:28:12 am
GetMem sent me the confirmation email that the new version of bgrabitmap is in OPM now.  :)
Title: Re: New version of BGRABitmap
Post by: circular on December 13, 2023, 08:47:02 am
Cool, thanks for notifying me. So all is well now :)
Title: Re: New version of BGRABitmap
Post by: Okoba on December 14, 2023, 05:44:50 pm
Another good one. I like the BGRAPapers, thanks!
Hi Okoba,

It is great to see you around. I hope all is well in your projects.

And long life to beloved pixels!  :)

Thank you! Yes we both love them :) And lainz too :D
I always monitor your work, thank you for that. BTW, I emailed you before, so maybe you missed it.
Title: Re: New version of BGRABitmap
Post by: Josh on December 26, 2023, 12:29:45 pm
Latest Laz/FPC Fixes  Win 32

Lazarus 3.1 (rev lazarus_3_0-11-gd3a957ea98) FPC 3.2.3 i386-win32-win32/win64

BGRABitMap via OPM 10.5.8.0

Fails to Install

Code: Pascal  [Select][+][-]
  1. unibitmap.inc(121,5) Error: Duplicate identifier "FResolutionUnit"
  2. unibitmap.inc(121,20) Hint: Identifier already defined in unit FPIMAGE: fpimage.pp at line 121
  3. unibitmap.inc(122,5) Error: Duplicate identifier "FResolutionX"
  4. unibitmap.inc(122,17) Hint: Identifier already defined in unit FPIMAGE: fpimage.pp at line 122
  5. unibitmap.inc(123,5) Error: Duplicate identifier "FResolutionY"

Added:
Tried 10.4 which works on Lazarus 2.2.7 (rev ada7a90f86) FPC 3.2.3 i386-win32-win32/win64.
10.4 DOES not work on Latest fixes.

Looks like some change in laz/fpc has broken bgrabitmap.
Title: Re: New version of BGRABitmap
Post by: paweld on December 26, 2023, 12:58:23 pm
This is related to changes in FPC 3.2.3. Download BGRABitmap from the dev branch and it will work: https://github.com/bgrabitmap/bgrabitmap/tree/dev-bgrabitmap
Title: Re: New version of BGRABitmap
Post by: Josh on December 26, 2023, 02:31:02 pm
Hi

Tried dev branch, get diff error

Code: Pascal  [Select][+][-]
  1. bgrawritejpeg.pas(91,34) Error: Identifier not found "ResolutionUnitTodensity_unit"
Title: Re: New version of BGRABitmap
Post by: circular on December 26, 2023, 03:06:56 pm
Hi Josh,

Thanks for notifying. I've applied a fix on the dev branch. Does it compile now?

Regards
Title: Re: New version of BGRABitmap
Post by: Josh on December 26, 2023, 03:34:30 pm
now diff error
Code: Pascal  [Select][+][-]
  1. bgrawritejpeg.pas(25,27) Error: Identifier not found "TFPWriterJPEG"
  2. bgrawritejpeg.pas(25,40) Error: class type expected, but got "<erroneous type>"
Title: Re: New version of BGRABitmap
Post by: circular on December 26, 2023, 04:51:45 pm
Ah yes, I've made a mistake in the uses clause.

And now?
Title: Re: New version of BGRABitmap
Post by: Josh on December 26, 2023, 05:36:05 pm
compiling ok now :)


bgacontrols v8.0 now giving error

Code: Pascal  [Select][+][-]
  1. bgraknob.pas(162,47) Error: Incompatible types: got "TPointF" expected "Single"

reported on bgracontrols topic
Title: Re: New version of BGRABitmap
Post by: circular on December 27, 2023, 05:41:38 am
Thanks!  :)

I've answered on BGRAControls topic.
https://forum.lazarus.freepascal.org/index.php/topic,24176.msg500524.html#msg500524
Title: Re: New version of BGRABitmap
Post by: Josh on December 27, 2023, 08:38:03 pm
hi

thanks for fast response, replied in bgracontrols topiv thread.

Quote
Hi

Yep compiled and all appears good.

thanks for your rapid fix  :)
Title: Re: New version of BGRABitmap
Post by: circular on March 06, 2024, 08:03:36 pm
BGRABitmap has now a wonderful website with documentation!

It can be accessed from two URLs:
https://bgrabitmap.web.app/
https://bgrabitmap.github.io/

Enjoy   :)

A big thank to DomingoGP for making the proof of concept that generates the documentation using pasdoc and a big thank to michaliskambi for helping out with pasdoc.

If you love BGRABitmap, you can be featured in the testimonials and have your quote on the website!
Title: Re: New version of BGRABitmap
Post by: lainz on March 07, 2024, 12:30:13 am
Add me as testimonial

With bgrabitmap I can build custom controls for Lazarus that looks awesome and are fast at the same time.
Title: Re: New version of BGRABitmap
Post by: circular on March 07, 2024, 07:28:47 am
Cool quote indeed.  :)

Here is a preview of your quote. Feel free to let me know if there's anything you'd like to change or add to your testimonial.

I will wait for your validation and also for other quotes so that you're not the only one on the website.
Title: Re: New version of BGRABitmap
Post by: lainz on March 07, 2024, 01:22:27 pm
Hi, It's ok. Thanks.  :)
Title: Re: New version of BGRABitmap
Post by: 440bx on March 07, 2024, 01:54:34 pm
It all looks really good.

One thing I'd like to see is a list of examples arranged in order of difficulty/complexity.  That's usually very useful and avoids a lot of frustration.

If that's already there somewhere then I'd suggest their availability to be made more visible and prominent.
Title: Re: New version of BGRABitmap
Post by: circular on March 07, 2024, 03:12:57 pm
I am glad you like the design.  :)

I take a note of your suggestion for graduated examples:
https://forum.lazarus.freepascal.org/index.php/topic,17565.msg510096.html#msg510096

By the way would you be interested in having your testimony on the website?
Title: Re: New version of BGRABitmap
Post by: 440bx on March 07, 2024, 03:50:21 pm
By the way would you be interested in having your testimony on the website?
It will be my pleasure to add a testimonial (one caveat... I need to acquire more knowledge for my testimonial about  BGRABitmap to be worth something)
Title: Re: New version of BGRABitmap
Post by: circular on March 07, 2024, 03:57:09 pm
Well let's have a try. Maybe you define yourself as a beginner, that's ok. Every input is valuable. So what would you be your experience is?
Title: Re: New version of BGRABitmap
Post by: 440bx on March 07, 2024, 04:08:33 pm
So far I've just seen the results obtained by some of the forum members who use it and the many comments (and sometimes examples) about it here in the forums. 

I've been meaning to get my hands into it (I like creating nice looking graphical interfaces) but, there is always something else monopolizing my attention.

I'm most definitely a beginner when it comes to BGRABitmap but, as I said previously, it will be my pleasure to offer a worthwhile testimonial once I can make one ;)  Thank you for the encouragement to produce one.
Title: Re: New version of BGRABitmap
Post by: circular on March 07, 2024, 04:22:09 pm
I understand. Sure, have fun with it if you get your hands into it.  :)

Well you're welcome around anyway  :-*
Title: Re: New version of BGRABitmap
Post by: Okoba on March 10, 2024, 11:33:38 am
Nice website! Add a fav icon for it too.
Me: "BGRABitmap helped me express and grow my love for pixels."
Title: Re: New version of BGRABitmap
Post by: circular on March 10, 2024, 02:36:00 pm
Thank you Okoba  :)

It's a pleasure to see you around.

I love your quote. With it, what would be the name and the avatar?
Title: Re: New version of BGRABitmap
Post by: Okoba on March 11, 2024, 09:56:25 am
I am always following your work and BGRABitmap.
Okoba is fine, but I have no Avatar. I can choose one if you like!
Title: Re: New version of BGRABitmap
Post by: AlexTP on March 11, 2024, 11:31:39 am
"With BGRABitmap, I reworked painting of per-pixel mini-map in my text editor CudaText. Mini-map code became 2...4 times faster (comparing to TCanvas.SetPixel). And I even was able to put that code into its own thread, so minimap rendering runs in parallel!" - Alexey T., CudaText author
Title: Re: New version of BGRABitmap
Post by: circular on March 11, 2024, 02:53:02 pm
Cool, I have a lot of quotes now on the website. Thank you  :)

Okoba, I have put a heart drawn with big pixels for you!
Title: Re: New version of BGRABitmap
Post by: Okoba on March 12, 2024, 08:56:03 am
That is the loveliest avatar I ever had. Thank you, my friend!
Title: Re: New version of BGRABitmap
Post by: circular on March 12, 2024, 10:52:44 am
You're very welcome my dear  :)
Title: Re: New version of BGRABitmap
Post by: Okoba on March 12, 2024, 05:42:26 pm
 :-[
Title: Re: New version of BGRABitmap
Post by: circular on March 13, 2024, 02:19:51 pm
I thought of this poem:

The world is unknown, but nonetheless
A conclusion is inescapable to anybody
The world is vast, very vast, we can guess.
A group of friends might number around twenty
But a medium-sized country contains 7 million.
We can't really grasp this scale.
It's akin to an ultra high definition
A 4K screen of which we are but a single pixel.
And the Earth contains billions of folks,
In other words, a thousand of these screens,
Arranged in a 32 by 32 box.
The color of a pixel cannot be seen,
Yet without it, these apparatus
would have no stories to tell us.
Title: Re: New version of BGRABitmap
Post by: lainz on March 13, 2024, 02:22:41 pm
 ;)
very good
Title: Re: New version of BGRABitmap
Post by: circular on March 13, 2024, 02:53:28 pm
Thank you  :-[
Title: Re: New version of BGRABitmap
Post by: Okoba on March 14, 2024, 04:18:20 pm
I thought of this poem:

The world is unknown, but nonetheless
A conclusion is inescapable to anybody
The world is vast, very vast, we can guess.
A group of friends might number around twenty
But a medium-sized country contains 7 million.
We can't really grasp this scale.
It's akin to an ultra high definition
A 4K screen of which we are but a single pixel.
And the Earth contains billions of folks,
In other words, a thousand of these screens,
Arranged in a 32 by 32 box.
The color of a pixel cannot be seen,
Yet without it, these apparatus
would have no stories to tell us.

Lovely to imagine. I guess effective people function as a gradient, giving colour to pixels/peoples they touch.
Title: Re: New version of BGRABitmap
Post by: circular on March 15, 2024, 08:43:02 am
Ohhh that's sweet, gradient-like people.
Title: Re: New version of BGRABitmap
Post by: circular on March 17, 2024, 12:53:48 pm
New version of BGRABitmap (11.6)
https://github.com/bgrabitmap/bgrabitmap/releases
required for BGRAControls v9.0 (https://forum.lazarus.freepascal.org/index.php/topic,24176.msg511364.html#msg511364)

Changes
- core version of BGRABitmap available: by adding the library to the project include path and setting BGRABITMAP_CORE directive (see test/testcore (https://github.com/bgrabitmap/bgrabitmap/tree/dev-bgrabitmap/test/testcore) sample)
- package with FreeType support for Android and NoLCL (requires freetypelaz package)
- documentation for pasdoc (https://github.com/pasdoc/pasdoc) (all units and all classes have a description)
- compilation fixes for latest FPC
- reduce warning count issued by compiler
- TBGRABitmap: added CopyProperties parameter to more functions
- add HalfUp rounding function (similar to Round but always rounded up) to avoid misalignments of texts (see issue #238 (https://github.com/bgrabitmap/bgrabitmap/issues/238))
- TBGRAIconCursor: add GetBestFitIndex function to get index of image instead of bitmap
- BGRAVectorize: fixes for serialized vectorized font (see test/testcore (https://github.com/bgrabitmap/bgrabitmap/tree/dev-bgrabitmap/test/testcore) samples and forum thread (https://forum.lazarus.freepascal.org/index.php/topic,66508.msg510460.html#msg510460)), now kerning is saved in glyphs files
- optimized HSL blend modes (boLinearHue, boLinearColor, boLinearLightness, boLinearSaturation)

About core version
Core version is useful for small projects, if you want to reduce the size of the binaries. BGRABitmap can be about 50% smaller if you only use what's available in TBGRABitmap and no other units/classes).

BGRAVectorize also helps reducing size. You can make a program to serialize the glyphs you need in a .glyphs file. Then in another small program, you can draw text using TBGRAVectorizedTextRenderer without the LCL nor FreeType.
Title: Re: New version of BGRABitmap
Post by: Okoba on March 17, 2024, 05:16:10 pm
"BGRABitmap can by about 50% smaller" seems to be a typo.
How much (in kilobytes) is 50% in your tests?
Title: Re: New version of BGRABitmap
Post by: circular on March 17, 2024, 06:30:59 pm
Ah indeed, it was "can be".

Little test program without LCL and regular BGRABitmap: 2082 Ko
Same program without LCL and BGRABitmap core: 1187 Ko
Same program without LCL but without BGRABitmap: 271 Ko
=> 49 % smaller

Little test program using LCL and regular BGRABitmap: 4060 Ko
Same program using LCL and BGRABitmap core: 3559 Ko
Same program using LCL but without BGRABitmap: 2663 Ko
=> 36 % smaller
Title: Re: New version of BGRABitmap
Post by: d7_2_laz on March 17, 2024, 11:03:11 pm
Thanks circular for integrating the core version and your efforts, that makes it more attractive to use it for small projects too!   :)

Title: Re: New version of BGRABitmap
Post by: circular on March 22, 2024, 07:21:17 am
Hi folks. Yet another version (v11.6.1)
https://github.com/bgrabitmap/bgrabitmap/releases

Bug fixes
- fix hue gradient from color to same color (#245 (https://github.com/bgrabitmap/bgrabitmap/issues/245))
- patch for text angle on MacOS (see Lazarus issue 40855 (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40855))
- take into account LCL font kerning in TextSize and BGRAVectorize (#246 (https://github.com/bgrabitmap/bgrabitmap/issues/246))
- fix some examples for different OS / DPI scaling (test (https://github.com/bgrabitmap/bgrabitmap/tree/master/test) folder)

New feature
- support for SVG masks (#202 (https://github.com/bgrabitmap/bgrabitmap/issues/202))
- add TextOutOffset function #125 (https://github.com/bgrabitmap/bgrabitmap/issues/125)
- add RightToLeft parameter to CanvasBGRA.TextOut
- accommodating for some GIF extra data #192 (https://github.com/bgrabitmap/bgrabitmap/issues/192)
TinyPortal © 2005-2018